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

fix(cmdline): preserve range prefix when applying text edits #1155

Closed
wants to merge 2 commits into from

Conversation

solidtesting
Copy link
Contributor

Fixes #1092 by doing the following:

  • Matches regex for prefix
  • Preserves prefix by shifting text_edit.range

if mode == 'cmdline' then
local line = context.get_line()
-- Detect range markers '<,'>' or numeric ranges '3,5'
local prefix = line:match("^%s*['<,>%d]+%s*")
Copy link

@yoursvivek yoursvivek Feb 5, 2025

Choose a reason for hiding this comment

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

following is more precise

Suggested change
local prefix = line:match("^%s*['<,>%d]+%s*")
local prefix = line:match("^%s*'<%s*,%s*'>%s*") or line:match("^%s*%d%s*,%s*%d%s*")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tthanks, I moved the regex matching elsewhere as suggested by @Saghen.

@Saghen
Copy link
Owner

Saghen commented Feb 5, 2025

Thanks for the PR! This logic should be implemented in the cmdline source directly, rather than in the text edits library

@solidtesting
Copy link
Contributor Author

Thanks for the PR! This logic should be implemented in the cmdline source directly, rather than in the text edits library

I moved it accordingly, hope this is satisfactory.

@Saghen Saghen closed this in f0aeac2 Feb 8, 2025
@Saghen
Copy link
Owner

Saghen commented Feb 8, 2025

Thank you! I've rebased and merged on main since Github wasn't letting me push to this branch for some reason

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.

Selecting prev/next in cmdline removes line range markers (<,>)
3 participants