-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Description
Hi, here's a .patch file that can be applied with git am. No time to do pull req. rn, maybe this weekend.
Thanks,
Maxwell
From 5cef00e9d2ea2683504845980ab31c19c43c533c Mon Sep 17 00:00:00 2001
From: Maxwell Bland <mbland@motorola.com>
Date: Fri, 4 Apr 2025 12:55:18 -0500
Subject: [PATCH] virtual-text: fix column OOB on backspace
In the current implementation, pressing the backspace key will result in
the virtual-text luascript throwing an error, as the referenced column
is beyond the length of the current line.
Fix it so that virtual-text.lua limits the target column to the line
length.
---
lua/bropilot/virtual-text.lua | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lua/bropilot/virtual-text.lua b/lua/bropilot/virtual-text.lua
index c514879..63cdca2 100644
--- a/lua/bropilot/virtual-text.lua
+++ b/lua/bropilot/virtual-text.lua
@@ -32,10 +32,15 @@ local function render(lines, col)
extmark_opts.virt_lines = virt_lines
end
+ line = vim.fn.line(".")
+ col_count = vim.fn.strlen(vim.fn.getline(l))
+ if col > col_count then
+ col = col_count
+ end
extmark_id = vim.api.nvim_buf_set_extmark(
0,
ns_id,
- vim.fn.line(".") - 1,
+ line - 1,
col - 1,
extmark_opts
)
--
2.39.5
Metadata
Metadata
Assignees
Labels
No labels