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

Brace minimisation #548

Open
zesterer opened this issue Feb 9, 2020 · 4 comments
Open

Brace minimisation #548

zesterer opened this issue Feb 9, 2020 · 4 comments

Comments

@zesterer
Copy link

zesterer commented Feb 9, 2020

Since Howl is a multi-language editor, it's obvious that properly parsing all languages to figure out where functions begin or end is... difficult. Instead, I offer an alternative suggestion: A way to minimise content enclosed within a given set of braces/brackets/parentheses. As an example,

304 | 
305 | fn foo(a: i32, b: i32) -> i32 {
306 |     // Some useless code
307 |     let c = 5;
308 |     let d = c + a
309 |     a + d
310 | }
311 | 

Would minimise to

304 | 
305 | fn foo(a: i32, b: i32) -> i32 { ... }
311 | 

The character to perform the minimisation upon could be tweaked on a per-language basis.

I've not fully thought through how this might work with nesting, but I thought that starting a discussion about this would be the best thing to do.

@shalabhc
Copy link
Contributor

I like this idea. It also allows collapsing arbitrary lists, dicts and other structures that use braces. We already have cursor-goto-brace which has logic to find the matching brace. What's missing is some support for hiding lines. One corner case is something with trailing text:

a {
  b
  c
} d

Now what happens to d when this is collapsed?

@zesterer
Copy link
Author

I presume the result would just be a { .. } d?

@DriNeo
Copy link
Contributor

DriNeo commented Feb 3, 2021

Why not collapse every lines that has the same or lower indentation level, except the ones with 0 indentation ? That should work everywhere without configuration tweak.

@zesterer
Copy link
Author

zesterer commented Feb 3, 2021

Why not collapse every lines that has the same or lower indentation level, except the ones with 0 indentation ? That should work everywhere without configuration tweak.

I think this is a reasonable approach, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants