Skip to content

Sticky scroll - keep containers headers visible when scrolling #26757

Closed
@gulshan

Description

@gulshan

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-
current

And with this feature, I wish it to look something like this-
requested

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-

freeze_header

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions