Skip to content

expand selection feature not respecting server textDocument/selectionRange response #1007

Closed

Description

@ericdallo

I implemented in clojure-lsp the textDocument/selectionRange and it's working great in other editors, but in IntelliJ it's merging the default IntelliJ selection with the one clojure-lsp responded.

(ns clojure-lsp.foo
  (:require
   [clojure.string :as string]))



(string/split-lines "123")

example:

[Trace - 11:56:28 AM] Sending request 'textDocument/selectionRange - (39891)'.
Params: {
  "textDocument": {
    "uri": "file:///home/greg/dev/clojure-lsp/cli/src/clojure_lsp/foo.clj"
  },
  "positions": [
    {
      "line": 6,
      "character": 11
    }
  ]
}


[Trace - 11:56:28 AM] Received response 'textDocument/selectionRange - (39891)' in 3ms.
Result: [
  {
    "range": {
      "start": {
        "line": 6,
        "character": 1
      },
      "end": {
        "line": 6,
        "character": 19
      }
    },
    "parent": {
      "range": {
        "start": {
          "line": 6,
          "character": 1
        },
        "end": {
          "line": 6,
          "character": 25
        }
      },
      "parent": {
        "range": {
          "start": {
            "line": 6,
            "character": 0
          },
          "end": {
            "line": 6,
            "character": 26
          }
        }
      }
    }
  }
]

You can see there are only 3 ranges responded by clojure-lsp, but when using the feature in intellij, it behaves like:

Image

where the first selection is the whole string/split-lines and not split

original issue: clojure-lsp/clojure-lsp-intellij#49

Activity

  1. angelozerr commented on Apr 30, 2025

    @angelozerr
    Contributor

    @ericdallo this trace comes from LSP4IJ?

  2. angelozerr commented on Apr 30, 2025

    @angelozerr
    Contributor

    @ericdallo have you a custom PsiFile?

    Could you try without your plugin with user defined ls to use textmate (and not have installed your plugin to be sure that it doesn't use custom PsiFile)

  3. ericdallo commented on Apr 30, 2025

    @ericdallo
    ContributorAuthor

    @angelozerr yes we have a custom PsiFile, I can try but how we could make it use only lsp4ij?

  4. ericdallo commented on Apr 30, 2025

    @ericdallo
    ContributorAuthor

    same problema, updated logs with textmate only:

    [Trace - 08:57:41] Sending request 'textDocument/selectionRange - (100)'.
    Params: {
      "textDocument": {
        "uri": "file:///home/greg/dev/clojure-sample/src/clojure_sample/foo.clj"
      },
      "positions": [
        {
          "line": 6,
          "character": 12
        }
      ]
    }
    
    
    [Trace - 08:57:41] Received response 'textDocument/selectionRange - (100)' in 0ms.
    Result: [
      {
        "range": {
          "start": {
            "line": 6,
            "character": 1
          },
          "end": {
            "line": 6,
            "character": 19
          }
        },
        "parent": {
          "range": {
            "start": {
              "line": 6,
              "character": 1
            },
            "end": {
              "line": 6,
              "character": 25
            }
          },
          "parent": {
            "range": {
              "start": {
                "line": 6,
                "character": 0
              },
              "end": {
                "line": 6,
                "character": 26
              }
            }
          }
        }
      }
    ]

    Image

  5. ericdallo commented on Apr 30, 2025

    @ericdallo
    ContributorAuthor

    This is how vscode does, which is what I expect:

    Image

  6. angelozerr commented on Apr 30, 2025

    @angelozerr
    Contributor

    Where can I donwload your language server? Or perhaps could you attach your clojure-lsp .exe in the issue.

  7. ericdallo commented on Apr 30, 2025

    @ericdallo
    ContributorAuthor

    Here you will find a nightly build which supports selectionRange

  8. angelozerr commented on Apr 30, 2025

    @angelozerr
    Contributor

    I have tried it and I have this error (on Wondows 64)

    [Trace - 14:18:51] Received response 'textDocument/selectionRange - (71)' in 0ms.
    No response returned.
    Error: {
      "code": -32603,
      "message": "Internal error",
      "data": {
        "id": "71",
        "method": "textDocument/selectionRange"
      }
    }
    
    
  9. angelozerr commented on Apr 30, 2025

    @angelozerr
    Contributor

    Opps sorry Ican reproduce your issue.

    But when your clojure file has an error it fails

    Ex:

    (ns test)
      (:require
       [clojure.string :as string]))
    
    (string/split-lines "123")
    
  10. ericdallo commented on Apr 30, 2025

    @ericdallo
    ContributorAuthor

    Yes, with a wrong code it should not work indeed, try:

    (ns test
      (:require
       [clojure.string :as string]))
    
    (string/split-lines "123")
  11. self-assigned this
    on Apr 30, 2025
  12. added
    bug
    on Apr 30, 2025
  13. added this to the 0.13.0 milestone on Apr 30, 2025
  14. added 2 commits that reference this issue on Apr 30, 2025
    3333f26
    f53e93d
  15. added a commit that references this issue on May 1, 2025
    0468245
  16. angelozerr commented on May 1, 2025

    @angelozerr
    Contributor

    @ericdallo please try nighty build.

  17. ericdallo commented on May 2, 2025

    @ericdallo
    ContributorAuthor

    That fixed! thank you @angelozerr

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

Metadata

Metadata

Assignees

Labels

bugselectionRange

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions