Skip to content

Commit

Permalink
Fixes #156786
Browse files Browse the repository at this point in the history
  • Loading branch information
aiday-mar committed Aug 23, 2022
1 parent 6b5baad commit b87aa2b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/vs/editor/common/model/textModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2332,12 +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);

// TODO: CHANGE HERE IN ORDER TO FIRE THE AFFECTED LINES TOO
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 @@ -11,7 +11,6 @@ import { EditorOption, RenderLineNumbersType } from 'vs/editor/common/config/edi
import { StickyScrollWidget, StickyScrollWidgetState } from './stickyScrollWidget';
import { StickyLineCandidateProvider, StickyRange } from './stickyScrollProvider';
import { IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents';
import { ModifierKeyEmitter } from 'vs/base/browser/dom';

export class StickyScrollController extends Disposable implements IEditorContribution {

Expand All @@ -21,7 +20,6 @@ export class StickyScrollController extends Disposable implements IEditorContrib
private readonly _stickyLineCandidateProvider: StickyLineCandidateProvider;
private readonly _sessionStore: DisposableStore = new DisposableStore();
private _widgetState: StickyScrollWidgetState;
private _ctrlAltClicked: boolean;

constructor(
_editor: ICodeEditor,
Expand All @@ -32,8 +30,6 @@ export class StickyScrollController extends Disposable implements IEditorContrib
this._stickyScrollWidget = new StickyScrollWidget(this._editor);
this._stickyLineCandidateProvider = new StickyLineCandidateProvider(this._editor, _languageFeaturesService);
this._widgetState = new StickyScrollWidgetState([], 0);
this._ctrlAltClicked = false;


this._register(this._editor.onDidChangeConfiguration(e => {
if (e.hasChanged(EditorOption.stickyScroll)) {
Expand Down Expand Up @@ -68,25 +64,21 @@ export class StickyScrollController extends Disposable implements IEditorContrib
this._sessionStore.add(this._editor.onDidChangeCursorPosition(() => this.renderStickyScroll()));
}
const inlayHintsOptions = this._editor.getOption(EditorOption.inlayHints);

// inlay hints are decorations, check if it fires below and if it fires not very often
// maybe fire the actual line number, or the range of the decoration, and rerender the sticky scroll in that case
this._editor.onDidChangeModelDecorations((e) => {
console.log('e', e);

});
/*
if (inlayHintsOptions.enabled === 'offUnlessPressed' || inlayHintsOptions.enabled === 'onUnlessPressed') {
this._sessionStore.add(ModifierKeyEmitter.getInstance().event(e => {
console.log('e : ', e);
if (this._ctrlAltClicked !== e.altKey && e.ctrlKey) {
this.renderStickyScroll();
this._ctrlAltClicked = e.altKey && e.ctrlKey;
console.log('_ctrlAltClicked : ', this._ctrlAltClicked);
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
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

0 comments on commit b87aa2b

Please sign in to comment.