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

cmd/govim: don't open a split when renaming things #459

Open
cespare opened this issue Aug 19, 2019 · 6 comments
Open

cmd/govim: don't open a split when renaming things #459

cespare opened this issue Aug 19, 2019 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@cespare
Copy link
Contributor

cespare commented Aug 19, 2019

Right now govim hard-codes opening splits for renamed files.

In general I would prefer no splits. If the purpose of the splits is to convey a sense of what changed to the user, then perhaps a brief message ("changed X instances of 'foo' to 'bar' in Y files") in the status would be enough. (But I don't find this necessary either.)

If the splits are useful for some people, perhaps they should be behind an option.

@myitcv
Copy link
Member

myitcv commented Aug 20, 2019

Interesting. The thinking behind opening the splits was that, in a future version of govim, it should be possible to atomically (across all files involved in the rename) "undo" the rename. Would you want that feature?

We might be able to implement this feature without opening the files in the editor. However, this could present something of a source-of-truth problem, because we wouldn't necessarily be able to guarantee the undo, whereas if the files were all open in the editor we would.

@myitcv myitcv added bug Something isn't working needs investigation Needs someone familiar with govim to investigate in more detail labels Aug 20, 2019
@myitcv myitcv added this to the Next milestone Aug 20, 2019
@cespare
Copy link
Contributor Author

cespare commented Aug 20, 2019

[...] it should be possible to atomically (across all files involved in the rename) "undo" the rename. Would you want that feature?

That's a cool idea. I would like that feature, but if I had to choose, I'd prefer having no splits. Typically when I'm doing some renaming, I start with a clean repo and use git to roll back unwanted changes.

I'm also hopeful that gopls will support module-wide renaming soon (golang/go#32877). I use the GOPATH-wide renaming capability of gorename a fair amount for doing renames across our company's entire codebase (and I expect that we'll use a single module when we finally make that transition). For these cases, a rename might touch dozens of files.

We might be able to implement this feature without opening the files in the editor. However, this could present something of a source-of-truth problem, because we wouldn't necessarily be able to guarantee the undo, whereas if the files were all open in the editor we would.

Does opening the files mean opening splits? It wouldn't bother me if the rename opened a bunch of buffers in the background.

@myitcv
Copy link
Member

myitcv commented Aug 21, 2019

I'm also hopeful that gopls will support module-wide renaming soon (golang/go#32877)

Understood. So would your preference be, therefore, that these "other" files not get loaded in the editor at all?

Does opening the files mean opening splits?

No. There's actually a TODO to add a config option for this. One option is for the files to be opened as hidden buffers. But this would still require a :wa... which might be some counterintuitive if you can't see a whole load of files have been "changed" in the editor.

@cespare
Copy link
Contributor Author

cespare commented Aug 21, 2019

If I understand you, you're suggesting that there are probably two possibilities for a no-split solution:

  1. Modify and save the files without opening them in vim; this means we can't use a vim undo, but there aren't a bunch of new opened files either. (This is like GoRename in vim-go.)
  2. Open the files in hidden buffers; this requires :wqa but potentially allows an undo operation.

I think I'd be satisfied with either of these for now. (2) sounds cool and probably works for most of my use cases, but I'd worry that it would not work as well as (1) at some scale. It's probably not a good idea to open hundreds of buffers, say.

@myitcv
Copy link
Member

myitcv commented Aug 21, 2019

Yup, your understanding is 💯% correct.

Ok, will ponder this a bit. I'm erring back towards option 1 because of the scale point. That still leaves the door open for future improvements in this space.

@myitcv
Copy link
Member

myitcv commented Sep 4, 2019

@cespare - I've pondered and I haven't changed my thinking; I think we should go for option 1:

Modify and save the files without opening them in vim; this means we can't use a vim undo, but there aren't a bunch of new opened files either. (This is like GoRename in vim-go.)

Marking this as "to be done next". If anyone wants to have a go, be my guest :)

@myitcv myitcv removed the needs investigation Needs someone familiar with govim to investigate in more detail label Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants