Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkedEditing mode incorrectly triggered #1311

Open
notpeter opened this issue Dec 16, 2024 · 0 comments
Open

linkedEditing mode incorrectly triggered #1311

notpeter opened this issue Dec 16, 2024 · 0 comments

Comments

@notpeter
Copy link

Expected Behavior

textDocument/linkedEditingRange mode is not triggered when typing on empty lines lines

Current Behavior

Duplicated characters are inserted into the buffer on the line below and on the current line.

Possible Solution

I wonder whether is an off-by-one error when mapping the current cursor position in the code to determine whether to enable linkedEditingRange. Have not investigated further.

Steps to Reproduce (for bugs)

Reproducible with both Zed and VSCode.

Zed Steps:
Install the Zed Elm extension (cmd-shift-x, search for Elm, click install.

brew install elm
mkdir /tmp/elm
cd $_
elm init
echo '-- Welcome to hell

viewError : View Msg
viewError = {}
' > src/Main.elm
zed . src/Main.elm:2

Then type something (abc) on line 2.
Use undo (cmd-z) if you want to trigger it multiple times.

Context

End-users trying to edit files can duplicated text inserted a line below after the first character.

Your Environment

  • Version used: "@elm-tooling/elm-language-server": "2.8.0" (installed via npm)
  • Editor used: Zed Nightly 0.167.0
  • Environment name and version node-v18.15.0-darwin-arm64
  • Operating System and version: macOS Sonoma 14.7

Extra info

See also:

zed video
Screen.Recording.2024-12-15.at.21.43.53.mov
vscode video
Screen.Recording.2024-12-16.at.14.13.04.mov

elm-language-server LSP logs: rpc messages
// Send:
{
  "jsonrpc": "2.0",
  "method": "textDocument/didChange",
  "params": {
    "textDocument": {
      "uri": "file:///private/tmp/elm/src/Main.elm",
      "version": 48
    },
    "contentChanges": [
      {
        "range": {
          "start": {
            "line": 1,
            "character": 0
          },
          "end": {
            "line": 1,
            "character": 0
          }
        },
        "text": "a"
      }
    ]
  }
}
// Receive:
{
  "jsonrpc": "2.0",
  "method": "window/logMessage",
  "params": {
    "type": 3,
    "message": "Changed text document, going to parse it. file:///private/tmp/elm/src/Main.elm"
  }
}
// Send
{
  "jsonrpc": "2.0",
  "id": 135,
  "method": "textDocument/linkedEditingRange",
  "params": {
    "textDocument": {
      "uri": "file:///private/tmp/elm/src/Main.elm"
    },
    "position": {
      "line": 1,
      "character": 1
    }
  }
}
// Receive
{
  "jsonrpc": "2.0",
  "id": 135,
  "result": {
    "ranges": [
      {
        "start": {
          "line": 1,
          "character": 0
        },
        "end": {
          "line": 1,
          "character": 1
        }
      },
      {
        "start": {
          "line": 2,
          "character": 0
        },
        "end": {
          "line": 2,
          "character": 1
        }
      }
    ]
  }
}

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant