Skip to content

[WIP] View based refactoring in workspace v2 #13870

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

gerblesh
Copy link
Contributor

Rebased and modified from the original author: #4381
As is disclaimer this is heavily WIP and I'm fairly new to Rust so things aren't the cleanest

A couple changes:

  • It also now uses the global_search command rather than bespoke query logic
  • Keybind to put the results from the search into the refactor buffer is (ctrl-q). The keybind is mainly because of vim muscle memory so it's subject to change
  • The global_refactor command still exists as a way to "write out" the changes to the buffers, though I think it might be nice to eventually make it work on the :write command

This is also still using the enum in Document since using View (seems) to require much deeper knowledge of Helix's codebase and rewriting/reusing much of the document editing code.

This PR is mainly meant to document my changes but feedback/reviews are welcome, though I don't expect this to be merged, especially as-is. This might also be better suited as a plugin

@gerblesh gerblesh marked this pull request as draft June 30, 2025 19:27
@gerblesh

This comment was marked as outdated.

@gerblesh
Copy link
Contributor Author

gerblesh commented Jul 1, 2025

ok so I modified the gutter to display the custom path but I'm not sure how I feel about touching so many internals of Document and Gutter and putting down a bunch of match statements. It feels a little tacked on atm, though anything cleaner seems to be a lot more work that would require restructuring. Ideas and feedback are very much welcome on how to improve this implementation

@gerblesh
Copy link
Contributor Author

gerblesh commented Jul 1, 2025

helix_refactor.mp4

Here's a demo using now with the gutter being "properly" implemented

@daedroza
Copy link
Contributor

daedroza commented Jul 1, 2025

Hi, I was looking into this and it looks super cool and very similar to oil.nvim. However at the moment the global_refactor is not a typed command i.e what if I am inside a workspace and I would like to perform a refactor inside specific directory or a file? Something like ":refactor x/y/z".

@gerblesh
Copy link
Contributor Author

gerblesh commented Jul 1, 2025

Hi, I was looking into this and it looks super cool and very similar to oil.nvim. However at the moment the global_refactor is not a typed command i.e what if I am inside a workspace and I would like to perform a refactor inside specific directory or a file? Something like ":refactor x/y/z".

currently the way to specify a directory is to use the column matching in the global search picker so something like <regex> %p <filepath> and then ctrl+q, not perfect though, maybe there's a simple change to global search that allows searching just within a certain filepath as well. The global_refactor command does not open or search regex anymore, it simply writes out the changes of a refactor buffer

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.

3 participants