sticky scroll disabled in the left hand side of the diff editor

This commit is contained in:
Aiday Marlen Kyzy 2023-06-01 15:23:44 +02:00
parent 9aba21b6aa
commit 374e02fda2
No known key found for this signature in database
GPG key ID: 24A8B53DBD26FF4E
3 changed files with 6 additions and 23 deletions

View file

@ -1297,6 +1297,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
result.readOnly = !this._options.originalEditable;
result.dropIntoEditor = { enabled: !result.readOnly };
result.extraEditorClassName = 'original-in-monaco-diff-editor';
result.stickyScroll = { enabled: false };
return {
...result,
dimension: {

View file

@ -291,6 +291,7 @@ export class DiffEditorWidget2 extends DelegatingEditor implements IDiffEditor {
result.readOnly = !options.originalEditable;
result.dropIntoEditor = { enabled: !result.readOnly };
result.extraEditorClassName = 'original-in-monaco-diff-editor';
result.stickyScroll = { enabled: false };
return result;
}

View file

@ -26,7 +26,6 @@ import { ILanguageConfigurationService } from 'vs/editor/common/languages/langua
import { ILanguageFeatureDebounceService } from 'vs/editor/common/services/languageFeatureDebounce';
import * as dom from 'vs/base/browser/dom';
import { StickyRange } from 'vs/editor/contrib/stickyScroll/browser/stickyScrollElement';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
interface CustomMouseEvent {
detail: string;
@ -77,8 +76,7 @@ export class StickyScrollController extends Disposable implements IEditorContrib
@IInstantiationService private readonly _instaService: IInstantiationService,
@ILanguageConfigurationService _languageConfigurationService: ILanguageConfigurationService,
@ILanguageFeatureDebounceService _languageFeatureDebounceService: ILanguageFeatureDebounceService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@ICodeEditorService private readonly _codeEditorService: ICodeEditorService
@IContextKeyService private readonly _contextKeyService: IContextKeyService
) {
super();
this._stickyScrollWidget = new StickyScrollWidget(this._editor);
@ -299,32 +297,15 @@ export class StickyScrollController extends Disposable implements IEditorContrib
});
}
private _removeStickyWidget(): void {
this._editor.removeOverlayWidget(this._stickyScrollWidget);
this._sessionStore.clear();
this._enabled = false;
}
private _readConfiguration() {
const options = this._editor.getOption(EditorOption.stickyScroll);
if (options.enabled === false) {
this._removeStickyWidget();
this._editor.removeOverlayWidget(this._stickyScrollWidget);
this._sessionStore.clear();
this._enabled = false;
return;
} else if (options.enabled && !this._enabled) {
// Do not render the sticky scroll if the editor is the left side of an inline diff editor
let isLeftSideOfInlineDiffEditor = false;
if (this._editor.getOption(EditorOption.inDiffEditor)) {
for (const diffEditor of this._codeEditorService.listDiffEditors()) {
if (diffEditor.getOriginalEditor() === this._editor && !diffEditor.renderSideBySide) {
isLeftSideOfInlineDiffEditor = true;
}
}
}
if (isLeftSideOfInlineDiffEditor) {
this._removeStickyWidget();
return;
}
// When sticky scroll was just enabled, add the listeners on the sticky scroll
this._editor.addOverlayWidget(this._stickyScrollWidget);
this._sessionStore.add(this._editor.onDidScrollChange(() => this._renderStickyScroll()));