Skip to content

Implement selection range request lsp feature #212

Closed
@sir4ur0n

Description

@sir4ur0n

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:

  1. Selects foo
  2. Selects foo = s -- start with your cursor on this line, somewhere on the foo field
  3. 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...)
  4. Selects everything between the brackets excluded (including new lines)
  5. Selects everything between the brackets included
  6. 💥 Selects the pattern case of bar (i.e. does not include the empty string case)
  7. 💥 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions