summaryrefslogtreecommitdiffstats
path: root/core/input
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2024-04-16 00:21:14 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2024-04-16 00:21:14 +0200
commit9558d4f28fef77696027c6e654feb33f6caa8db7 (patch)
tree5f80013d6aae3dab8cb86d94b359e511bd893e8e /core/input
parent4728ff30c0226b9918b29a6ba494dc61eae87639 (diff)
downloadredot-engine-9558d4f28fef77696027c6e654feb33f6caa8db7.tar.gz
Make TextEdit autocompletion replace word unless Shift is held
This makes Tab and Enter act identical by default for autocompletion. If Shift is held, the suggestion is added in-place without the word being replaced. This matches the behavior found in Visual Studio Code where the following occurs: - Pressing Tab accepts the suggestion and replaces the word. - Pressing Enter accepts the suggestion and replaces the word. - Pressing Shift + Tab accepts the suggestion and doesn't replace the word. - Pressing Shift + Enter accepts the suggestion and doesn't replace the word.
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input_map.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index 7fd1806b31..34255898e6 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -510,12 +510,15 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
default_builtin_cache.insert("ui_text_completion_query", inputs);
inputs = List<Ref<InputEvent>>();
- inputs.push_back(InputEventKey::create_reference(Key::ENTER));
- inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
+ inputs.push_back(InputEventKey::create_reference(KeyModifierMask::SHIFT | Key::TAB));
+ inputs.push_back(InputEventKey::create_reference(KeyModifierMask::SHIFT | Key::ENTER));
+ inputs.push_back(InputEventKey::create_reference(KeyModifierMask::SHIFT | Key::KP_ENTER));
default_builtin_cache.insert("ui_text_completion_accept", inputs);
inputs = List<Ref<InputEvent>>();
inputs.push_back(InputEventKey::create_reference(Key::TAB));
+ inputs.push_back(InputEventKey::create_reference(Key::ENTER));
+ inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
default_builtin_cache.insert("ui_text_completion_replace", inputs);
// Newlines
@@ -525,7 +528,6 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
default_builtin_cache.insert("ui_text_newline", inputs);
inputs = List<Ref<InputEvent>>();
-
inputs.push_back(InputEventKey::create_reference(Key::ENTER | KeyModifierMask::CMD_OR_CTRL));
inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER | KeyModifierMask::CMD_OR_CTRL));
default_builtin_cache.insert("ui_text_newline_blank", inputs);