Skip to content

ghost text: invalid 'col' out of range #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
mirsella opened this issue Nov 4, 2024 · 7 comments · Fixed by #287
Closed
2 tasks done

ghost text: invalid 'col' out of range #257

mirsella opened this issue Nov 4, 2024 · 7 comments · Fixed by #287
Labels
bug Something isn't working windows Module which displays UI

Comments

@mirsella
Copy link

mirsella commented Nov 4, 2024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

this only happens on large rust project, where rust analyzer is slow to give response. there is a lot of "rust-analyzer: -32802: server cancelled the request". there is completion after like 500ms when rust analyzer give the response.
the problem might not be much the late response, but maybe also rust analyzer returning big function / types which are sometimes bigger than the screen

  Error  10:32:04 notify.error rust-analyzer: -32802: server cancelled the request
   Error  10:32:05 msg_show.lua_error Error executing vim.schedule lua callback: ...nvim/lazy/blink.cmp/lua/blink/cmp/windows/ghost-text.lua:61: Invalid 'col': out of range
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	...nvim/lazy/blink.cmp/lua/blink/cmp/windows/ghost-text.lua:61: in function 'show_preview'
	...nvim/lazy/blink.cmp/lua/blink/cmp/windows/ghost-text.lua:15: in function 'callback'
	...im/lazy/blink.cmp/lua/blink/cmp/windows/autocomplete.lua:313: in function 'emit_on_select'
	...im/lazy/blink.cmp/lua/blink/cmp/windows/autocomplete.lua:157: in function 'open_with_items'
	.../.local/share/nvim/lazy/blink.cmp/lua/blink/cmp/init.lua:57: in function <.../.local/share/nvim/lazy/blink.cmp/lua/blink/cmp/init.lua:51>

Relevant configuration

windows = {
        ghost_text = {
          enabled = true,
        },
      },

neovim version

NVIM v0.10.2 Build type: RelWithDebInfo LuaJIT 2.1.1727870382

blink.cmp version: branch, tag, or commit

d3e1c92

@mirsella mirsella added the bug Something isn't working label Nov 4, 2024
@Saghen Saghen added the windows Module which displays UI label Nov 4, 2024
@stefanboca
Copy link
Collaborator

stefanboca commented Nov 5, 2024

I'm also getting this on textEdits where range.end.character is at the end of a line (equivalent to the length of the line + 1, which I believe is perfectly reasonable according to the LSP spec because the end character is excluded from the range). NVM, I set the range end index incorrectly :)

@lopi-py
Copy link
Contributor

lopi-py commented Nov 11, 2024

I'm getting this too with jdtls after db3d1ad. It was working before.

Typing E:
image

Typing En:
image

I tried with #287 but doesn't seems to solve the issue, and also the ghost text starts to flicker
image

@mirsella
Copy link
Author

@lopi-py the problem seems to be resolved for me.
use the main version instead of release, and maybe cargo build --release

@stefanboca
Copy link
Collaborator

@Saghen I'm working on compat (trying to get supermaven working) and I'm getting this issue again.

image

@stefanboca
Copy link
Collaborator

Although this might be because supermaven also inserts its own virtual text. In a bit I'll try disabling supermaven's ghost text, and I'll let you know if this still occurs.

@stefanboca
Copy link
Collaborator

This still occurs, even when all vim.api calls related to extmarks in supermaven are removed.

@Saghen Saghen reopened this Dec 2, 2024
@stefanboca
Copy link
Collaborator

Here's a minimal repro. In the file:

pr|

(where | is the cursor)

the completion item that triggers the error is

 {
  cmp = {
    kind_hl_group = "CmpItemKindSupermaven",
    kind_text = "Supermaven"
  },
  cursor_column = 2,
  documentation = {
    kind = "markdown",
    value = '```python\nprint("hello")\n```'
  },
  dup = 0,
  insertTextFormat = 1,
  kind = 1,
  label = 'print("hello")',
  score = 100,
  score_offset = 0,
  source_id = "supermaven",
  source_name = "supermaven",
  textEdit = {
    insert = <1>{
      ["end"] = {
        character = 3,
        line = 0
      },
      start = {
        character = 0,
        line = 0
      }
    },
    newText = 'print("hello")',
    replace = <table 1>
  }
}

@Saghen Saghen closed this as completed in 7ceff61 Dec 2, 2024
folke pushed a commit to LazyVim/LazyVim that referenced this issue Dec 2, 2024
## Description

Supermaven completion now works with the latest release of blink.cmp and
blink.compat. I'll also take a look at the other ai extras soon.

~A draft for now, until some issues with ghost text are resolved, see
Saghen/blink.cmp#257. Alternatively, enabling
the supermaven extra could disable ghost text.~

## Screenshots


![image](https://github.com/user-attachments/assets/feb8003d-85c5-49a4-80df-7f57b240d371)

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Module which displays UI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants