microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.59k stars 29.03k forks source link

API to trigger a refresh of the OUTLINE (DocumentSymbols) #108722

Open angelozerr opened 4 years ago

angelozerr commented 4 years ago

I recreate the issue https://github.com/Microsoft/vscode/issues/71454 because it was closed.

My need is that I have a XML Language Server which supports settings for configuring symbols (like show/hide XML attributes, XML text nodes in the outline). When those settings are saved, I would like to refresh the outline.

If vscode could provide a command to refresh this outline, it should be great!

Thanks!

tsmaeder commented 4 years ago

Not sure if a "refresh" command for the view is the only way to implement it, but I can see the need.

kiuKisas commented 2 years ago

Up

qianguyizhe commented 2 years ago

1.67.1 still too slow for C/C++ outline documentSymbol event is sent to us upon file refresh and keystroke, but not on save. So our outline view is always one step behind when we change a binding or module. And C/C++ parsing is too slow, only show outline when parsing is end, always cost more zhan 10 seconds and reopen the file will continue cost a same long time ... I try to use ctags to provide outline ... https://github.com/rescript-lang/rescript-vscode/issues/176

gayanper commented 2 years ago

I can think of two ways to do this.

  1. Looking at the XML LS need and Java LS need we could listen for configuration changes and refresh the symbols. But we need a way to filter such change is applicable for current symbol provider's language services. otherwise we will endup doing unwanted refresh operations

  2. Provide the command to refresh without exposing that in the UI. So extensions can call this command when they want to refresh the outline programmatically.

Option two might be a better choice given that, extensions can decide when to refresh based on the context.

gayanper commented 2 years ago

I did an implementation on 2 option above. https://github.com/microsoft/vscode/pull/160027 @tsmaeder @jrieken Let me know what you think.

EhabY commented 1 year ago

@jrieken You mention in the PR that there is no need for a way to refresh the outline as it is done automatically when the document is touched. However, there are several cases where we might want to refresh even if the document is not changed:

  1. Builds that take a lot of time to finish, so the result of the outline is not ready yet when it is requested (thus having an empty outline)
  2. While the document could have not changed, another document that depends on it could have changed and caused the outline to be out of date (C/C++ included files)

Those are just two examples where we might need a way to refresh the outline without touching the document, I am sure there are a lot more use cases...

c-claeys commented 1 year ago

@jrieken We have need of a refresh like this for DocumentSymbols. Our use case is a sometimes-long running background calculation for each of those that we don't want to leave open with the extension request. Are you open to a PR for optional events similar to onDidChangeSemanticTokens, onDidChangeCodeLenses, onDidChangeInlineValues, onDidChangeInlayHints, and onDidChangeFoldingRanges?