-
Notifications
You must be signed in to change notification settings - Fork 39
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
on_text_changed() is not working well with "revert" (F5) command #3323
Comments
This will also trigger when stashing and popping changes from SublimeMerge, for example. ST then refreshes the view and that messes up the state in language servers, causing them to report issues that don't exist or even changing the code in wrong ways when formatting-on-save is enabled. |
The lowest common denominator seems to be file system events not passing through |
For the purposes of LSP I think it would be enough if we would get an extra change with all content re-added (assuming that that would be easier to do than actually providing a real diff of changes). |
Would it be better to have a separate notification for reverts? From my reading of the lsp specification it seems like the best action would be to send a |
I believe that would be fine too. I'm not sure that specific case fits more of a modification or close/open case as from user's perspective the file is modified rather than closed and reopened but in any case, I think it would be OK to handle it that way. (By "reverts" I hope you mean the generic case of when the file is touched externally and not just the revert command.) |
Except for callbacks both those cases have identical code paths :) |
I don't think it really matters if what the user sees matches up directly with what events get fired for a plugin. The way reload works internally is very similar to a close/reopen: We clear the whole buffer, then load it again off disk. |
But a You could opt for invoking I would still prefer to see the changes through Note that there's also another open issue that asks for callbacks for all filesystem events that ST tracks: #2669 so avoid duplicating information through callbacks (i.e. if a file is already open, FS events seep through on_text_changed, and no FS event is fired from the linked feature request) |
Invoking existing |
But shouldn't they react on If it were to behave like this, all view-specific settings should also be removed, FWIW. |
It definitely won't trigger on_close/on_load. My idea was to add something like |
We’ve already added |
@wbond In that case I think the best solution would be to just remove the |
There's still a small bug left where ST fires a text change event with all zeroes. See: sublimehq/sublime_text#3323
There's still a small bug left where ST fires a text change event with all zeroes. See: #1015 See: sublimehq/sublime_text#3323
If you're going the route of depending on on_revert and on_reload, it's probably best to also not send the first text change where it says to remove the whole buffer. I'm not convinced it would cause a 6GB allocation for a 2GB file. In practice reverting or reloading files changes a few lines in the buffer. So, calculating that diff in ST core would result in 4GB + text diff sent over IPC. |
There's still a small bug left where ST fires a text change event with all zeroes. See: #1015 See: sublimehq/sublime_text#3323
|
Sorry seems not. |
Yea, this one didn't make it in for 4075. |
Build 4080 has completely reworked how |
My hope is to have the docs for this and other 4081 changes done early next week. |
Description
When a
revert
(F5
) command is triggered,on_text_changed()
thinks all text is deleted.Steps to reproduce
revert
(F5
)Expected behavior
The
0 0 0 0 0 0
part should add the whole file back. Or something equivalent to delete all buffer content and add all disk content back during the wholerevert
process.Actual behavior
No text is added back.
Environment
Related Issue
The text was updated successfully, but these errors were encountered: