Skip to content

Conversation

@matthias314
Copy link
Contributor

When doing replaceall, selections are preserved. Currently they are left untouched even if the boundaries have shifted as a result of the replacement. This PR adjusts the beginning or end of a selection according to the number of characters added or deleted in the last line of the selection.

@matthias314 matthias314 marked this pull request as draft January 21, 2025 17:37
@matthias314 matthias314 marked this pull request as ready for review January 21, 2025 17:44
@matthias314 matthias314 marked this pull request as draft January 29, 2025 21:48
@matthias314
Copy link
Contributor Author

I made this a draft some time ago because I've been wondering if this is the right approach. Cursor positions and selections are automatically adjusted when inserting or deleting text. This is done in DoTextEvent. I think the right thing to do would be to treat replacements there, too. This way we would cover also replacements initiated by Lua scripts, not just those from ReplaceCmd. This is tricky to achieve at present because lines with matches are replaced entirely. With #3658 it will be much easier because the corresponding TextEvent will list every single replacement. What do you think about waiting and seeing if we can get a better solution with #3658?

@dmaluka
Copy link
Collaborator

dmaluka commented Mar 9, 2025

Yeah, makes sense.

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