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

When inlay hints appear/disappear rerender the sticky scroll #158893

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2332,11 +2332,12 @@ export class DidChangeDecorationsEmitter extends Disposable {
this._deferredCnt--;
if (this._deferredCnt === 0) {
if (this._shouldFire) {
const affectedTextLines = new Set(this._affectedInjectedTextLines);
this.handleBeforeFire(this._affectedInjectedTextLines);

const event: IModelDecorationsChangedEvent = {
affectsMinimap: this._affectsMinimap,
affectsOverviewRuler: this._affectsOverviewRuler
affectsOverviewRuler: this._affectsOverviewRuler,
linesAffected: affectedTextLines,
};
this._shouldFire = false;
this._affectsMinimap = false;
Expand Down
1 change: 1 addition & 0 deletions src/vs/editor/common/textModelEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface IModelContentChangedEvent {
export interface IModelDecorationsChangedEvent {
readonly affectsMinimap: boolean;
readonly affectsOverviewRuler: boolean;
readonly linesAffected?: Set<number> | null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ export class StickyScrollController extends Disposable implements IEditorContrib
if (lineNumberOption.renderType === RenderLineNumbersType.Relative) {
this._sessionStore.add(this._editor.onDidChangeCursorPosition(() => this.renderStickyScroll()));
}
const inlayHintsOptions = this._editor.getOption(EditorOption.inlayHints);
if (inlayHintsOptions.enabled === 'offUnlessPressed' || inlayHintsOptions.enabled === 'onUnlessPressed') {
this._editor.onDidChangeModelDecorations((e) => {
const firstLine = this._widgetState.lineNumbers[0];
const lastLine = this._widgetState.lineNumbers[this._widgetState.lineNumbers.length - 1];
if (!e.linesAffected || !firstLine || !lastLine) {
return;
}
for (const line of e.linesAffected) {
if (line >= firstLine && line <= lastLine) {
this.renderStickyScroll();
return;
}
}
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export class StickyLineCandidateProvider extends Disposable {
}

private readConfiguration() {
const options = this._editor.getOption(EditorOption.stickyScroll);
if (options.enabled === false) {
const stickyScrollOptions = this._editor.getOption(EditorOption.stickyScroll);
if (stickyScrollOptions.enabled === false) {
this._sessionStore.clear();
return;
} else {
Expand Down
1 change: 1 addition & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,7 @@ declare namespace monaco.editor {
export interface IModelDecorationsChangedEvent {
readonly affectsMinimap: boolean;
readonly affectsOverviewRuler: boolean;
readonly linesAffected?: Set<number> | null;
}

export interface IModelOptionsChangedEvent {
Expand Down