AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
226 stars 54 forks source link

[Bug]: LSP Client may not indent cursor with onTypeFormatting #1197

Open brownts opened 1 month ago

brownts commented 1 month ago

Environment

Bug Summary and Reproducer

Apparently the LSP doesn't guarantee the location of the cursor when edits are applied. Both major LSP clients for Emacs (Eglot and lsp-mode) lock the cursor (i.e., point) before applying edits. This prevents the Ada Language Server's onTypeFormatting from being used for indentation purposes as the indentation space will be inserted into the editor's buffer, but the cursor is kept at the beginning of the line instead of pushed to the end of it by the inserted space. I filed a bug report against Eglot here, but it seems the Language Server might not be able to assume that the cursor is actually moved due to this text insertion.

AnthonyLeonardoGracio commented 1 month ago

Hello,

Usually clients use a minimal diff algorithm when applying TextEdits from the LSP servers: this allows to keep the cursor at the right place when indenting. That's what VS Code and GNAT Studio do for instance.

So at this stage I would say that it's a client bug/missing capabiilty.