Closed
Description
Hi,
I started toying with the "Expand selection" (Alt + Shift + Right arrow by default on Linux) feature in VS Code and I noticed some quirks here and there. As usual, I am unsure if this is an HLS or Ghcide issue, sorry 😅
To reproduce:
{-# LANGUAGE DataKinds #-}
module Foo where
import Prelude
newtype Foo = Foo {
foo :: String
}
bar :: String -> Foo
bar "" = undefined
bar s = Foo {
foo = s -- start with your cursor on this line, somewhere on the foo field
}
baz :: Bool -> ()
baz _ = ()
When using "Expand selection" feature several times, here's what happens:
- Selects
foo
- Selects
foo = s -- start with your cursor on this line, somewhere on the foo field
- Selects
foo = s -- start with your cursor on this line, somewhere on the foo field
(the left spaces are now included, but Github doesn't display them...) - Selects everything between the brackets excluded (including new lines)
- Selects everything between the brackets included
- 💥 Selects the pattern case of
bar
(i.e. does not include the empty string case) - 💥 Selects the whole file
IMHO 6 is weird, there should be additional steps:
- Between 5 and 6: Select the whole
Foo {}
expression - TBD: Between 6 and 7: Select the whole implementation but not the signature (I am much less opinionated on this one)
- Between 6 and 7: Select the whole implementation, including the signature
- Between 6 and 7: Select all declarations (types, functions, etc.) but not imports
- Between 6 and 7: Select all declarations (types, functions, etc.) and imports, but not module declaration