Skip to content

fix: #25 Fixes vim:E976 error when cursor is on a blob.#28

Open
rpopic2 wants to merge 2 commits intoya2s:mainfrom
rpopic2:main
Open

fix: #25 Fixes vim:E976 error when cursor is on a blob.#28
rpopic2 wants to merge 2 commits intoya2s:mainfrom
rpopic2:main

Conversation

@rpopic2
Copy link

@rpopic2 rpopic2 commented Feb 11, 2023

  • How to reproduce the original error:
    Error executing lua callback: Vim:E976: using Blob as a String #25
    Open any binary file, move cursor on a blob(blue characters starting with ^), throws vim:E976.
    This error is thrown when blob is provided for function vim.fn.matchstr(), instead of a string.
  • What changes I've made:
    • In function matchadd() (line 12),
    • Check whether the current line is a blob, seeing if fn.type(line) is a vim.v.t_blob.
    • If it is a blob, return early from matchadd()
  • Test results:
    I tried reproducing the bug as I mentioned above, and it was fixed.
    Testing environment: MacOS Ventura 13.1, Apple M2, nvim v0.8.3

@Forsigg
Copy link

Forsigg commented Jul 16, 2024

Hello! I see that PR approved, but not merged. I also get this error from issue. @alanchenvon please merge that PR if all ok. And thanks @rpopic2 for that fix!

@ya2s
Copy link
Owner

ya2s commented Feb 13, 2026

Thanks for working on this fix. I reviewed the patch with Issue #25 in mind, and I think we should adjust a few points before merge:

  1. Early return on blob can leave stale highlight
  • The new if fn.type(line) == vim.v.t_blob then return end exits before deleting existing w.cursorword_id.
  • If a previous match exists, it may remain visible when moving onto blob lines.
  • Suggestion: clear existing cursorword_id first, then return for blob lines.
  1. cursorword == "~" is a special-case workaround, not a root fix
  • Excluding only ~ still leaves other regexp meta chars (*, +, [, |, etc.) as potential failures.
  • Suggestion: make pattern construction robust (escape dynamic word / very nomagic) instead of blacklisting specific symbols.

The blob type guard is a good direction, but these changes would make the fix safer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants