lsp-mode icon indicating copy to clipboard operation
lsp-mode copied to clipboard

Lsp-mode doesn't filter input text

Open victorpigmeo opened this issue 3 years ago • 3 comments

Thank you for the bug report

  • [X] I am using the latest version of lsp-mode related packages.
  • [X] I checked FAQ and Troubleshooting sections
  • [ ] You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

I'm using lsp-dart and I'm experiencing a glitch that I described on this issue. When I type a { anywhere in my code, specially when is a function start the snippets menu open to fast, so when I tap Enter to break the line, it applies the snippet selected on the context menu opened. According to the other issue this occurs because lsp-mode doesn't filter the input text.

Steps to reproduce

  • install dart-lsp
  • open a .dart file
  • type something like void test(){<enter>}

Expected behavior

The expected behavior is that the menu doesn't open on some places, like the example above.

Which Language Server did you use?

lsp-dart

OS

Linux

Error callstack

No response

Anything else?

maybe @ericdallo can provide more information about this on lsp-dart side

victorpigmeo avatar Mar 16 '22 00:03 victorpigmeo

It may help providing the communication between server and client, you can achieve that following https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/#log-client-server-json

ericdallo avatar Mar 16 '22 00:03 ericdallo

[Trace - 09:27:13 PM] Sending request 'textDocument/completion - (1550)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 33
  },
  "context": {
    "triggerCharacter": "{",
    "triggerKind": 2
  }
}


[Trace - 09:27:13 PM] Sending request 'textDocument/codeAction - (1551)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "range": {
    "start": {
      "line": 141,
      "character": 33
    },
    "end": {
      "line": 141,
      "character": 33
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 09:27:13 PM] Sending request 'textDocument/documentHighlight - (1552)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 33
  }
}


[Trace - 09:27:13 PM] Sending request 'textDocument/hover - (1553)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 33
  }
}


[Trace - 09:27:13 PM] Received notification '$/progress'.
Params: {
  "value": {
    "title": "Analyzing…",
    "kind": "begin"
  },
  "token": "ANALYZING"
}


[Trace - 09:27:13 PM] Received notification '$/progress'.
Params: {
  "value": {
    "kind": "end"
  },
  "token": "ANALYZING"
}


[Trace - 09:27:13 PM] Received response 'textDocument/completion - (1550)' in 30ms.
Result: []


[Trace - 09:27:13 PM] Sending request 'textDocument/completion - (1554)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 33
  },
  "context": {
    "triggerCharacter": "{",
    "triggerKind": 2
  }
}


[Trace - 09:27:13 PM] Received response 'textDocument/completion - (1554)' in 13ms.
Result: []


[Trace - 09:27:13 PM] Sending request 'textDocument/completion - (1555)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 33
  },
  "context": {
    "triggerCharacter": "{",
    "triggerKind": 2
  }
}


[Trace - 09:27:13 PM] Received response 'textDocument/completion - (1555)' in 21ms.
Result: []


[Trace - 09:27:13 PM] Sending request 'textDocument/completion - (1556)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 33
  },
  "context": {
    "triggerCharacter": "{",
    "triggerKind": 2
  }
}


[Trace - 09:27:13 PM] Received response 'textDocument/completion - (1556)' in 21ms.
Result: []


[Trace - 09:27:15 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 1553
}


[Trace - 09:27:15 PM] Sending request 'textDocument/hover - (1557)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 32
  }
}


[Trace - 09:27:15 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 1551
}


[Trace - 09:27:15 PM] Sending request 'textDocument/codeAction - (1558)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "range": {
    "start": {
      "line": 141,
      "character": 32
    },
    "end": {
      "line": 141,
      "character": 32
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 09:27:15 PM] Sending notification '$/cancelRequest'.
Params: {
  "id": 1552
}


[Trace - 09:27:15 PM] Sending request 'textDocument/documentHighlight - (1559)'.
Params: {
  "textDocument": {
    "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
  },
  "position": {
    "line": 141,
    "character": 32
  }
}


[Trace - 09:27:15 PM] Received response 'textDocument/hover - (1557)' in 32ms.
Result: null


[Trace - 09:27:15 PM] Received response 'textDocument/codeAction - (1558)' in 27ms.
Result: [
  {
    "command": {
      "arguments": [
        "/home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
      ],
      "command": "edit.sortMembers",
      "title": "Sort Members"
    },
    "kind": "source.sortMembers",
    "title": "Sort Members"
  },
  {
    "command": {
      "arguments": [
        "/home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
      ],
      "command": "edit.organizeImports",
      "title": "Organize Imports"
    },
    "kind": "source.organizeImports",
    "title": "Organize Imports"
  },
  {
    "command": {
      "arguments": [
        "/home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart"
      ],
      "command": "edit.fixAll",
      "title": "Fix All"
    },
    "kind": "source.fixAll",
    "title": "Fix All"
  },
  {
    "edit": {
      "documentChanges": [
        {
          "edits": [
            {
              "newText": "async ",
              "range": {
                "end": {
                  "character": 32,
                  "line": 141
                },
                "start": {
                  "character": 32,
                  "line": 141
                }
              }
            }
          ],
          "textDocument": {
            "uri": "file:///home/victor/dev/belvedere/lib/comanda/screens/comanda_screen.dart",
            "version": 1335
          }
        }
      ]
    },
    "diagnostics": [],
    "kind": "refactor.convert.bodyToAsync",
    "title": "Convert to async function body"
  }
]


[Trace - 09:27:15 PM] Received response 'textDocument/documentHighlight - (1559)' in 40ms.
Result: null

is this the right log?

victorpigmeo avatar Mar 16 '22 00:03 victorpigmeo

It seems server is returning empty results for { which seems correct, @yyoncho any thoughts? Maybe completion cache?

ericdallo avatar Mar 16 '22 02:03 ericdallo

I can confirm that if typing c and quickly calling company to complete it's inserted the comment snippet wrongly, any thoughts @yyoncho ?

ericdallo avatar Oct 31 '22 00:10 ericdallo

seems like a cache bug... It has to be investigated.

cc @kiennq

yyoncho avatar Oct 31 '22 06:10 yyoncho