Skip to content

terminal/screen: preserve leading whitespaces in selectLine - #11503

Closed
jesusvazquez wants to merge 1 commit into
ghostty-org:mainfrom
jesusvazquez:jvp/fix-11463-preserve-leading-whitespaces
Closed

jesusvazquez wants to merge 1 commit into
ghostty-org:mainfrom
jesusvazquez:jvp/fix-11463-preserve-leading-whitespaces

Conversation

@jesusvazquez

@jesusvazquez jesusvazquez commented Mar 14, 2026 •

Copy link
Copy Markdown

Fixes #11463

selectLine was trimming leading whitespace on triple-click line selection, which strips indentation from the first selected line. I can see how this seemed right at the time but based on the discussion #11411 and how other terminals behave we're now adjusting this.

selectLine will now preserve the leading whitespaces.

We continue to drop the trailing whitespaces in the line.

Also added a regression unit test.
Also updated a few other unit tests that had leading whitespaces.

Before

image

Now

image

Relates to ghostty-org#11463

selectLine was trimming leading whitespace on triple-click line
selection, which strips indentation from the first selected line.

That behavior has now changed to preserve the leading whitespaces.

We continue to drop the trailing whitespaces in the line.

Also added a regression unit test.
Also updated a few other unit tests that had leading whitespaces.

Signed-off-by: Jesus Vazquez <jesusvzpg@gmail.com>
@mitchellh

Copy link
Copy Markdown
Contributor

This isn't right. We already have an option to modify whitespace matching. triple-click select should probably use that. If I'm wrong in that assessment please let me know.

@mitchellh mitchellh closed this Mar 15, 2026
@jesusvazquez

Copy link
Copy Markdown
Author

We already have an option to modify whitespace matching. triple-click select should probably use that. If I'm wrong in that assessment please let me know.

You are right 👍 I did not fully understand that bit before, my bad. Here is the new attempt at it #11535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Triple-click select line shouldn't trim whitespace before/after

2 participants