From 83982f8e5cdad5b5dd89fb2dafee91a03eed4070 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sun, 28 Feb 2021 09:28:51 +0100 Subject: [PATCH] KRunner: Handle escape key in history view more gracefully Instead of adding an unprintable character to the UI the history view is closed and the text field it focused. To prevent unprintable characters like backspace a regex is used, just like we already do in the ResultsView Keys.onPressed slot. BUG: 433723 FIXED-IN: 5.21.2 --- lookandfeel/contents/runcommand/RunCommand.qml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lookandfeel/contents/runcommand/RunCommand.qml b/lookandfeel/contents/runcommand/RunCommand.qml index 7368faf51..27170d9d8 100644 --- a/lookandfeel/contents/runcommand/RunCommand.qml +++ b/lookandfeel/contents/runcommand/RunCommand.qml @@ -325,7 +325,12 @@ ColumnLayout { } else if (ctrl && event.key === Qt.Key_K) { decrementCurrentIndex() } else if (event.text !== "") { - queryField.text += event.text; + // This prevents unprintable control characters from being inserted + if (event.key == Qt.Key_Escape) { + root.showHistory = false + } else if (!/[\x00-\x1F\x7F]/.test(event.text)) { + queryField.text += event.text; + } queryField.focus = true; } }