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

Consider a sticky scroll provider API #168428

Open
jrieken opened this issue Dec 8, 2022 · 11 comments
Open

Consider a sticky scroll provider API #168428

jrieken opened this issue Dec 8, 2022 · 11 comments
Assignees
Labels
api editor-sticky-scroll feature-request Request for new features or functionality
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Dec 8, 2022

Today sticky scroll is mostly powered by the DocumentSymbolProvider API. Mostly because it falls back to folding information when not symbol provider is available. This approach is serving us well but there are cases which don't work nicely and we should consider is a "DocumentStickyScrollLinesProvider"-API, e.g one that's provides data only used for the sticky scroll feature

@michaelhays
Copy link

It would be great if this could include support for all levels of indentation, like for loops and if statements.

@PanzerFowst
Copy link

It would be great if this could include support for all levels of indentation, like for loops and if statements.

I have been working on multiple projects which vary language and realized that my project with Python has the sticky scroll in things like for/while loops and if statements while my project in C/C++ doesn't show the for/while loops, if/switch statements etc.

It'd be amazing to have the sticky scroll for everything. =)

@meganrogge meganrogge self-assigned this Apr 5, 2024
@aiday-mar
Copy link
Contributor

aiday-mar commented Apr 8, 2024

Hi, @PanzerFowst thank you for posting your concern. The lines that are stuck are determined by the the value of your setting editor.stickyScroll.defaultModel. If set to outlineModel, the sticky widget will use an outline provider if one is available through the extensions. The outline model could be provided in your case by the Python extension pack or the C++ extension pack if you have them installed. If no such provider exists, the widget will fall back onto the folding provider (which is also provided by the extensions generally), and if no folding provider is available, the sticky widget will fall back to the indentation model which always exists. In your case, I am not aware what extensions you have installed, but the difference you see is likely due to the fact that for Python files one method is used, and for C++ files the other one is used.

In your case if you want to have sticky scroll everywhere, you can maybe set the setting to indentationModel, in which case it will base the sticky widget off the indentation schema.

@detzt
Copy link

detzt commented Apr 8, 2024

Thank you for the suggestion! Setting it to foldingProviderModel works perfectly in so many places :)
It adds folding in all sensible places and even brings in #regions, which is very useful.

@detzt
Copy link

detzt commented Apr 8, 2024

Setting editor.stickyScroll.defaultModel actually already solves many of the referenced issues that have been closed as duplicates. Even though I have been watching for progress in this topic, the addition of editor.stickyScroll.defaultModel went completely under my radar. Therefore, I think it would help other people who are unaware of it to post a comment like:

Even though work in this area is not yet completed, this particular use case can already be achieved using "editor.stickyScroll.defaultModel": "foldingProviderModel".

I cannot comment on the issues closed as duplicates myself, because the conversations are locked.

@meganrogge meganrogge removed their assignment Apr 8, 2024
@PanzerFowst
Copy link

PanzerFowst commented Apr 8, 2024

Thank you so much for that, @aiday-mar! This is very helpful!

Is there a way to set editor.stickyScroll.defaultModel for specific languages? Or to modify it for specific languages?

So far, I mostly like setting editor.stickyScroll.defaultModel to foldingProfiderModel, but it doesn't show me my visibility (public:, protected:, private:, etc. in C++) but generally shows everything else I want it to.

And yes, I do have the Python and C++ extensions installed albeit enabled in separate workspaces.

@aiday-mar
Copy link
Contributor

Hi @PanzerFowst yes you can set any setting per language. You can do this as follows:

  1. Search for the command Configure Language Specific Settings ...
  2. Select your language of interest
  3. Find the setting of interest and modify it

@DavidIbarr
Copy link

I am also interested in this issue, this could be really helpful for Allman-style braces, which currently just sticks as a single brace at the top of the editor when browsing the function.

@sheiun-xu
Copy link

Allman-style braces current view.

image

Source: https://www.reddit.com/r/vscode/comments/1ctegci/sticky_scroll_settings_am_i_doing_something_wrong/

@Colengms
Copy link
Contributor

It seems we would need this to address some issues with how sticky scroll works with the C/C++ Extension. We are switching to foldingProviderModel mode (as outlineModel was the default and doesn't provide enough granularity). But due to how C++ functions can have 'header' text (i.e. template <typename etc> which can be multi-line, etc.), may have 'attributes', or args that span multiple lines, we would need better control over the range and sticky text in order to display something helpful (including the function's name) on that line, instead of something relatively unhelpful such as template <typename A, or just the last function argument.

If a sticky scroll provider API allowed both ranges and sticky line text to be provided, that would allow us replicate what was done in Visual Studio, where multiple relevant lines of 'header' text get collapsed into the same sticky line.

@VitGottwald
Copy link

VitGottwald commented Aug 21, 2024

Sticky scroll works well with our language server for COBOL in general. Except for one glitch - the top level node in an outline is a program node. However each program starts like this.

       IDENTIFICATION DIVISION.
       PROGRAM-ID <program-name>

and that means that in the sticky scroll for the program node, I aways see IDENTIFICATION DIVISION line which is not very helpful. I would much rather see the second line of the program with the program name.

Having a provider specifically for sticky scroll would allow us to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api editor-sticky-scroll feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

10 participants