Skip to content

Code folding swallows all empty lines at top level indentation #1707

Open
@dunrix

Description

@dunrix

Not quite sure this is a bug or a feature, but (haskell-hide-toggle) 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:

main = putStrLn $ greet ++ name   -- cursor on this line
  where
    greet = "Hello "

    name = "Alice"


topLevelFn = undefined

folds to

main = putStrLn $ greet ++ name...
topLevelFn = undefined

instead of to this

main = putStrLn $ greet ++ name...


topLevelFn = undefined

ie. with initial indentation level blank lines preserved.

Related code in (haskell-find-line-with-indentation)

(while (and (zerop (forward-line direction))
(or (haskell-blank-line-p)
(funcall comparison (current-indentation) start-indent))))

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions