Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/contrib/longLinesHelper/browser/longLinesHelper.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable } from '../../../../base/common/lifecycle.js';
7
import { ICodeEditor, MouseTargetType } from '../../../browser/editorBrowser.js';
8
import { EditorContributionInstantiation, registerEditorContribution } from '../../../browser/editorExtensions.js';
9
import { EditorOption } from '../../../common/config/editorOptions.js';
10
import { IEditorContribution } from '../../../common/editorCommon.js';
11
12
class LongLinesHelper extends Disposable implements IEditorContribution {
13
public static readonly ID = 'editor.contrib.longLinesHelper';
14
15
public static get(editor: ICodeEditor): LongLinesHelper | null {
16
return editor.getContribution<LongLinesHelper>(LongLinesHelper.ID);
17
}
18
19
constructor(
20
private readonly _editor: ICodeEditor,
21
) {
22
super();
23
24
this._register(this._editor.onMouseDown((e) => {
25
const stopRenderingLineAfter = this._editor.getOption(EditorOption.stopRenderingLineAfter);
26
if (stopRenderingLineAfter >= 0 && e.target.type === MouseTargetType.CONTENT_TEXT && e.target.position.column >= stopRenderingLineAfter) {
27
this._editor.updateOptions({
28
stopRenderingLineAfter: -1
29
});
30
}
31
}));
32
}
33
}
34
35
registerEditorContribution(LongLinesHelper.ID, LongLinesHelper, EditorContributionInstantiation.BeforeFirstInteraction);
36
37