godotengine / godotengine/godot

LineEdit: cannot extend selection that was set in script

Open
#115,706 2 comments 1 reaction 0 assignees View on GitHub
bug topic:gui
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.5.1-stable, 4.6-stable

### System information

Godot v4.6.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Sat, 24 Jan 2026 00:47:39 +0000 on Wayland - X11 display driver, Single-window, 1 monitor - OpenGL 3 (Compatibility) - Mesa Intel(R) Iris(R) Xe Graphics (ADL GT2) - 12th Gen Intel(R) Core(TM) i5-12500H (16 threads) - 15.33 GiB memory

### Issue description

In some cases, you would wish to set the selection in a LineEdit through script and allow the user to extend/shrink it later as they see fit. However, it seems that keyboard selection and script selection do not match up.

### Steps to reproduce

1. Set both the selection and caret position on a focused `LineEdit` with `LineEdit.select()` and `LineEdit.caret_column` respectively, making sure that caret aligns with either selection start or selection end.
2. Try to adjust the selection with `[Shift] + [Left Arrow]` or `[Shift] + [Right Arrow]`.

Expected behaviour: current selection is expanded/shrunk, depending on caret position and action.

Observed behaviour: new selection is created starting from column 0 to `caret_column`.

### Minimal reproduction project (MRP)

Test project: [line-edit-test.zip](https://github.com/user-attachments/files/24991406/line-edit-test.zip)

Open the scene: you would see a LineEdit with text '12345' with '5' selected and caret between '4' and '5'. Press `[Shift] + [Left Arrow]`. Instead of expanding the selection to be '45', it starts from the beginning of the string to be '123'.

Contributor guide

Open the contributing guide

Research direction

Run the linked minimal reproduction project and inspect the LineEdit.select(), caret_column, and Shift+Arrow selection behavior described in the report. The work is complete when a selection set by script can be expanded or shrunk from either aligned caret position without creating a selection from column 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, godot
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.