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

feature request: Exclude filename from editor changes #28

Closed
1 task done
mike-ap opened this issue Sep 23, 2024 · 2 comments · Fixed by #32
Closed
1 task done

feature request: Exclude filename from editor changes #28

mike-ap opened this issue Sep 23, 2024 · 2 comments · Fixed by #32
Labels
enhancement New feature or request P1 May get worked on if I get free time. PRs welcome

Comments

@mike-ap
Copy link

mike-ap commented Sep 23, 2024

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

First, thanks for another great plugin!

When a list includes both filename and test matches for a substitution command, both values are modified. Modifying a filename produces an error "does not support adding or reordering quickfix items".

list:
app/controllers/foo_bar.rb ┃ 54┃@foo_bar = "baz"

substituter:
%s/foo_bar/foo_baz

Provide background

I am trying to substitute matching terms, excluding filename matches. I can do this by modifying my search (e.g. "foo_bar$"), but I wonder if ignoring filenames in the editor makes sense as a default behavior.

What is the significance of this feature?

nice to have

Additional details

No response

@mike-ap mike-ap added the enhancement New feature or request label Sep 23, 2024
@stevearc
Copy link
Owner

I wish I could, but we need the filenames. When you save changes in the quickfix, I parse the buffer and for each line I try to match it to one of the quickfix entries. This is done by trying to match the filename + lnum.

-- Search for filename and lnum match
for i = start, #items do
local item = items[i]
local lnum = item.lnum
if not lnum or lnum == 0 then
lnum = util.get_user_data(item).lnum
end
if filename_match(item, needle.filename) and lnum == needle.lnum then
return i
end
end

The only thing I could think of that might work would be to change how the buffer is rendered and make the filename + lnum virtual text instead of real text. Would require rewriting a good bit of this plugin though, and I'm not 100% sure it would work perfectly with the editor.

@stevearc stevearc added the P1 May get worked on if I get free time. PRs welcome label Oct 16, 2024
@stevearc
Copy link
Owner

@mike-ap I did the refactor I was talking about in #32. It actually worked better than I expected! I'm going to daily drive this for a while and then merge it in once I think it's stable enough. If you get a chance please try it out and let me know if you encounter any bugs or usability issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1 May get worked on if I get free time. PRs welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants