DebugConsole: restore non-history text on down key

When user starts typing something in the console, then navigates the
history with up but comes back to normal input by pressing down, restore
the text that was initially typed before navigating.
This commit is contained in:
miruka 2020-09-28 17:21:56 -04:00
parent 68d1ddfa61
commit 4cc4229728

View File

@ -19,6 +19,7 @@ HDrawer {
property alias his: debugConsole.history
property int historyEntry: -1
property int maxHistoryLength: 4096
property var textBeforeHistoryNavigation: null // null or string
property string help: qsTr(
`Javascript debugging console
@ -131,9 +132,20 @@ HDrawer {
}
}
onHistoryEntryChanged:
inputArea.text =
historyEntry === -1 ? "" : history.slice(-historyEntry - 1)[0]
onHistoryEntryChanged: {
if (historyEntry === -1) {
inputArea.clear()
inputArea.append(textBeforeHistoryNavigation)
textBeforeHistoryNavigation = null
return
}
if (textBeforeHistoryNavigation === null)
textBeforeHistoryNavigation = inputArea.text
inputArea.clear()
inputArea.append(history.slice(-historyEntry - 1)[0])
}
HShortcut {
sequences: settings.keys.toggleDebugConsole