[rkward/work/new_completion_to_console] /: Fix Enter key in console completion (and improve in script completion)
Thomas Friedrichsmeier
null at kde.org
Sun Apr 26 21:03:32 BST 2020
Git commit d5c0e347941ccd2b70a90534483cef121d46ac36 by Thomas Friedrichsmeier.
Committed on 26/04/2020 at 20:03.
Pushed by tfry into branch 'work/new_completion_to_console'.
Fix Enter key in console completion (and improve in script completion)
M +2 -1 ChangeLog
M +11 -0 rkward/windows/rkcodecompletion.cpp
https://commits.kde.org/rkward/d5c0e347941ccd2b70a90534483cef121d46ac36
diff --git a/ChangeLog b/ChangeLog
index 79ba9c74..74985e2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,13 +8,14 @@
* TODO: Bring new code hinting features to the console window!
- Tab key (+option)
- Clean up unused code
- - Enter key behavior
- On unix-systems, RKWard can now be run without installation
- TODO: common.js is not found in plugins!
- Kate addons are now supported within RKWard. Intially, search-in-files, snippets, and projects are loaded by default
* TODO: Some plugins still have UI issues. E.g.:
- SQL plugin fails to add toplevel menu
- Text filter plugin always shows menu entry, but should be limited to script windows
+- TODO:
+ - Ctrl+Enter action now clashes with kate part...
--- Version 0.7.1 - Jan-23-2020
- Code hinting in script editor windows has been reworked, and now also completes argument names
diff --git a/rkward/windows/rkcodecompletion.cpp b/rkward/windows/rkcodecompletion.cpp
index 71086cfb..784b7523 100644
--- a/rkward/windows/rkcodecompletion.cpp
+++ b/rkward/windows/rkcodecompletion.cpp
@@ -359,6 +359,7 @@ KTextEditor::Range RKCompletionManager::currentCallRange () const {
bool RKCompletionManager::eventFilter (QObject*, QEvent* event) {
if (event->type () == QEvent::KeyPress || event->type () == QEvent::ShortcutOverride) {
RK_TRACE (COMMANDEDITOR); // avoid loads of empty traces, putting this here
+ if (!cc_iface->isCompletionActive()) return false;
QKeyEvent *k = static_cast<QKeyEvent *> (event);
// If only the calltip is active, make sure the tab-key and enter behave as a regular keys. There is no completion in this case.
@@ -371,6 +372,16 @@ bool RKCompletionManager::eventFilter (QObject*, QEvent* event) {
}
}
+ if ((k->modifiers() == Qt::NoModifier) && ((k->key () == Qt::Key_Return) || (k->key () == Qt::Key_Enter))) {
+ if (k->type () == QEvent::ShortcutOverride) {
+ // Too bad for all the duplicate work, but the event will re-trigger as a keypress event, and we need to intercept that one, too.
+ return true;
+ }
+ cc_iface->forceCompletion();
+ if (settings->autoEnabled ()) ignore_next_trigger = true;
+ return true;
+ }
+
if (k->key () == Qt::Key_Tab && (!k->modifiers ())) {
// Try to do partial completion. Unfortunately, the base implementation in ktexteditor is totally broken (inserts the whole partial completion, without removing the start).
// TODO: It is not quite clear, what behavior is desirable, in case more than one completion model is active at a time.
More information about the rkward-tracker
mailing list