haskell / haskell/haskell-mode
Code folding swallows all empty lines at top level indentation
- Dominant language
- Emacs Lisp
- Stars
- 1.4k
- Forks
- 354
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
Description
Not quite sure this is a bug or a feature, but [`(haskell-hide-toggle)`](https://github.com/haskell/haskell-mode/blob/bbdbc0e9231f49a45ce787ebfb3f2b019615bf61/haskell-collapse.el#L26) from `haskell-collapse` calculates end of overlay region to the next same-level indented code, while ignoring all blank lines. I'd suggest blank lines have to be ignored _only in nested indentation_ levels, not the initial one. The way how code is now folded, with losing all intended spacing between logically unrelated code, makes it overall less readable.
For example:
```haskell
main = putStrLn $ greet ++ name -- cursor on this line
where
greet = "Hello "
name = "Alice"
topLevelFn = undefined
```
folds to
```haskell
main = putStrLn $ greet ++ name...
topLevelFn = undefined
```
instead of to this
```haskell
main = putStrLn $ greet ++ name...
topLevelFn = undefined
```
ie. with initial indentation level blank lines preserved.
Related code in `(haskell-find-line-with-indentation)`
https://github.com/haskell/haskell-mode/blob/bbdbc0e9231f49a45ce787ebfb3f2b019615bf61/haskell-collapse.el#L82-L84
where blank lines are skipped despite next indentation level found (or end of file).
Maybe some backtracking for last range of empty lines, by comparison of indentation levels between their preceding and the initial one ?
Contributor guide
Assessment
This issue has not been assessed yet.