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

is there an inverse of .save() #14

Open
kekscode opened this issue Sep 14, 2023 · 7 comments
Open

is there an inverse of .save() #14

kekscode opened this issue Sep 14, 2023 · 7 comments

Comments

@kekscode
Copy link

kekscode commented Sep 14, 2023

My workflow is creating a qf list (with telescope usually), then pressing <leader>r which triggers the .run method and (conveniently) opens the editable qf list (if it is not already opened).

Sometimes though, i figure that i want to exit the editable qf list (=replacer ft) without any changes by e.g. returning to normal mode and then just hitting e.g. q to return to the normal, unmodifiable qf list. Maybe a bit like the .cleanup method does, but without ending up with an empty qf list.

Is this possible or am i just using it wrong (as in "stupid workflow")?

@gabrielpoca
Copy link
Owner

I experience something similar sometimes: I do "Ctrl+o" and then find myself in an empty buffer. I don't know exactly what to do about it. I could change the plugin to create a new buffer instead of changing the qf buffer, but it will leave those qf buffers around. What's your use case? What are you looking to do?

@kekscode
Copy link
Author

I experience something similar sometimes: I do "Ctrl+o" and then find myself in an empty buffer. I don't know exactly what to do about it. I could change the plugin to create a new buffer instead of changing the qf buffer, but it will leave those qf buffers around. What's your use case? What are you looking to do?

My use case is dead simple: I activate the replacer, immediately change my mind and just want to get my quickfix window back (e.g., to do some more filtering first or removing lines from qf, before again switching to replacer mode and actually do something).

@gabrielpoca
Copy link
Owner

I've been thinking about this. I never edit qf windows, but some people might. The issue is that replacer.nvim destroys the qf window, and reverting those destructive changes will be messy. I thought that instead of destroying the qf, I could simply create a new buffer, and if you want your qf back, go back or delete the current buffer. What do you think?

I made a quick implementation if you can try it out: https://github.com/gabrielpoca/replacer.nvim/compare/gp-preserve-qf?expand=1

All of this would be configured, and I would add another configuration to delete the qf window when you're done with replacer.nvim

@kekscode
Copy link
Author

Sounds like a good solution. I‘ll check the PR and give you feedback as soon as possible.

@kekscode
Copy link
Author

kekscode commented Sep 23, 2023

I had a quick look and generally it works, but I litterally just switched to the branch, did a :Lazy sync and tried to activate/deactivate replacer and then re-visiting my (now still existing) quickfix list. So i'll have to do some more testing.

Good side-effect: Replacer works now without issues alongside bqf, too.

@kekscode
Copy link
Author

kekscode commented Sep 23, 2023

I tested a bit and i have a suggestion (maybe independent from this testing branch):

File 1.md:Text content
File 2.md:Text content
File 3.md:Text content

and then i activate replacer and edit the buffer to be:

File.md:Text content
File.md:Text content
File.md:Text content

I get first:

Error executing lua callback: ...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:115: File Fest.md already exists
stack traceback:
	[C]: in function 'error'
	...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:115: in function 'save'
	...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:204: in function <...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:204>

and it results in having 1 of the three files changed to File.md while the other 2 remain the same (obviously).

and when i try it again i get:

Error executing lua callback: Vim:E484: Can't open file <empty>
stack traceback:
	[C]: in function 'readfile'
	...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:53: in function 'save'
	...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:204: in function <...ocal/share/nvim/lazy/replacer.nvim/lua/replacer/init.lua:204>

Maybe this kind of errors can be catched by some nice error handling? I think it is totally okay to produce this error in e.g., a heavy refactoring but it's hard to know what's going on, because of the cognitive load of lua tracebacks.

@kekscode
Copy link
Author

I had a quick look and generally it works, but I litterally just switched to the branch, did a :Lazy sync and tried to activate/deactivate replacer and then re-visiting my (now still existing) quickfix list. So i'll have to do some more testing.

Good side-effect: Replacer works now without issues alongside bqf, too.

I did some more testing and for me it works just fine now :)

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

No branches or pull requests

2 participants