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: don't save/edit unchanged files #41

Open
calonx opened this issue Apr 18, 2022 · 3 comments
Open

Feature request: don't save/edit unchanged files #41

calonx opened this issue Apr 18, 2022 · 3 comments

Comments

@calonx
Copy link

calonx commented Apr 18, 2022

On Friday I accidentally hit Save on an unmodified document (not even open for edit) and wound up triggering a local rebuild of a decently sized codebase. Any chance we could have the extension bail on saving/editing if there are no pending changes? Or at least an option for enabling this behavior?

Thanks for your effort in offering up this extension! Pre-VS2022, I've just hobbled along with my own homebrew VS extension. That's no longer necessary now that I've got this one. 😁

@belkiss
Copy link
Owner

belkiss commented Apr 19, 2022

Heya! Thanks for the kind words :)

The save part is handled by Visual Studio, we only hook ourselves to the OnBeforeSave event and do a p4 edit beforehand (if you use auto-checkout on save, which is default in this niftyperforce fork).

Afaik, if you trigger a manual save on a specific file (by ctrl+s for instance), then it'll always do the save.
We could theoretically skip the p4 edit part, but the write attempt will still occur, and succeed if the file is read-write. And in case the file is still checked in and read-only, you'll get a file write error popup, which isn't great...

Note that the "Save all" should already do what you want, only save dirty files.

@calonx
Copy link
Author

calonx commented Apr 19, 2022

Aha! I suppose my homebrew extension was set up as a wholesale replacement for Edit.Save, meant to be bound directly to Ctrl+S. As such, it was the thing calling dte.ActiveDocument.Save() under the right conditions. Side-note: when switching to VS2022, I attempted to port my extension but got stuck in the weeds and abandoned the effort.

I'd be happy to share my approach, but it seems at odds with how this extension is set up. Maybe I'll clone your repo and try my hand at injecting such a feature...

@belkiss
Copy link
Owner

belkiss commented Apr 19, 2022

Ah ok. I guess if we made it a real VCS plugin in Visual Studio, it'd be possible to completely cancel the edit, but I'm not sure it'd be a good move, as Visual tend to do a lot of queries to the VCS plugin, and that would probably slow down the IDE.

Out of curiosity, what roadblock did you meet when porting your own extension to vs2022?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants