Path: blob/main/src/vs/editor/contrib/longLinesHelper/browser/longLinesHelper.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Disposable } from '../../../../base/common/lifecycle.js';6import { ICodeEditor, MouseTargetType } from '../../../browser/editorBrowser.js';7import { EditorContributionInstantiation, registerEditorContribution } from '../../../browser/editorExtensions.js';8import { EditorOption } from '../../../common/config/editorOptions.js';9import { IEditorContribution } from '../../../common/editorCommon.js';1011class LongLinesHelper extends Disposable implements IEditorContribution {12public static readonly ID = 'editor.contrib.longLinesHelper';1314public static get(editor: ICodeEditor): LongLinesHelper | null {15return editor.getContribution<LongLinesHelper>(LongLinesHelper.ID);16}1718constructor(19private readonly _editor: ICodeEditor,20) {21super();2223this._register(this._editor.onMouseDown((e) => {24const stopRenderingLineAfter = this._editor.getOption(EditorOption.stopRenderingLineAfter);25if (stopRenderingLineAfter >= 0 && e.target.type === MouseTargetType.CONTENT_TEXT && e.target.position.column >= stopRenderingLineAfter) {26this._editor.updateOptions({27stopRenderingLineAfter: -128});29}30}));31}32}3334registerEditorContribution(LongLinesHelper.ID, LongLinesHelper, EditorContributionInstantiation.BeforeFirstInteraction);353637