-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextEdit multicaret and selection issues #86863
Labels
Milestone
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested versions
Godot v4.2, v4.3.dev (179dfdc)
System information
Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 (NVIDIA; 31.0.15.3598) - Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 Threads)
Issue description
Some of these issues are only relevent to
CodeEdit
,CodeEditor
, orScriptTextEditor
, but most stem fromTextEdit
.related issues:
CodeEdit
functions crashes Godot #73202ctrl+d
with some multi line selections #71217CTRL+/
on Windows #83410related PRs:
I am working on a PR to fix all of these issues.
API #
add_caret
,remove_caret
,set_caret_line
,set_caret_col
,set_line
,remove_text
, etc.caret_blink
is off.caret_index
to various functions doesn't error for indexes at carets.size() or below -1.insert_text_at_caret
,select_word_under_caret
,select_word_under_caret
,delete_selection
,_handle_unicode_input_internal
,_backspace_internal
,_cut_internal
,_copy_internal
,_paste_internal
,_paste_primary_clipboard_internal
,get_word_under_caret
,has_selection
,get_selected_text
.remove_text()
doesn't adjust carets. It is mentioned in the documentation, but it is not consistent with all other methods.set_line()
doesn't properly adjust carets. selection from is ignored and passing in multiple lines doesn't adjust carets below.insert_line_at
doesn't offset carets after the inserted line correctly.insert_line_at
is called with the subsequent line, they are merged together so undo will undo both calls.caret_index_edit_dirty
is only set when in the tree, and after the first edit, getting the caret order won't be up to date.Backspace #
Using backspace when indent_using_spaces is true and there are multiple carets in the last tab of a line, the wrong characters can be deleted. There must be a caret at the first non whitespace column, and another before it within that same tab.
test
.tst
, when it should betest
.Using backspace at the start of a line with multiple carets on it moves the carets straight up to the previous line if it can.
If a caret is placed one character to the left of another, it shows errors like
The main caret should not be removed.
orscene\gui\text_edit.cpp:4878 - Index p_caret = 1 is out of bounds (carets.size() = 1).
Delete #
scene\gui\text_edit.cpp:4563 Index p_caret = 2 is out of bounds
orThe main caret should not be removed.
.Copy, Cut, Paste #
The main caret should not be removed.
orscene\gui\text_edit.cpp:4878 - Index p_caret = 1 is out of bounds (carets.size() = 1).
IME (Fixed #87479) #
Clicking inside the TextEdit but outside of IME area does not apply the IME text or close it.
scene\gui\text_edit.cpp:4991 - Index p_column = 3 is out of bounds (text[carets[p_caret].selection.selecting_line].length() + 1 = 1).
Clicking outside the TextEdit (on something focusable) closes the IME and does not apply it, however clicking outside the window or using alt+tab closes and applies the IME.
It is possible to select text while the IME is still open by clicking and dragging. This can cause multiple errors.
scene\gui\text_edit.cpp::4984
Cannot use the mouse wheel or drag the minimap when IME is open, but can use scrollbar.
Some actions can still be used while IME is open, when using shortcut or the MenuBar. These should all close the IME.
Mouse selection #
Selections can overlap.
merge_overlapping_carets()
doesn't catch it.Shift selecting left/up when selection is left to right appends to the selection instead of selecting to the from position.
scene\gui\text_edit.cpp:7841 - Condition "p_to_line < p_from_line" is true. Returning: String()
Error when clicking in selection if it's not the last caret's selection.
scene\gui\text_edit.cpp:5189 - Condition "!has_selection(p_caret)" is true. Returning: -1
If a selection is made in selection mode word or line, adding a new selection with a new caret (alt+click and drag) will be made in the same mode instead of in pointer mode.
When shift selecting and changing selection mode with shift+double click the selection origin can change unexpectedly.
While dragging and using shortcuts that change text at the same time (toggling comments, indentation, etc) the selection origin can be moved around.
Selection mode word
When double clicking without a word (such as at the end of a line, spaces or symbols), the starting selection word will become the next word highlighted or wrong instead of being none.
Cannot activate on an empty line.
Shift+double click and drag starts drag and drop instead of starting selection mode word.
Selection mode line
Drag and drop selected text #
scene\gui\text_edit.cpp:5195 - Condition "!has_selection(p_caret)" is true. Returning: -1
scene\gui\text_edit.cpp:5207 - Condition "!has_selection(p_caret)" is true. Returning: -1
.ui_text_add_caret_below
to change carets while dragging text.scene\gui\text_edit.cpp:5213 - Condition "!has_selection(p_caret)" is true. Returning: -1
drag_caret_force_displayed
doesn't get set back to false when the mouse exits.Text
andPlaceholder Text
fields in the Inspector.Toggle comment #
Uncomment when selection from line was at the end of a single comment and the selection to line is at column 0 shows errors
scene\gui\text_edit.cpp:7838 - Index p_from_column = 1 is out of bounds (text[p_from_line].length() + 1 = 1).
.Selecting from the last column of a line leftwards then uncommenting and clicking the end of the line shows an error. Error when using
CTRL+/
on Windows #83410 and TextEdit caret line selection raises: Index p_column = N is out of bounds #72797.When selection end is at column 0, the selection start is offset wrong.
Toggle indent #
CTRL+/
on Windows #83410 and TextEdit caret line selection raises: Index p_column = N is out of bounds #72797.Auto indent
Convert Indent
Duplicate Selection #
Duplicate Lines Down #
Add caret above/below #
scene\gui\text_edit.cpp:5294 - Index p_line = -1 is out of bounds (text.size() = 124).
Toggle Fold line #
Create Code Region #
scene\gui\text_edit.cppscene\gui\text_edit.cpp:5189 - Condition "!has_selection(p_caret)" is true. Returning: -1
Connect Signal #
Go to Line and Go to Function #
Reload Scripts #
scene\gui\text_edit.cpp:5195 - Condition "!has_selection(p_caret)" is true. Returning: -1
CodeTextEditor::get_navigation_state()
checks if there is any selection before trying to get the first carets selection, even if the first caret has no selection.I found a few other issues, but I'll open separate issues for them.
Steps to reproduce
See above for steps and details, let me know if any aren't clear enough.
API issues are reproducible with a TextEdit and using the related methods.
All others should be reproducible in the Script editor, unless otherwise specified.
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: