completionItem/resolve returns an inverted range for an item created before an edit

Author: wangzhihao-labCreated Sep 28, 2026Updated Sep 28, 2026

rust-analyzer version: 0.3.3057-standalone (aaddfb73fd 2026-09-20), the 2026-09-21 release. Same with the 2026-07-13 release. Also reproduces with the newest release, 2026-09-28, in 3 of 3 runs.

rustc version: rustc 1.98.1 (48a229cea 2026-09-01)

editor or extension: none; I drive the server over stdio from a small LSP client script on macOS 27 (Apple silicon). The client declares completionItem.resolveSupport with properties documentation, detail, additionalTextEdits, textEdit, insertText, and no insertReplaceSupport, so items come without textEdit and get it on resolve.

relevant settings: {"checkOnSave": false, "cargo": {"buildScripts": {"enable": true}}, "procMacro": {"enable": true}, "diagnostics": {"enable": true}}

repository link (if public, optional): https://github.com/sxyazi/yazi/tree/0ea4c5d9ef75d7165c2e3b4eb8d713fc11f26c96, file yazi-parser/src/tasks/spawn.rs

code snippet to reproduce:

rust
use anyhow::anyhow;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_core::tasks::TaskOpt;
use yazi_shared::event::ActionCow;

#[derive(Clone, Debug)]
pub struct SpawnForm {
	pub opt: TaskOpt,
}

These are the first lines of yazi-parser/src/tasks/spawn.rs. Positions below are 0-based LSP positions.

  1. didOpen yazi-parser/src/tasks/spawn.rs (version 1); two other files of the workspace were open as well (yazi-fs/src/mounts/partition.rs, yazi-vfs/src/entries.rs). Wait until the server reports quiescent.
  2. textDocument/completion at {line: 5, character: 8}, right after #[derive. One of the items is anyhow::, with data.position 5:8 and data.version 1. Resolving it at this point gives textEdit 5:2-5:8, anyhow::, which is fine.
  3. didChange (version 2): insert "\n\n" at {line: 5, character: 0}. #[derive(Clone, Debug)] is now on line 7.
  4. completionItem/resolve with the anyhow:: item from step 2, unchanged.

Actual: the textEdit range is start {line: 6, character: 0}, end {line: 5, character: 8}. The start is after the end and the range spans two lines, so it contains no position at all; the spec requires a single-line range that contains the position where completion was requested. The end is the position of the original request. Same in 3 of 3 runs.

Expected: an error, or the item without a textEdit, since data.version is 1 and the document is at version 2; or the edit that a new completion at the new position gives: {line: 7, character: 2} to {line: 7, character: 8}, anyhow::.

#23199 also shows an inverted range from completionItem/resolve after an edit. There the edited file is a library file (std sources), and the discussion there says library files are now treated as immutable. Here the file is a workspace member, the edit goes through didChange, and the item was created before the edit. It also happens with the 2026-07-13 release, which #23199 lists as not affected.

LSP trace

F stands for the URI of yazi-parser/src/tasks/spawn.rs; documentation fields elided.

--> textDocument/completion {"textDocument":{"uri":F},"position":{"line":5,"character":8},"context":{"triggerKind":1}}
<-- {"isIncomplete":true,"items":[... 49 items, including
      {"label":"anyhow::","kind":9,"preselect":true,"sortText":"7ffffff6","filterText":"anyhow",
       "data":{"position":{"textDocument":{"uri":F},"position":{"line":5,"character":8}},"version":1,"for_ref":false,"hash":"vFPc7PDMMcJhm7QWC3xKOsS7Bgg="}} ...]}
--> completionItem/resolve (that item)
<-- {"label":"anyhow::","kind":9,"documentation":...,"preselect":true,"sortText":"7ffffff6","filterText":"anyhow",
     "textEdit":{"range":{"start":{"line":5,"character":2},"end":{"line":5,"character":8}},"newText":"anyhow::"}}
--> textDocument/didChange {"textDocument":{"uri":F,"version":2},"contentChanges":[{"range":{"start":{"line":5,"character":0},"end":{"line":5,"character":0}},"text":"\n\n"}]}
--> completionItem/resolve (the same item as above, data.version 1)
<-- {"label":"anyhow::","kind":9,"documentation":...,"preselect":true,"sortText":"7ffffff6","filterText":"anyhow",
     "textEdit":{"range":{"start":{"line":6,"character":0},"end":{"line":5,"character":8}},"newText":"anyhow::"}}
--> textDocument/completion {"textDocument":{"uri":F},"position":{"line":7,"character":8},"context":{"triggerKind":1}}
<-- {"isIncomplete":true,"items":[... "anyhow::" with "data":{... "position":{"line":7,"character":8}},"version":2,...} ...]}
--> completionItem/resolve (the new item)
<-- {"label":"anyhow::",...,"textEdit":{"range":{"start":{"line":7,"character":2},"end":{"line":7,"character":8}},"newText":"anyhow::"}}