Skip to content

Messed up completions eating spaces, smeicolons etc. #20630

@vikigenius

Description

@vikigenius

rust-analyzer version: rust-analyzer 0.3.2593-standalone

rustc version: rustc 1.88.0 (6b00bc388 2025-06-23)

editor or extension: Emacs lsp-mode

code snippet to reproduce:

use crate::backend::{Backend, BackendId};
use async_lsp::{
    lsp_types::{InitializeParams, InitializeResult, ServerCapabilities}, router::Router, LanguageServer, ResponseError
};
use futures::future::BoxFuture;
use std::{collections::HashMap, ops::ControlFlow};

pub struct Server {
    backends: HashMap<BackendId, Backend>,
}

impl Server {
    fn new() {
        let mut router = Router::from_language_server(Self { backends: HashMap::new() });
    }
}

impl LanguageServer for Server {
    typeError = ; // This is the problem
    type NotifyResult = ControlFlow<async_lsp::Result<()>>;

    fn initialize(
        &mut self,
        params: InitializeParams,
    ) -> BoxFuture<'static, Result<InitializeResult, Self::Error>> {
        Box::pin(async move {Ok(InitializeResult { capabilities: ServerCapabilities::default(), server_info: None })})
    }
}

Here are the relevant portion of the logs

{
   "label":"type Error =",
   "kind":22,
   "preselect":true,
   "sortText":"7fffffeb",
   "filterText":"type Error",
   "insertTextFormat":2,
   "textEdit":{
      "newText":"typeError = $0;",
      "insert":{
         "start":{
            "line":18,
            "character":4
         },
         "end":{
            "line":18,
            "character":6
         }
      },
      "replace":{
         "start":{
            "line":18,
            "character":4
         },
         "end":{
            "line":18,
            "character":6
         }
      }
   },
   "data":{
      "position":{
         "textDocument":{
            "uri":"file:///home/void/Projects/Rust/rmux-lsp/src/serve.rs"
         },
         "position":{
            "line":18,
            "character":6
         }
      },
      "version":4,
      "for_ref":null,
      "hash":"+E5LTI1OZRcSvGkQXcVnEW9T0tE="
   }
},

You can see that it wants to insert typeError = $0 rather than type Error =

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions