-
Notifications
You must be signed in to change notification settings - Fork 29k
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
Explicitly refresh active text editor from extension api. #7532
Comments
@bmingles Would |
There is an option for opening editors to /cc @jrieken |
@bpasero Isn't this a case for file events? |
@jrieken yeah though all the bugs I have on file events show me that they do not work in all cases ;-) |
Actually in this case what could bite is the fact that I ignore file change events on the currently edited file for a short period because otherwise I would reload the file every time you made a modification. @bmingles is this a possible explanation that the text content is rapidly changed after the user saved? what is the use case for the extension? |
@bpasero I have an extension that can run arbitrary shell commands whenever a user saves a file (using vscode.workspace.onDidSaveTextDocument). I have some users of the extension that are running commands that modify the source file after save and are asking if it could update the active file after the commands run. The goal would be to explicitly refresh it in the extension after commands run and not based on change detection on the source file. |
My current version of VS code is 1.11.1 and got the same issue. I noticed that the VS code editor do not refresh when an external program update a file (copy, save, etc). If the opened file is currently focused in the editor and change externally, it does not refresh. The workaround to refresh the opened and focused file in VS code is to select another opened file and get back to the edited/updated opened file. Steps to reproduce:
Expected result: The change is visible in VS Code. I found this while trying to debug a file under the node_module that is copied from another server package during the build process. Please, give us a solution to automatically refresh opened and focused file in VS Code editor when an external program change it. |
@slemireOmni To clarify, it sounds like you are asking for a different feature, one that responds to a file system change or something external to vscode. The feature I am requesting here is for extension developers to be able to explicitly trigger a refresh via a vscode extension through an api of some sort. |
Is it still open? Any solution to that? It is really annoying I can't use any formatting tools as vscode get out of sync with the formatted files. |
@bpasero Has there been anything added to the extension api that would facilitate this, |
There is no official API yet (hence this issue is still open). The only workaround to force refresh the active file from disk is to call our internal command |
Ok, that may be a good workaround for some synchronous use cases. Now that I think about it, I guess that would be a challenge of any sort of refresh from disk scenario if it is possible for the user to make changes before it runs. |
There doesn't appear to be any way to explicitly refresh the active text editor. This would be useful for extensions that modify files via external commands and need to show the latest version once said command completes.
The text was updated successfully, but these errors were encountered: