apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.69k stars 853 forks source link

Stick first line of focused code block to top, for better orientation #7984

Open asafm7 opened 6 days ago

asafm7 commented 6 days ago

Description

When the cursor is in a code block, stick the first line of the block to the top when scrolling beyond it for easier orientation. If possible, do the same for nested blocks.

I've seen it in other IDEs. I thought I had also seen it in NetBeans, but I couldn't find anything like it in the settings.

image

Use case/motivation

I'm looking for an easier understanding of the context within long code blocks.

Related issues

No response

Are you willing to submit a pull request?

No

Chris2011 commented 6 days ago

It is not quite the same in NetBeans, but sometimes, I think when you set the cursor to the last closing bracket. It is not the same, I know but to say we have a similar feature and we can improve this. I really like the idea of it and yes it is very handy. Like it in VS Code.

mbien commented 5 days ago

i think this is essentially covered by the classic "breadcrumbs" bar. Maybe an option to move it to the top of the editor would make it easier to use on larger screens.

Chris2011 commented 5 days ago

image This is more what was looking for, the breadcrumbs are different from this. It shows the whole path from the beginning to the end,

mbien commented 5 days ago

yes I do understand the suggestion. It is semantically equivalent of the breadcrumbs bar, just with reduced functionality.

The main difference is that the breadcrumbs bar is listening to the cursor position. This would render the first line of the clipped block which doesn't fit in the viewport. However, realistically this likely would have to be implemented using a delayed action just like the breadcrumbs bar. So I don't see why it couldn't be used right away for this.

asafm7 commented 4 days ago

Thanks, @mbien, @Chris2011.

I wasn't aware of the breadcrumb. It is close to what I was looking for, but not quite. Its location isn't optimal. For example, the search bar might buffer between the breadcrumb and the document:

image

Having the option to move it to the top might bring it closer to what I had in mind.

Also, with native CSS nesting, the breadcrumb only shows the top level: image

Is it by design or should I consider it a bug?

Chris2011 commented 4 days ago

@asafm7 it is just not implemented. When it was implemented, there where no nesting in CSS. You can try scss also whether this is working or not. But it will be a new feautre request, instead of a bug.

asafm7 commented 4 days ago

Thanks, @Chris2011.

What about the option to change the position of the breadcrumb?

Chris2011 commented 4 days ago

Sure, but as I said this not fixes the FR request for me either. We have the calculation of when a block goes out of the viewport we just need to stick this to the top. Adding option to move Breadcrumb around is a different FR.

asafm7 commented 4 days ago

@Chris2011 I agree.

It will be great to have it as a standalone feature. It will be more clear, useful and intuitive.

As you mentioned, when standing on a closing bracket of a top-level block it already happens (the line of the opening bracket sticks to the top) - so the feature is already there, just needs some tweaking.

A couple of notes though:

For example, if CSS is formatted this way:

p 
{
  color: red;
  text-align: center;
}

The line that sticks to the top is:

{