In vscode, the new Sticky scroll doesn't seem to work out of the box with my custom language extension. Is there some interface my language needs to implement in order to support it?
2 Answers
The new Sticky Scroll feature seems to be based on the language elements (class
/interface
/namespace
/function
/method
/constructor
) being recognized, and available in the Outline
view. This means your custom language must have a Language Server or any other tooling that provides such elements to the editor.
If your language does provide that, but is not being properly supported in the new Sticky Scroll feature, I suggest you to open an issue in VS Code repo. As you can see (https://github.com/microsoft/vscode/labels/editor-sticky-scroll), there are a few issues reported.
Hope this helps

- 2,478
- 11
- 16
-
I haven't implemented a proper language server yet. However, I have created and registered a DocumentSymbolProvider. I thought that the 'method' or 'function' symbols returned from that would trigger the sticky scroll to work. However, that doesn't seem to be the case. If no one knows offhand, perhaps I just need to debug vscode in order to figure out what else I'm missing. – MaddawgX9 Aug 22 '22 at 18:23
-
The issue was that SymbolKind isn't well-documented in the API documentation and I didn't realize the enums were capitalized and not all lowercase. Now I'm mostly just sad that conditionals aren't considered relevant Symbols so there is no Kind to capture them. – MaddawgX9 Aug 23 '22 at 00:06
That could change with VSCode 1.72 and issue 157165 "Add option to base Sticky Scroll on indent, not Document Symbols"
Basing Sticky Scroll on class/function/namespace etc. makes a lot of sense, but only as long as there is an active language server or language extension that provides good Document Symbols (Outline).
For all languages that either have no LSP (so, so many), whose LSP provides no Outline, whose LSP provide invalid Outline or which simply have no concept of functions/classes etc., Sticky Scroll can not be leveraged :-(
I'd argue that in many cases the respective context could be inferred from the indentation instead.
I realize this may not be desirable by default, so perhaps it should be either hidden behind a flag or configurable per language. For example, in a large JSON file, you might then get this context:
1 { 51 "a": { 52 "b": [ ----------------------------------------------- 74 "current_line", 75 "..."
Personally, I'd like to have SS in CoffeeScript, Crystal, AutoHotkey, Markdown, JSON, and pretty much everywhere else except maybe plain text files.
This implemented with PR 159198;
When no document symbol provider use the folding model for the sticky scroll:
This is available in VSCode insiders today.

- 1,262,500
- 529
- 4,410
- 5,250
-
This is exactly what I was hoping for. And you are correct, it's language dependant and should be on a flag set by the language extension or even a user language setting. – MaddawgX9 Sep 04 '22 at 17:07
-
@MaddawgX9 Yes, but that setting can then be applied to languages which do not support [LSP](https://microsoft.github.io/language-server-protocol/), as opposed to the first "sticky scroll" implementation, which depends on LSP for getting the function name. – VonC Sep 04 '22 at 17:10