Skip to content

WIP: lsp: Apply additionalTextEdits for completions

Tom A. Wagner requested to merge (removed):additional-text-edits into master

Fixes #1406 (closed).

This works pretty well already.

10.dbg| now properly completes to dbg!(10).

A slight problem creeps up when completing a function implementation:

trait T {
    fn hello();
}

Struct S;

impl T for S {
    fn h| 
}

completes the impl to

impl T for S {
    fn hello() {

       } // <-
}

The marked closing bracket is misplaced because the snippet first completes to

impl T for S {
    fn fn hello() {

       } // <-
}

and then the fn that was typed already gets deleted with the additional text edit. (This might not be worth adding a specific workaround for, as additionalTextEdits were never meant to modify the cursor line like this)

Another remaining problem is that using Ctrl+Z to undo changes does not undo the whole snippet, but first each additional edit and then the snippet itself.

Edited by Tom A. Wagner

Merge request reports