-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
bug: hlsearch is persistent in places text no longer exists, or never was #1888
Comments
FWIW, I am interested in working to solve this bug, so if you have any pointers as to where I could look, it would be appreciated! Otherwise, I'm going to do some digging of my own. |
I've been staring at this for a little while, and I'm having trouble capturing the precise nature of what's going on, but I do think I have some kind of idea, and I wanted to share my findings. In order to calculate offsets, the highlight manager requests details about the current viewport, which implies that these vscode-neovim/src/highlight_manager.ts Line 51 in f7f8938
When a batch of redraws is received, the extension broadcasts all the redraw events to the various vscode-neovim/src/main_controller.ts Lines 301 to 315 in f7f8938
The nvim docs state that the events must be handled in order.
Unfortunately, there's no guarantee this will happen here for a given batch of redraws. Consider a I think that VSCode's With this in mind, I applied this patch to fire the redraw events one by one, in order, but it didn't seem to fix the issue. diff --git a/src/main_controller.ts b/src/main_controller.ts
index 5ed5504..fdec736 100644
--- a/src/main_controller.ts
+++ b/src/main_controller.ts
@@ -299,6 +299,7 @@ export class MainController implements vscode.Disposable {
const hasFlush = findLastEvent("flush", events);
if (hasFlush) {
const batch = [...this.currentRedrawBatch.splice(0), ...redrawEvents];
+ batch.reverse()
const eventData = batch.map(
(b) =>
({
@@ -312,7 +313,9 @@ export class MainController implements vscode.Disposable {
},
}) as any,
);
- eventBus.fire("redraw", eventData);
+ eventData.forEach((item) => {
+ eventBus.fire("redraw", [item]);
+ })
} else {
this.currentRedrawBatch.push(...redrawEvents);
} I'll keep playing with this. |
Another interesting case of this: if you press tab after a double-wide character, the highlights are offset. It's weirdly inconsistent, too. Here, you'll notice that as I press tab after searching for simplescreenrecorder-2024-04-27_22.15.47.mp4 |
Yes, this is a legacy bug #1449 (comment). The main challenge now is that we need to convert the drawing information from nvim into vscode decorations, rather than directly rendering(and there are also differences between JavaScript character rules and CSS character rules). Nvim only sends data for the changes that occur in a line. For example, if there's a multi-width character that occupies 2 cells, we might only receive data for one cell. However, in vscode, we store highlights based on characters, which makes it difficult to calculate. @justinmk If nvim could provide an option to always send complete highlight information for each line, this problem would become simpler. Of course, we can definitely solve this, but it will require consideration of many edge cases. |
Are you sure there isn't a way to enable that in |
#1976 may helps this |
Can this issue be reproduced in v1.12.0? |
@xiyaowong It's definitely not fully resolved. I need to find a consistent reproducer, but while doing some other work, I managed to make this happen. I had searched |
an old issue, the viewport changes while dealing with the highlight. |
This has definitely been a lot better as of late. I've seen a few instances where whitespace is highlighted when it shouldn't, but ctrl+L seems to clear them. |
Check the following:
Neovim version (nvim -v)
v0.9.5
Operating system/version
Fedora 39
Describe the bug
When I use
hlsearch
, sometimes the "highlights" stick around in places the text no longer exists, similar to #1555. I'm not sure when it originated, it's been a problem for as long as I've used the plugin, but I've never quite pinned it down until now (it felt "random")I've attached a video of a repro, but it's definitely not consistent in how it fails. In this case, you'll notice that once I hit
J
to join the lines, theI
fromInsert
is duplicated. You'll also notice that on line 69, an extraInsert
is overlaid theawait
.simplescreenrecorder-2024-04-14_14.49.49.mp4
Steps To Reproduce
Expected Behavior
The highlight should move with the remaining text, if the text is still a match, just like in the commandline nvim
The text was updated successfully, but these errors were encountered: