Skip to content

Commit fc95daa

Browse files
jonasschnelliluke-jr
authored andcommitted
Qt/RPCConsole: Save current command entry when browsing history
Shell-like, but doesn't store changed history commands until executing it.
1 parent dce853e commit fc95daa

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/qt/rpcconsole.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ void RPCConsole::on_lineEdit_returnPressed()
751751

752752
if(!cmd.isEmpty())
753753
{
754+
cmdBeforeBrowsing = QString();
755+
754756
message(CMD_REQUEST, cmd);
755757
Q_EMIT cmdRequest(cmd);
756758
// Remove command, if already in history
@@ -769,6 +771,11 @@ void RPCConsole::on_lineEdit_returnPressed()
769771

770772
void RPCConsole::browseHistory(int offset)
771773
{
774+
// store current text when start browsing through the history
775+
if (historyPtr == history.size()) {
776+
cmdBeforeBrowsing = ui->lineEdit->text();
777+
}
778+
772779
historyPtr += offset;
773780
if(historyPtr < 0)
774781
historyPtr = 0;
@@ -777,6 +784,9 @@ void RPCConsole::browseHistory(int offset)
777784
QString cmd;
778785
if(historyPtr < history.size())
779786
cmd = history.at(historyPtr);
787+
else if (!cmdBeforeBrowsing.isNull()) {
788+
cmd = cmdBeforeBrowsing;
789+
}
780790
ui->lineEdit->setText(cmd);
781791
}
782792

src/qt/rpcconsole.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public Q_SLOTS:
140140
ClientModel *clientModel;
141141
QStringList history;
142142
int historyPtr;
143+
QString cmdBeforeBrowsing;
143144
QList<NodeId> cachedNodeids;
144145
const PlatformStyle *platformStyle;
145146
RPCTimerInterface *rpcTimerInterface;

0 commit comments

Comments
 (0)