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