Repository navigation
Closed
Labels
editor-sticky-scrollfeature-requestRequest for new features or functionalityverification-neededVerification of issue is requestedverifiedVerification succeeded
Milestone
Description
This is a feature request. Starting with an example. Suppose we have following c# file-
using System;
namespace ExampleNamespace
{
class ExampleClass
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
static void ExampleMethod1()
{
Console.WriteLine("ExampleMethod1");
}
static void ExampleMethod2()
{
var methodName = "ExampleMethod2";
foreach(var c in methodName)
{
if(char.IsUpper(c))
{
Console.WriteLine("Upper case");
}
else
{
Console.WriteLine("Lower case");
}
}
}
}
}If we are browsing the file at the end, it looks like this now-
And with this feature, I wish it to look something like this-
It means the parent syntax nodes of the area being browsed is automatically freezed, so that the user can easily guess the context of the current code, regardless of how far the parent nodes are. Some points being-
- I think this should be a toggle keystroke to on/off feature, may or may not backed by a setting.
- The parent syntax nodes should smoothly stack up or goes out of stack while scrolling.
- This should be tied with the current viewport and not current cursor position in my opinion.
- It would be nice to have previous sibling nodes included in the stack for if-else chains and switch cases.
- By default, this can be solely based on indentation instead of actual syntax tree of the language, just like how folding currently works in vscode.
- There should be a minimum height of the viewport with actual code (without parent nodes). Or maximum height of parent node (header) lines. When that value will be reached (like for heavily nested code), furthest or top most parent nodes can be hidden in that order. The closes parent nodes will remain visible.
Edit:
Found a nice illustration for this feature from this tweet-
Reacted by Alexandru Dima, Zoltan Peto, Fred Vatin, Yemi Bedu @ P&R, Keith Hill, Eyal, Rory O’Kane, Tom Short, Valon Kastrati, mphelt and 177 more
Reacted by Philip Waritschlager, Daniel Bertalan, Giuseppe Cianci, gardenofwine, Stephen Gunn, Piotr Krupa, Francisco Lourenço, Martyn Davis, Alvise Sembenico, Dominic Maas and 28 more
Reacted by Bo Lingen, Qandil abdel fadil awayn, Nicolai Weitkemper and Kacper Kapuściak
Reacted by Qandil abdel fadil awayn
Metadata
Metadata
Labels
editor-sticky-scrollfeature-requestRequest for new features or functionalityverification-neededVerification of issue is requestedverifiedVerification succeeded

Activity
aeschli commentedon May 17, 2017
Interesting idea! Erich Gamma (@egamma) alexandrudima FYI.
[-]Option for freezing parent syntax nodes while browsing code[/-][+]Automatic Smart code folding (Freeze parent syntax node headers)[/+]PEZO19 commentedon Jun 2, 2017
I really like the idea, I have something very similar. I believe code folding could be use many ways to make code easier to absorb.
I wonder is there any other editor which has similar code folding strategy?
gulshan commentedon Jun 5, 2017
I don't know any other editor with this kind of code folding feature.
pr-yemibedu commentedon Aug 1, 2017
Hello,
This Peeking fold is nice. Some settings could be:
So what I would like to see is more (+) in the left border to indicate a way to collapse or expand. Also this can be a lot easier to get in vscode if there are not a lot of limits. The OP made six points ATTOW and so:
This is one of those so simple looking additions to the editor that it would be a crime to leave out. Thank you. Good day.
gulshan commentedon Nov 2, 2017
I thought user may not want to keep this settings on always. It will help more in code exploring situations. But may be someone will want to keep it on permanently. Then I have no objection to a permanent settings.
Regarding branching nodes like if, else-if, else, cases for switch or others, it's true that freezing previous sibling node headers violates indent based folding expectations and the feature will then require language awareness of some sort. So the first or baseline implementation can leave it. But I think it's still a nice to have enhancement and language servers should be able to contribute to this part.
gulshan commentedon Jan 10, 2018
One thing! When this feature is turned on, the usual code-folding has to be turned off. So enabling this can be part of
editor.foldingsettings.gulshan commentedon Jun 16, 2019
This tweet has a nice illustration for this feature-
https://twitter.com/jckarter/status/1140131108564062213
wayou commentedon Jun 17, 2019
Since the frozen part will take vertical space, it's better to limit the rows and collapse the middle rows with an explicit expand button.
Something like this:
jrieken commentedon Jun 19, 2019
We could try that for breadcrumbs. I have created #75776 to make breadcrumbs being driven by the viewport, not the selection
33 remaining items
BenBE commentedon Aug 7, 2022
I'm properly seeing the semantic scroll work in C (haven't checked C++ yet), but with the headings only generated for the actual function I'm in, but not control structures within the function. Is this intentional? Or could there at least be a setting to enable this? With just the top-level header of the function this doesn't bring any advantages over the existing line above it:
I'd prefer if the
while (!quit)from line 224, theif (ch == KEY_MOUSE && this->settings->enableMouse) {from line 239, theif (ok == OK) {from line 243 andif (mevent.bstate & BUTTON1_RELEASED) {from line 244 were all kept in view.Also I noticed a minor strangeness in that trying to scroll up, the cursor seems to move into a line hidden by the sticky-scroll display.
Overall I like the feature and am looking forward to see these minor issues resolved in an upcoming version.
NB: Screenshot done against htop-dev/htop@3e1908b in case someone needs the exact source to reproduce. Feel free to ask for further details as needed.
The-Compiler commentedon Aug 11, 2022
gjsjohnmurray commentedon Aug 11, 2022
Freya Bruhin (@The-Compiler) please see #157185 (comment)
The-Compiler commentedon Aug 11, 2022
Whoops, I missed that - thanks for the pointer and sorry for the noise! 👍
aiday-mar commentedon Aug 12, 2022
Thank you for all your comments and interest. If you are interested to see the latest new behavior of sticky scroll you may install the VSCode Insiders release for testing (https://code.visualstudio.com/insiders/). Some of the recurring issues have been solved there. These changes will appear in next month's stable release.
[-]Semantic scroll - keep containers headers visible when scrolling[/-][+]Sticky scroll - keep containers headers visible when scrolling[/+]aiday-mar commentedon Aug 22, 2022
To verify:
Open a file, scroll in it
Verify that the correct sticky headers are stuck to the top
Use simple click to jump to the line
Use control click to jump to the definitions of the variable