Skip to content

Textarea optimizations #5925

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

Merged
merged 13 commits into from
Jul 6, 2025
Merged

Textarea optimizations #5925

merged 13 commits into from
Jul 6, 2025

Conversation

willmcgugan
Copy link
Member

@willmcgugan willmcgugan commented Jul 5, 2025

A few optimizations to TextArea.

Started out as a modest optimization to avoid calculating cell lengths. But turned in to implementing a line cache, which results in a very good win, but potential for breakage. I'd appreciate an extra set of eyes on this.

@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Widget.release_mouse will now only release the mouse, if it was captured by self https://github.com/Textualize/textual/pull/5900
- Some optimizations to TextArea, which may be noticeable during scrolling (note: may break snapshots with a TextArea) https://github.com/Textualize/textual/pull/5925
- Selecting in the TextArea now hides the cursor until you release the mouse https://github.com/Textualize/textual/pull/5925
- Read only TextAreas will no longer display a cursor https://github.com/Textualize/textual/pull/5925
Copy link
Contributor

@TomJGooding TomJGooding Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still navigate and select the text in read-only mode, so don't we need the cursor?

@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Widget.release_mouse will now only release the mouse, if it was captured by self https://github.com/Textualize/textual/pull/5900
- Some optimizations to TextArea, which may be noticeable during scrolling (note: may break snapshots with a TextArea) https://github.com/Textualize/textual/pull/5925
- Selecting in the TextArea now hides the cursor until you release the mouse https://github.com/Textualize/textual/pull/5925
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also still want the cursor here, as it helps show what exactly is being selected?

For example, try selecting a line with the mouse, starting at the end of the line. If you select only until the start of that line and hit backspace, that leaves a blank line. Whereas if you select until the end of the previous line, the line is removed entirely.

When you're quickly trying to edit, after selecting the text you're probably almost immediately going to hit the next key, which is why I think the cursor context while selecting is important.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow. The cursor is always directly under the mouse, which is why it feels redundant. As soon as you release the mouse the cursor reappears.

Screen.Recording.2025-07-06.at.08.15.17.mov

I'm going to merge this shortly. But if I've missed something, I'm happy to revisit it.

@willmcgugan willmcgugan merged commit c2b964f into main Jul 6, 2025
23 checks passed
@willmcgugan willmcgugan deleted the textarea-optimizations branch July 6, 2025 07:17
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.

2 participants