Skip to content
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

fix(incsearch): win cursor not properly revealed #1971

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cursor_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class CursorManager implements Disposable {
window.visibleTextEditors.forEach((e) => (e.options.cursorStyle = style));
},
},
main.viewportManager.onCursorChanged((grid) => this.gridCursorUpdates.addForceUpdate(grid)),
);
}

Expand Down
24 changes: 23 additions & 1 deletion src/viewport_manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { DebouncedFunc, debounce } from "lodash-es";
import { Disposable, Position, TextEditor, TextEditorVisibleRangesChangeEvent, window, workspace } from "vscode";
import {
Disposable,
EventEmitter,
Position,
TextEditor,
TextEditorVisibleRangesChangeEvent,
window,
workspace,
} from "vscode";

import actions from "./actions";
import { config } from "./config";
Expand Down Expand Up @@ -30,12 +38,18 @@ export class ViewportManager implements Disposable {

private syncViewportPromise?: ManualPromise;

// TODO: Temporary solution. Need to refactor cursor manager and viewport manager.
// Related issue: https://github.com/neovim/neovim/issues/28800
private cursorChanged = new EventEmitter<number>();
public onCursorChanged = this.cursorChanged.event;

private get client() {
return this.main.client;
}

public constructor(private main: MainController) {
this.disposables.push(
this.cursorChanged,
window.onDidChangeTextEditorVisibleRanges(this.onDidChangeVisibleRange),
eventBus.on("redraw", this.handleRedraw, this),
eventBus.on("window-scroll", ([winId, saveView]) => {
Expand Down Expand Up @@ -88,10 +102,14 @@ export class ViewportManager implements Disposable {
case "win_viewport": {
for (const [grid, , topline, botline, curline, curcol] of args) {
const view = this.getViewport(grid);
const { line, col } = view;
view.topline = topline;
view.botline = botline;
view.line = curline;
view.col = curcol;
if (line !== curline || col !== curcol) {
this.cursorChanged.fire(grid);
}
}
// HACK: See #1575
// Don't await, as it may result in processing different events in the wrong order.
Expand All @@ -103,11 +121,15 @@ export class ViewportManager implements Disposable {
const grid = this.main.bufferManager.getGridIdForWinId(currWin);
if (!grid) return;
const view = this.getViewport(grid);
const { line, col } = view;
view.line = currView.lnum - 1;
view.col = currView.col;
view.topline = currView.topline - 1;
view.leftcol = currView.leftcol;
view.skipcol = currView.skipcol;
if (line !== view.line || col !== view.col) {
this.cursorChanged.fire(grid);
}
})
.finally(() => {
this.syncViewportPromise?.resolve();
Expand Down