From 7d15ecc3affdee1ad89ef1a2eeaca6b894ae6548 Mon Sep 17 00:00:00 2001 From: Alfred Reinold Baudisch Date: Wed, 19 Oct 2022 19:35:14 +0200 Subject: Add Selection and Caret for Next Occurrence of Selection Adds the bind `add_selection_for_next_occurrence` to TextEdit, with CTRL+D as the default shortcut. When the bind is performed, ff a selection is currently active with the last caret in text fields, searches for the next occurrence of the selection, adds a caret and selects the next occurrence. If no selection is currently active with the last caret in text fields, selects the word currently under the caret. The action can be performed sequentially for all occurrences of the selection of the last caret and for all existing carets. The viewport is adjusted to the latest newly added caret. The bind and the behaviour is similar to VS Code's "Add Selection to Next Find Match" and JetBrains' "Add Selection for Next Occurrence". It takes advantage of the multi-caret API. The default shortcut for `select_word_under_caret` has been changed to ALT+G, in order to give priority to CTRL+D for `add_selection_for_next_occurrence` to better align with popular IDEs and editors. --- doc/classes/ProjectSettings.xml | 9 ++++++++- doc/classes/TextEdit.xml | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index a8080c70c6..f03fe15fb3 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -830,6 +830,13 @@ + + If a selection is currently active with the last caret in text fields, searches for the next occurrence of the selection, adds a caret and selects the next occurrence. + If no selection is currently active with the last caret in text fields, selects the word currently under the caret. + The action can be performed sequentially for all occurrences of the selection of the last caret and for all existing carets. + The viewport is adjusted to the latest newly added caret. + [b]Note:[/b] Default [code]ui_*[/code] actions cannot be removed as they are necessary for the internal logic of several [Control]s. The events assigned to the action can however be modified. + Default [InputEventAction] to delete the character before the text cursor. [b]Note:[/b] Default [code]ui_*[/code] actions cannot be removed as they are necessary for the internal logic of several [Control]s. The events assigned to the action can however be modified. @@ -984,7 +991,7 @@ If no selection is currently active, selects the word currently under the caret in text fields. If a selection is currently active, deselects the current selection. - [b]Note:[/b] Currently, this is only implemented in [TextEdit], not [LineEdit]. + [b]Note:[/b] Default [code]ui_*[/code] actions cannot be removed as they are necessary for the internal logic of several [Control]s. The events assigned to the action can however be modified. Default [InputEventAction] to submit a text field. diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index b1fda25ecd..879a355f25 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -70,6 +70,12 @@ Register a new gutter to this [TextEdit]. Use [param at] to have a specific gutter order. A value of [code]-1[/code] appends the gutter to the right. + + + + Adds a selection and a caret for the next occurrence of the current selection. If there is no active selection, selects word under caret. + + -- cgit v1.2.3