Skip to content

Conversation

@Tucchhaa
Copy link
Contributor

No description provided.

Comment on lines +116 to +124
connect(
m_history_edit->document(),
&QTextDocument::contentsChanged,
this,
[this]()
{
const int newHeight = calcHeightToFitContents(m_history_edit);
m_history_edit->setMinimumHeight(newHeight);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set minHeight to history editor so that it would fill all free space in scrollArea if there's some

Comment on lines +125 to +133
connect(
m_command_edit->document(),
&QTextDocument::contentsChanged,
this,
[this, commandEditMinHeight]()
{
const int newHeight = std::max(calcHeightToFitContents(m_command_edit), commandEditMinHeight);
m_command_edit->setFixedHeight(newHeight);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set fixedHeight to commandEdit so that it is big enough to contain all the text, but doesn't stretch if scrollArea has free space

Comment on lines +172 to +177
std::string const command = m_command_edit->toPlainText().trimmed().toStdString();

if (command.length() == 0)
{
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added trimmed(), so that user wouldn't execute empty command

Comment on lines -147 to -148
printCommandStdout(m_python_redirect.stdout_string());
printCommandStderr(m_python_redirect.stderr_string());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printCommandStderr and printCommandStdout were duplicates of writeToHistory so I removed them

Comment on lines 245 to -250
QTextCursor cursor = m_history_edit->textCursor();
cursor.movePosition(QTextCursor::End);
m_history_edit->setTextCursor(cursor);
m_history_edit->insertPlainText(QString::fromStdString(data));
cursor.movePosition(QTextCursor::End);
m_history_edit->setTextCursor(cursor);
Copy link
Contributor Author

@Tucchhaa Tucchhaa Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we just need to set cursor before we write to the editor since it's read-only editor

setCommand(QString::fromStdString(command_to_show));
}

void RPythonConsoleDockWidget::navigateCommand(int offset)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function contained a bug, when not yet executed command couldn't be restored after navigating to past commands and back to the not yet executed command. So I have fixed the bug and simplified the function.

Comment on lines +182 to +183
const auto formatted_command = std::format("[{}] {}\n\n", m_last_command_serial, command);
writeToHistory(formatted_command);
Copy link
Contributor Author

@Tucchhaa Tucchhaa Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an equivalent replacement of printCommandHistory() function

Comment on lines +53 to +54
const bool is_first_line_focused = cursor.blockNumber() == 0;
const bool is_last_line_focused = cursor.blockNumber() == document()->blockCount() - 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need this so that navigation between lines of a past command is possible

@Tucchhaa Tucchhaa marked this pull request as ready for review January 27, 2026 06:42
@Tucchhaa Tucchhaa marked this pull request as draft January 27, 2026 06:43
@Tucchhaa Tucchhaa marked this pull request as ready for review January 28, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant