Skip to content
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

Out of bounds error on ctrl+d with some multi line selections #71217

Closed
duianto opened this issue Jan 11, 2023 · 4 comments · Fixed by #91390
Closed

Out of bounds error on ctrl+d with some multi line selections #71217

duianto opened this issue Jan 11, 2023 · 4 comments · Fixed by #91390

Comments

@duianto
Copy link

duianto commented Jan 11, 2023

Godot version

v4.0.beta11.official [91713ce]

System information

Windows 10 22H2, Compatibility, GeForce GTX 550 Ti

Issue description

In the Script Editor.
Sometimes when a selection spans multiple lines.
Pressing: ctrl d (which calls: ui_text_add_selection_for_next_occurrence)
Shows an error message in the Output panel:

scene/gui/text_edit.cpp:4057 - Index p_from_column = 15 is out of bounds (text[p_from_line].length() + 1 = 1).

Steps to reproduce

  • start Godot
  • open the attached project (it just has a new unmodified script with the default template)
  • open the script Node2D.gd
  • open the Output panel, near the bottom left of Godot
  • in the Script Editor, select from the end of the first line to the second line,
    either with the keyboard (shift down), or with the mouse
  • press ctrl d

Expected

A second cursor should be added on line 3,
and second selection should span from the end of line 2 to line 3.
| = a cursor,
[ = a selection start
] = a selection end

Before Ctrl d

extends Node2D[
|]

After Ctrl d

extends Node2D[
|][
|]

The expected behavior is observed in Visual Studio Code,
with the same code example, and shortcut: ctrl d

Before Ctrl d

before

After Ctrl d

after

Observed

The Output panel shows the error message:

scene/gui/text_edit.cpp:4057 - Index p_from_column = 15 is out of bounds (text[p_from_line].length() + 1 = 1).

Selecting upwards from the second line to the end of the first, and pressing ctrl d,
shows the error message:

scene/gui/text_edit.cpp:4057 - Index p_from_column = 15 is out of bounds (text[p_from_line].length() + 1 = 15).

No errors when selecting in one direction

At first, it seemed like it might be happening when a new line is included in the selection.

But there is no error when selecting upwards:

  • from the second line to the first line, including the first line's last character:
extends Node2[|D
]
  • or downwards from the third line to the beginning, middle, or end of the fourth line:
extends Node2D

[
# Called|] when the node enters the scene tree for the first time.

But there are errors when selecting in the other direction

Downwards:

extends Node2[D
|]

scene/gui/text_edit.cpp:4057 - Index p_from_column = 14 is out of bounds (text[p_from_line].length() + 1 = 1).

Upwards:

extends Node2D

[|
# Called] when the node enters the scene tree for the first time.

scene/gui/text_edit.cpp:4057 - Index p_from_column = 1 is out of bounds (text[p_from_line].length() + 1 = 1).

Minimal reproduction project

issue, ctrl d, next occurrence.zip

@YuriSizov
Copy link
Contributor

cc @aXu-AP perhaps this is something that you've fixed (or are interested in fixing)

@aXu-AP
Copy link
Contributor

aXu-AP commented Feb 14, 2023

Thanks for the heads up, I might look at it some point, but I'm gonna be busy for some time now. But I tested this and can confirm this happens.
I didn't actually know this operation existed (it's called ui_text_add_selection_for_next_occurrence in shortcut settings), since I've remapped duplicate selection to ctrl+D long ago in my setup. Got me confused for a second 😅

@MewPurPur
Copy link
Contributor

I'm on it.

@YuriSizov YuriSizov added this to the 4.3 milestone Jan 12, 2024
@YuriSizov YuriSizov changed the title 4 beta, error: out of bounds, on ctrl d with some multi line selections Out of bounds error on ctrl+d with some multi line selections Jan 12, 2024
@YuriSizov
Copy link
Contributor

Still happens in 4.3 with the current master, by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants