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

Indent guides should not extend beyond the last line #8487

Open
aspizu opened this issue Oct 8, 2023 · 8 comments
Open

Indent guides should not extend beyond the last line #8487

aspizu opened this issue Oct 8, 2023 · 8 comments
Labels
A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@aspizu
Copy link

aspizu commented Oct 8, 2023

Indent guides should stop at the last non-empty line inside an indented block in languages which use indentation for structure.

left: what helix does currently.
right: what helix should do.
Issue demonstrated in image.

@aspizu
Copy link
Author

aspizu commented Oct 9, 2023

So, helix should add a option which will toggle this behavior and depending on the file-type enable this behavior. Languages such as Python would enable this. It could be enabled for any file optionally.

How difficult would be to implement this?

@kirawi
Copy link
Member

kirawi commented Oct 10, 2023

pub fn render_text<'t>(

It would be better to tackle this issue directly instead if it's possible within the current rendering system. What you're talking about is #8054

I think the cause of this behavior is that we currently depend on whitespace at the beginning of the line to determine whether to draw an indent guide. One way I think this could be done is to add additional scopes to indent.scm such that we can declare we should only draw indent guidelines within certain nodes.

@kirawi kirawi added A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Oct 10, 2023
@aspizu
Copy link
Author

aspizu commented Oct 10, 2023

Could tree-sitter be used for determining where to draw them?

@pascalkuthe
Copy link
Member

I don't think we should start using TS for indent guides.

I think the specific of how we render them is simply not ideal.

We continue the indentation of the previous line across emply and whitespace only line.

Instead we should:

  • use the trailing indentation for empty lines (fixing this issue)
  • compute the indentation for whitespacelines as normal. This makes sure that o at the end of a function still shows the correct indent guides

This is how other editors/vim plugins handle this. That approach would also allow us to do some lookahead to avoid indent guides disappearing at the first/last lines as they currently do.

@aspizu
Copy link
Author

aspizu commented Oct 10, 2023

Code formatters remove trailing indentation which would introduce another issue.

Using TS for indent guides would also allow us to fix this mess.

@pascalkuthe
Copy link
Member

yes that is exactly the intention. Helix also removes trailing indentation when leaving insert mode (if the line is empty on the cursor line). This ensures that the indent guides both behave correctly and use the trailing indentation (the indentatino of the next non-emtpy line) while also making sure that lines which are manually indented but don't contain text yet (lime after hitting o) have the correct indentation.

I don't think the case you show should be fixed. Indentguides are not meant to show somekind of "language level scope& or similar. They are supped to show how many times you need to press tab to reach te same indentatino. They are purely textual and I don't think that should change.

@kirawi
Copy link
Member

kirawi commented Oct 10, 2023

use the trailing indentation for empty lines (fixing this issue)

What does "trailing indentation" mean in this context?

@pascalkuthe
Copy link
Member

The indentation of the first non-empty line after an empty lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

3 participants