mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 17:24:01 -05:00
Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)
* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 * fix config changes * fix strictnull checks
This commit is contained in:
@@ -93,8 +93,7 @@ class DomCharWidthReader {
|
||||
container.appendChild(italicDomNode);
|
||||
|
||||
const testElements: HTMLSpanElement[] = [];
|
||||
for (let i = 0, len = this._requests.length; i < len; i++) {
|
||||
const request = this._requests[i];
|
||||
for (const request of this._requests) {
|
||||
|
||||
let parent: HTMLElement;
|
||||
if (request.type === CharWidthRequestType.Regular) {
|
||||
@@ -113,7 +112,7 @@ class DomCharWidthReader {
|
||||
DomCharWidthReader._render(testElement, request);
|
||||
parent!.appendChild(testElement);
|
||||
|
||||
testElements[i] = testElement;
|
||||
testElements.push(testElement);
|
||||
}
|
||||
|
||||
this._container = container;
|
||||
|
||||
@@ -11,7 +11,7 @@ import * as platform from 'vs/base/common/platform';
|
||||
import { CharWidthRequest, CharWidthRequestType, readCharWidths } from 'vs/editor/browser/config/charWidthReader';
|
||||
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
|
||||
import { CommonEditorConfiguration, IEnvConfiguration } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { IDimension } from 'vs/editor/common/editorCommon';
|
||||
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
|
||||
@@ -320,7 +320,7 @@ export class Configuration extends CommonEditorConfiguration {
|
||||
|
||||
this._register(CSSBasedConfiguration.INSTANCE.onDidChange(() => this._onCSSBasedConfigurationChanged()));
|
||||
|
||||
if (this._validatedOptions.automaticLayout) {
|
||||
if (this._validatedOptions.get(EditorOption.automaticLayout)) {
|
||||
this._elementSizeObserver.startObserving();
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorMoveCommands.moveTo(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition)
|
||||
]
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ export namespace CoreNavigationCommands {
|
||||
toViewLineNumber: result.toLineNumber,
|
||||
toViewVisualColumn: result.toVisualColumn
|
||||
});
|
||||
cursors.reveal(true, (result.reversed ? RevealTarget.TopMost : RevealTarget.BottomMost), ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, (result.reversed ? RevealTarget.TopMost : RevealTarget.BottomMost), ScrollType.Smooth);
|
||||
}
|
||||
|
||||
protected abstract _getColumnSelectResult(context: CursorContext, primary: CursorState, prevColumnSelectData: IColumnSelectData, args: any): IColumnSelectResult;
|
||||
@@ -343,12 +343,8 @@ export namespace CoreNavigationCommands {
|
||||
const validatedPosition = context.model.validatePosition(args.position);
|
||||
const validatedViewPosition = context.validateViewPosition(new Position(args.viewPosition.lineNumber, args.viewPosition.column), validatedPosition);
|
||||
|
||||
let fromViewLineNumber = prevColumnSelectData.fromViewLineNumber;
|
||||
let fromViewVisualColumn = prevColumnSelectData.fromViewVisualColumn;
|
||||
if (!prevColumnSelectData.isReal && args.setAnchorIfNotSet) {
|
||||
fromViewLineNumber = validatedViewPosition.lineNumber;
|
||||
fromViewVisualColumn = args.mouseColumn - 1;
|
||||
}
|
||||
let fromViewLineNumber = args.doColumnSelect ? prevColumnSelectData.fromViewLineNumber : validatedViewPosition.lineNumber;
|
||||
let fromViewVisualColumn = args.doColumnSelect ? prevColumnSelectData.fromViewVisualColumn : args.mouseColumn - 1;
|
||||
return ColumnSelection.columnSelect(context.config, context.viewModel, fromViewLineNumber, fromViewVisualColumn, validatedViewPosition.lineNumber, args.mouseColumn - 1);
|
||||
}
|
||||
});
|
||||
@@ -492,7 +488,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
CursorMoveCommands.move(cursors.context, cursors.getAll(), args)
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,7 +827,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
CursorMoveCommands.moveToBeginningOfLine(cursors.context, cursors.getAll(), this._inSelectionMode)
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,7 +876,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
this._exec(cursors.context, cursors.getAll())
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
|
||||
private _exec(context: CursorContext, cursors: CursorState[]): PartialCursorState[] {
|
||||
@@ -910,7 +906,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
CursorMoveCommands.moveToEndOfLine(cursors.context, cursors.getAll(), this._inSelectionMode)
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -959,7 +955,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
this._exec(cursors.context, cursors.getAll())
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
|
||||
private _exec(context: CursorContext, cursors: CursorState[]): PartialCursorState[] {
|
||||
@@ -990,7 +986,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
CursorMoveCommands.moveToBeginningOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode)
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1034,7 +1030,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
CursorMoveCommands.moveToEndOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode)
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,7 +1249,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorMoveCommands.word(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position)
|
||||
]
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1313,7 +1309,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorMoveCommands.line(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition)
|
||||
]
|
||||
);
|
||||
cursors.reveal(false, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, false, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1385,7 +1381,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorChangeReason.Explicit,
|
||||
CursorMoveCommands.expandLineSelection(cursors.context, cursors.getAll())
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1413,7 +1409,7 @@ export namespace CoreNavigationCommands {
|
||||
CursorMoveCommands.cancelSelection(cursors.context, cursors.getPrimaryCursor())
|
||||
]
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1440,7 +1436,7 @@ export namespace CoreNavigationCommands {
|
||||
cursors.getPrimaryCursor()
|
||||
]
|
||||
);
|
||||
cursors.reveal(true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
cursors.reveal(args.source, true, RevealTarget.Primary, ScrollType.Smooth);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1488,7 +1484,7 @@ export namespace CoreNavigationCommands {
|
||||
|
||||
const viewRange = cursors.context.convertModelRangeToViewRange(range);
|
||||
|
||||
cursors.revealRange(false, viewRange, revealAt, ScrollType.Smooth);
|
||||
cursors.revealRange(args.source, false, viewRange, revealAt, ScrollType.Smooth);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import { HorizontalRange } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
/**
|
||||
* Merges mouse events when mouse move events are throttled
|
||||
@@ -111,7 +113,7 @@ export class MouseHandler extends ViewEventHandler {
|
||||
const onMouseWheel = (browserEvent: IMouseWheelEvent) => {
|
||||
this.viewController.emitMouseWheel(browserEvent);
|
||||
|
||||
if (!this._context.configuration.editor.viewInfo.mouseWheelZoom) {
|
||||
if (!this._context.configuration.options.get(EditorOption.mouseWheelZoom)) {
|
||||
return;
|
||||
}
|
||||
const e = new StandardWheelEvent(browserEvent);
|
||||
@@ -216,7 +218,7 @@ export class MouseHandler extends ViewEventHandler {
|
||||
const targetIsContent = (t.type === editorBrowser.MouseTargetType.CONTENT_TEXT || t.type === editorBrowser.MouseTargetType.CONTENT_EMPTY);
|
||||
const targetIsGutter = (t.type === editorBrowser.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorBrowser.MouseTargetType.GUTTER_LINE_DECORATIONS);
|
||||
const targetIsLineNumbers = (t.type === editorBrowser.MouseTargetType.GUTTER_LINE_NUMBERS);
|
||||
const selectOnLineNumbers = this._context.configuration.editor.viewInfo.selectOnLineNumbers;
|
||||
const selectOnLineNumbers = this._context.configuration.options.get(EditorOption.selectOnLineNumbers);
|
||||
const targetIsViewZone = (t.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE);
|
||||
const targetIsWidget = (t.type === editorBrowser.MouseTargetType.CONTENT_WIDGET);
|
||||
|
||||
@@ -351,8 +353,10 @@ class MouseDownOperation extends Disposable {
|
||||
// Overwrite the detail of the MouseEvent, as it will be sent out in an event and contributions might rely on it.
|
||||
e.detail = this._mouseState.count;
|
||||
|
||||
if (!this._context.configuration.editor.readOnly
|
||||
&& this._context.configuration.editor.dragAndDrop
|
||||
const options = this._context.configuration.options;
|
||||
|
||||
if (!options.get(EditorOption.readOnly)
|
||||
&& options.get(EditorOption.dragAndDrop)
|
||||
&& !this._mouseState.altKey // we don't support multiple mouse
|
||||
&& e.detail < 2 // only single click on a selection can work
|
||||
&& !this._isActive // the mouse is not down yet
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ClientCoordinates, EditorMouseEvent, EditorPagePosition, PageCoordinate
|
||||
import { PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart';
|
||||
import { ViewLine } from 'vs/editor/browser/viewParts/lines/viewLine';
|
||||
import { IViewCursorRenderData } from 'vs/editor/browser/viewParts/viewCursors/viewCursor';
|
||||
import { EditorLayoutInfo } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditorLayoutInfo, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range as EditorRange } from 'vs/editor/common/core/range';
|
||||
import { HorizontalRange } from 'vs/editor/common/view/renderingContext';
|
||||
@@ -239,10 +239,11 @@ export class HitTestContext {
|
||||
|
||||
constructor(context: ViewContext, viewHelper: IPointerHandlerHelper, lastViewCursorsRenderData: IViewCursorRenderData[]) {
|
||||
this.model = context.model;
|
||||
this.layoutInfo = context.configuration.editor.layoutInfo;
|
||||
const options = context.configuration.options;
|
||||
this.layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this.viewDomNode = viewHelper.viewDomNode;
|
||||
this.lineHeight = context.configuration.editor.lineHeight;
|
||||
this.typicalHalfwidthCharacterWidth = context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this.lineHeight = options.get(EditorOption.lineHeight);
|
||||
this.typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
this.lastViewCursorsRenderData = lastViewCursorsRenderData;
|
||||
this._context = context;
|
||||
this._viewHelper = viewHelper;
|
||||
@@ -713,9 +714,10 @@ export class MouseTargetFactory {
|
||||
}
|
||||
|
||||
public getMouseColumn(editorPos: EditorPagePosition, pos: PageCoordinates): number {
|
||||
const layoutInfo = this._context.configuration.editor.layoutInfo;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
const mouseContentHorizontalOffset = this._context.viewLayout.getCurrentScrollLeft() + pos.x - editorPos.x - layoutInfo.contentLeft;
|
||||
return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth);
|
||||
return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth);
|
||||
}
|
||||
|
||||
public static _getMouseColumn(mouseContentHorizontalOffset: number, typicalHalfwidthCharacterWidth: number): number {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./textAreaHandler';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
@@ -16,7 +17,7 @@ import { ViewController } from 'vs/editor/browser/view/viewController';
|
||||
import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart';
|
||||
import { LineNumbersOverlay } from 'vs/editor/browser/viewParts/lineNumbers/lineNumbers';
|
||||
import { Margin } from 'vs/editor/browser/viewParts/margin/margin';
|
||||
import { RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
||||
import { RenderLineNumbersType, EditorOption, IComputedEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { WordCharacterClass, getMapForWordSeparators } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
@@ -91,12 +92,13 @@ export class TextAreaHandler extends ViewPart {
|
||||
|
||||
private readonly _viewController: ViewController;
|
||||
private readonly _viewHelper: ITextAreaHandlerHelper;
|
||||
private _scrollLeft: number;
|
||||
private _scrollTop: number;
|
||||
|
||||
private _accessibilitySupport: AccessibilitySupport;
|
||||
private _contentLeft: number;
|
||||
private _contentWidth: number;
|
||||
private _contentHeight: number;
|
||||
private _scrollLeft: number;
|
||||
private _scrollTop: number;
|
||||
private _fontInfo: BareFontInfo;
|
||||
private _lineHeight: number;
|
||||
private _emptySelectionClipboard: boolean;
|
||||
@@ -117,19 +119,20 @@ export class TextAreaHandler extends ViewPart {
|
||||
|
||||
this._viewController = viewController;
|
||||
this._viewHelper = viewHelper;
|
||||
|
||||
const conf = this._context.configuration.editor;
|
||||
|
||||
this._accessibilitySupport = conf.accessibilitySupport;
|
||||
this._contentLeft = conf.layoutInfo.contentLeft;
|
||||
this._contentWidth = conf.layoutInfo.contentWidth;
|
||||
this._contentHeight = conf.layoutInfo.contentHeight;
|
||||
this._scrollLeft = 0;
|
||||
this._scrollTop = 0;
|
||||
this._fontInfo = conf.fontInfo;
|
||||
this._lineHeight = conf.lineHeight;
|
||||
this._emptySelectionClipboard = conf.emptySelectionClipboard;
|
||||
this._copyWithSyntaxHighlighting = conf.copyWithSyntaxHighlighting;
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._accessibilitySupport = options.get(EditorOption.accessibilitySupport);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
this._contentHeight = layoutInfo.contentHeight;
|
||||
this._fontInfo = options.get(EditorOption.fontInfo);
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);
|
||||
this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);
|
||||
|
||||
this._visibleTextArea = null;
|
||||
this._selections = [new Selection(1, 1, 1, 1)];
|
||||
@@ -143,7 +146,7 @@ export class TextAreaHandler extends ViewPart {
|
||||
this.textArea.setAttribute('autocapitalize', 'off');
|
||||
this.textArea.setAttribute('autocomplete', 'off');
|
||||
this.textArea.setAttribute('spellcheck', 'false');
|
||||
this.textArea.setAttribute('aria-label', conf.viewInfo.ariaLabel);
|
||||
this.textArea.setAttribute('aria-label', this._getAriaLabel(options));
|
||||
this.textArea.setAttribute('role', 'textbox');
|
||||
this.textArea.setAttribute('aria-multiline', 'true');
|
||||
this.textArea.setAttribute('aria-haspopup', 'false');
|
||||
@@ -280,6 +283,7 @@ export class TextAreaHandler extends ViewPart {
|
||||
const column = this._selections[0].startColumn;
|
||||
|
||||
this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent(
|
||||
'keyboard',
|
||||
new Range(lineNumber, column, lineNumber, column),
|
||||
viewEvents.VerticalRevealType.Simple,
|
||||
true,
|
||||
@@ -340,7 +344,7 @@ export class TextAreaHandler extends ViewPart {
|
||||
|
||||
private _getWordBeforePosition(position: Position): string {
|
||||
const lineContent = this._context.model.getLineContent(position.lineNumber);
|
||||
const wordSeparators = getMapForWordSeparators(this._context.configuration.editor.wordSeparators);
|
||||
const wordSeparators = getMapForWordSeparators(this._context.configuration.options.get(EditorOption.wordSeparators));
|
||||
|
||||
let column = position.column;
|
||||
let distance = 0;
|
||||
@@ -367,35 +371,33 @@ export class TextAreaHandler extends ViewPart {
|
||||
return '';
|
||||
}
|
||||
|
||||
private _getAriaLabel(options: IComputedEditorOptions): string {
|
||||
const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
|
||||
if (accessibilitySupport === AccessibilitySupport.Disabled) {
|
||||
return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press Alt+F1 for options.");
|
||||
}
|
||||
return options.get(EditorOption.ariaLabel);
|
||||
}
|
||||
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
const conf = this._context.configuration.editor;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
if (e.fontInfo) {
|
||||
this._fontInfo = conf.fontInfo;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this.textArea.setAttribute('aria-label', conf.viewInfo.ariaLabel);
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._contentLeft = conf.layoutInfo.contentLeft;
|
||||
this._contentWidth = conf.layoutInfo.contentWidth;
|
||||
this._contentHeight = conf.layoutInfo.contentHeight;
|
||||
}
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = conf.lineHeight;
|
||||
}
|
||||
if (e.accessibilitySupport) {
|
||||
this._accessibilitySupport = conf.accessibilitySupport;
|
||||
this._accessibilitySupport = options.get(EditorOption.accessibilitySupport);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
this._contentHeight = layoutInfo.contentHeight;
|
||||
this._fontInfo = options.get(EditorOption.fontInfo);
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);
|
||||
this._copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);
|
||||
this.textArea.setAttribute('aria-label', this._getAriaLabel(options));
|
||||
|
||||
if (e.hasChanged(EditorOption.accessibilitySupport)) {
|
||||
this._textAreaInput.writeScreenReaderContent('strategy changed');
|
||||
}
|
||||
if (e.emptySelectionClipboard) {
|
||||
this._emptySelectionClipboard = conf.emptySelectionClipboard;
|
||||
}
|
||||
if (e.copyWithSyntaxHighlighting) {
|
||||
this._copyWithSyntaxHighlighting = conf.copyWithSyntaxHighlighting;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -544,10 +546,12 @@ export class TextAreaHandler extends ViewPart {
|
||||
tac.setWidth(1);
|
||||
tac.setHeight(1);
|
||||
|
||||
if (this._context.configuration.editor.viewInfo.glyphMargin) {
|
||||
const options = this._context.configuration.options;
|
||||
|
||||
if (options.get(EditorOption.glyphMargin)) {
|
||||
tac.setClassName('monaco-editor-background textAreaCover ' + Margin.OUTER_CLASS_NAME);
|
||||
} else {
|
||||
if (this._context.configuration.editor.viewInfo.renderLineNumbers !== RenderLineNumbersType.Off) {
|
||||
if (options.get(EditorOption.lineNumbers).renderType !== RenderLineNumbersType.Off) {
|
||||
tac.setClassName('monaco-editor-background textAreaCover ' + LineNumbersOverlay.CLASS_NAME);
|
||||
} else {
|
||||
tac.setClassName('monaco-editor-background textAreaCover');
|
||||
|
||||
@@ -54,6 +54,11 @@ const enum TextAreaInputEventType {
|
||||
blur
|
||||
}
|
||||
|
||||
interface CompositionEvent extends UIEvent {
|
||||
readonly data: string;
|
||||
readonly locale: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes screen reader content to the textarea and is able to analyze its input events to generate:
|
||||
* - onCut
|
||||
|
||||
@@ -17,7 +17,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
const IEditorCancellationTokens = createDecorator<IEditorCancellationTokens>('IEditorCancelService');
|
||||
|
||||
interface IEditorCancellationTokens {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
add(editor: ICodeEditor, cts: CancellationTokenSource): () => void;
|
||||
cancel(editor: ICodeEditor): void;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ const ctxCancellableOperation = new RawContextKey('cancellableOperation', false)
|
||||
|
||||
registerSingleton(IEditorCancellationTokens, class implements IEditorCancellationTokens {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _tokens = new WeakMap<ICodeEditor, { key: IContextKey<boolean>, tokens: LinkedList<CancellationTokenSource> }>();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { IMouseEvent, IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { OverviewRulerPosition, ConfigurationChangedEvent, EditorLayoutInfo, IComputedEditorOptions, EditorOption, FindComputedEditorOptionValueById, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { ICursors } from 'vs/editor/common/controller/cursorCommon';
|
||||
import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
@@ -315,7 +315,7 @@ export interface IOverviewRuler {
|
||||
getDomNode(): HTMLElement;
|
||||
dispose(): void;
|
||||
setZones(zones: OverviewRulerZone[]): void;
|
||||
setLayout(position: editorOptions.OverviewRulerPosition): void;
|
||||
setLayout(position: OverviewRulerPosition): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,7 +351,7 @@ export interface ICodeEditor extends editorCommon.IEditor {
|
||||
* An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`)
|
||||
* @event
|
||||
*/
|
||||
onDidChangeConfiguration(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable;
|
||||
onDidChangeConfiguration(listener: (e: ConfigurationChangedEvent) => void): IDisposable;
|
||||
/**
|
||||
* An event emitted when the cursor position has changed.
|
||||
* @event
|
||||
@@ -481,7 +481,7 @@ export interface ICodeEditor extends editorCommon.IEditor {
|
||||
* An event emitted when the layout of the editor has changed.
|
||||
* @event
|
||||
*/
|
||||
onDidLayoutChange(listener: (e: editorOptions.EditorLayoutInfo) => void): IDisposable;
|
||||
onDidLayoutChange(listener: (e: EditorLayoutInfo) => void): IDisposable;
|
||||
/**
|
||||
* An event emitted when the scroll in the editor has changed.
|
||||
* @event
|
||||
@@ -532,15 +532,19 @@ export interface ICodeEditor extends editorCommon.IEditor {
|
||||
setModel(model: ITextModel | null): void;
|
||||
|
||||
/**
|
||||
* Returns the current editor's configuration
|
||||
*/
|
||||
getConfiguration(): editorOptions.InternalEditorOptions;
|
||||
|
||||
/**
|
||||
* Returns the 'raw' editor's configuration (without any validation or defaults).
|
||||
* @internal
|
||||
*/
|
||||
getRawConfiguration(): editorOptions.IEditorOptions;
|
||||
getOptions(): IComputedEditorOptions;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getOption<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
|
||||
|
||||
/**
|
||||
* Returns the editor's configuration (without any validation or defaults).
|
||||
*/
|
||||
getRawOptions(): IEditorOptions;
|
||||
|
||||
/**
|
||||
* Get value of the current model attached to this editor.
|
||||
@@ -655,7 +659,7 @@ export interface ICodeEditor extends editorCommon.IEditor {
|
||||
/**
|
||||
* Get the layout info for the editor.
|
||||
*/
|
||||
getLayoutInfo(): editorOptions.EditorLayoutInfo;
|
||||
getLayoutInfo(): EditorLayoutInfo;
|
||||
|
||||
/**
|
||||
* Returns the ranges that are currently visible.
|
||||
|
||||
@@ -13,7 +13,7 @@ import { IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
|
||||
export abstract class AbstractCodeEditorService extends Disposable implements ICodeEditorService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _onCodeEditorAdd: Emitter<ICodeEditor> = this._register(new Emitter<ICodeEditor>());
|
||||
public readonly onCodeEditorAdd: Event<ICodeEditor> = this._onCodeEditorAdd.event;
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface IBulkEditResult {
|
||||
}
|
||||
|
||||
export interface IBulkEditService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
apply(edit: WorkspaceEdit, options?: IBulkEditOptions): Promise<IBulkEditResult>;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
export const ICodeEditorService = createDecorator<ICodeEditorService>('codeEditorService');
|
||||
|
||||
export interface ICodeEditorService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
readonly onCodeEditorAdd: Event<ICodeEditor>;
|
||||
readonly onCodeEditorRemove: Event<ICodeEditor>;
|
||||
|
||||
@@ -13,12 +13,11 @@ import { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IOpener, IOpenerService, IValidator } from 'vs/platform/opener/common/opener';
|
||||
|
||||
export class OpenerService extends Disposable implements IOpenerService {
|
||||
|
||||
_serviceBrand!: ServiceIdentifier<any>;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _openers = new LinkedList<IOpener>();
|
||||
private readonly _validators = new LinkedList<IValidator>();
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IConfiguration } from 'vs/editor/common/editorCommon';
|
||||
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export interface IMouseDispatchData {
|
||||
position: Position;
|
||||
@@ -107,7 +108,7 @@ export class ViewController {
|
||||
}
|
||||
|
||||
private _hasMulticursorModifier(data: IMouseDispatchData): boolean {
|
||||
switch (this.configuration.editor.multiCursorModifier) {
|
||||
switch (this.configuration.options.get(EditorOption.multiCursorModifier)) {
|
||||
case 'altKey':
|
||||
return data.altKey;
|
||||
case 'ctrlKey':
|
||||
@@ -119,7 +120,7 @@ export class ViewController {
|
||||
}
|
||||
|
||||
private _hasNonMulticursorModifier(data: IMouseDispatchData): boolean {
|
||||
switch (this.configuration.editor.multiCursorModifier) {
|
||||
switch (this.configuration.options.get(EditorOption.multiCursorModifier)) {
|
||||
case 'altKey':
|
||||
return data.ctrlKey || data.metaKey;
|
||||
case 'ctrlKey':
|
||||
@@ -132,11 +133,7 @@ export class ViewController {
|
||||
|
||||
public dispatchMouse(data: IMouseDispatchData): void {
|
||||
if (data.middleButton) {
|
||||
if (data.inSelectionMode) {
|
||||
this._columnSelect(data.position, data.mouseColumn, true);
|
||||
} else {
|
||||
this.moveTo(data.position);
|
||||
}
|
||||
this._columnSelect(data.position, data.mouseColumn, data.inSelectionMode);
|
||||
} else if (data.startedOnLineNumbers) {
|
||||
// If the dragging started on the gutter, then have operations work on the entire line
|
||||
if (this._hasMulticursorModifier(data)) {
|
||||
@@ -182,7 +179,7 @@ export class ViewController {
|
||||
if (this._hasMulticursorModifier(data)) {
|
||||
if (!this._hasNonMulticursorModifier(data)) {
|
||||
if (data.shiftKey) {
|
||||
this._columnSelect(data.position, data.mouseColumn, false);
|
||||
this._columnSelect(data.position, data.mouseColumn, true);
|
||||
} else {
|
||||
// Do multi-cursor operations only when purely alt is pressed
|
||||
if (data.inSelectionMode) {
|
||||
@@ -222,13 +219,13 @@ export class ViewController {
|
||||
this._execMouseCommand(CoreNavigationCommands.MoveToSelect, this._usualArgs(viewPosition));
|
||||
}
|
||||
|
||||
private _columnSelect(viewPosition: Position, mouseColumn: number, setAnchorIfNotSet: boolean): void {
|
||||
private _columnSelect(viewPosition: Position, mouseColumn: number, doColumnSelect: boolean): void {
|
||||
viewPosition = this._validateViewColumn(viewPosition);
|
||||
this._execMouseCommand(CoreNavigationCommands.ColumnSelect, {
|
||||
position: this._convertViewToModelPosition(viewPosition),
|
||||
viewPosition: viewPosition,
|
||||
mouseColumn: mouseColumn,
|
||||
setAnchorIfNotSet: setAnchorIfNotSet
|
||||
doColumnSelect: doColumnSelect
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'
|
||||
import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler';
|
||||
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { IThemeService, getThemeTypeSelector } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export interface IContentWidgetData {
|
||||
widget: editorBrowser.IContentWidget;
|
||||
@@ -218,7 +220,7 @@ export class View extends ViewEventHandler {
|
||||
this.domNode.appendChild(this.overflowGuardContainer);
|
||||
this.domNode.appendChild(this.contentWidgets.overflowingContentWidgetsDomNode);
|
||||
|
||||
this._setLayout();
|
||||
this._applyLayout();
|
||||
|
||||
// Pointer handler
|
||||
this.pointerHandler = this._register(new PointerHandler(this._context, viewController, this.createPointerHandlerHelper()));
|
||||
@@ -280,8 +282,10 @@ export class View extends ViewEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
private _setLayout(): void {
|
||||
const layoutInfo = this._context.configuration.editor.layoutInfo;
|
||||
private _applyLayout(): void {
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this.domNode.setWidth(layoutInfo.width);
|
||||
this.domNode.setHeight(layoutInfo.height);
|
||||
|
||||
@@ -290,23 +294,18 @@ export class View extends ViewEventHandler {
|
||||
|
||||
this.linesContent.setWidth(1000000);
|
||||
this.linesContent.setHeight(1000000);
|
||||
|
||||
}
|
||||
|
||||
private getEditorClassName() {
|
||||
const focused = this._textAreaHandler.isFocused() ? ' focused' : '';
|
||||
return this._context.configuration.editor.editorClassName + ' ' + getThemeTypeSelector(this._context.theme.type) + focused;
|
||||
return this._context.configuration.options.get(EditorOption.editorClassName) + ' ' + getThemeTypeSelector(this._context.theme.type) + focused;
|
||||
}
|
||||
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.editorClassName) {
|
||||
this.domNode.setClassName(this.getEditorClassName());
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._setLayout();
|
||||
}
|
||||
this.domNode.setClassName(this.getEditorClassName());
|
||||
this._applyLayout();
|
||||
return false;
|
||||
}
|
||||
public onFocusChanged(e: viewEvents.ViewFocusChangedEvent): boolean {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { IStringBuilder, createStringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
/**
|
||||
* Represents a visible line
|
||||
@@ -269,7 +270,10 @@ export class VisibleLinesCollection<T extends IVisibleLine> {
|
||||
// ---- begin view event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
return e.layoutInfo;
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public onFlushed(e: viewEvents.ViewFlushedEvent): boolean {
|
||||
|
||||
@@ -14,6 +14,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class ViewOverlays extends ViewPart implements IVisibleLinesHost<ViewOverlayLine> {
|
||||
|
||||
@@ -147,7 +149,7 @@ export class ViewOverlayLine implements IVisibleLine {
|
||||
|
||||
constructor(configuration: IConfiguration, dynamicOverlays: DynamicViewOverlay[]) {
|
||||
this._configuration = configuration;
|
||||
this._lineHeight = this._configuration.editor.lineHeight;
|
||||
this._lineHeight = this._configuration.options.get(EditorOption.lineHeight);
|
||||
this._dynamicOverlays = dynamicOverlays;
|
||||
|
||||
this._domNode = null;
|
||||
@@ -171,9 +173,7 @@ export class ViewOverlayLine implements IVisibleLine {
|
||||
// Nothing
|
||||
}
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): void {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._configuration.editor.lineHeight;
|
||||
}
|
||||
this._lineHeight = this._configuration.options.get(EditorOption.lineHeight);
|
||||
}
|
||||
|
||||
public renderLine(lineNumber: number, deltaTop: number, viewportData: ViewportData, sb: IStringBuilder): boolean {
|
||||
@@ -215,8 +215,9 @@ export class ContentViewOverlays extends ViewOverlays {
|
||||
|
||||
constructor(context: ViewContext) {
|
||||
super(context);
|
||||
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
|
||||
this.domNode.setHeight(0);
|
||||
}
|
||||
@@ -224,10 +225,10 @@ export class ContentViewOverlays extends ViewOverlays {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.layoutInfo) {
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
}
|
||||
return super.onConfigurationChanged(e);
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
return super.onConfigurationChanged(e) || true;
|
||||
}
|
||||
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {
|
||||
return super.onScrollChanged(e) || e.scrollWidthChanged;
|
||||
@@ -249,25 +250,22 @@ export class MarginViewOverlays extends ViewOverlays {
|
||||
constructor(context: ViewContext) {
|
||||
super(context);
|
||||
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
|
||||
this.domNode.setClassName('margin-view-overlays');
|
||||
this.domNode.setWidth(1);
|
||||
|
||||
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
|
||||
Configuration.applyFontInfo(this.domNode, options.get(EditorOption.fontInfo));
|
||||
}
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
let shouldRender = false;
|
||||
if (e.fontInfo) {
|
||||
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
|
||||
shouldRender = true;
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
shouldRender = true;
|
||||
}
|
||||
return super.onConfigurationChanged(e) || shouldRender;
|
||||
const options = this._context.configuration.options;
|
||||
Configuration.applyFontInfo(this.domNode, options.get(EditorOption.fontInfo));
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
return super.onConfigurationChanged(e) || true;
|
||||
}
|
||||
|
||||
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {
|
||||
|
||||
@@ -14,6 +14,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
class Coordinate {
|
||||
_coordinateBrand: void;
|
||||
@@ -207,10 +209,13 @@ class Widget {
|
||||
this.allowEditorOverflow = this._actual.allowEditorOverflow || false;
|
||||
this.suppressMouseDown = this._actual.suppressMouseDown || false;
|
||||
|
||||
this._fixedOverflowWidgets = this._context.configuration.editor.viewInfo.fixedOverflowWidgets;
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._fixedOverflowWidgets = options.get(EditorOption.fixedOverflowWidgets);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
|
||||
this._position = null;
|
||||
this._range = null;
|
||||
@@ -230,12 +235,12 @@ class Widget {
|
||||
}
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): void {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
const options = this._context.configuration.options;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
this._maxWidth = this._getMaxWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,26 +10,33 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
|
||||
private readonly _context: ViewContext;
|
||||
private _lineHeight: number;
|
||||
private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
|
||||
private _contentWidth: number;
|
||||
private _selectionIsEmpty: boolean;
|
||||
private _primaryCursorLineNumber: number;
|
||||
private _scrollWidth: number;
|
||||
private _contentWidth: number;
|
||||
|
||||
constructor(context: ViewContext) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
|
||||
this._selectionIsEmpty = true;
|
||||
this._primaryCursorLineNumber = 1;
|
||||
this._scrollWidth = 0;
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
|
||||
|
||||
this._context.addEventHandler(this);
|
||||
}
|
||||
@@ -42,15 +49,12 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
return true;
|
||||
}
|
||||
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
|
||||
|
||||
@@ -10,24 +10,30 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
|
||||
private readonly _context: ViewContext;
|
||||
private _lineHeight: number;
|
||||
private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
|
||||
private _contentLeft: number;
|
||||
private _selectionIsEmpty: boolean;
|
||||
private _primaryCursorLineNumber: number;
|
||||
private _contentLeft: number;
|
||||
|
||||
constructor(context: ViewContext) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
|
||||
this._selectionIsEmpty = true;
|
||||
this._primaryCursorLineNumber = 1;
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
|
||||
this._context.addEventHandler(this);
|
||||
}
|
||||
@@ -40,15 +46,12 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._renderLineHighlight = this._context.configuration.editor.viewInfo.renderLineHighlight;
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
return true;
|
||||
}
|
||||
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { HorizontalRange, RenderingContext } from 'vs/editor/common/view/renderi
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class DecorationsOverlay extends DynamicViewOverlay {
|
||||
|
||||
@@ -21,8 +22,9 @@ export class DecorationsOverlay extends DynamicViewOverlay {
|
||||
constructor(context: ViewContext) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
const options = this._context.configuration.options;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
this._renderResult = null;
|
||||
|
||||
this._context.addEventHandler(this);
|
||||
@@ -37,12 +39,9 @@ export class DecorationsOverlay extends DynamicViewOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.fontInfo) {
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
return true;
|
||||
}
|
||||
public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { getThemeTypeSelector } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class EditorScrollbar extends ViewPart {
|
||||
|
||||
@@ -28,8 +29,11 @@ export class EditorScrollbar extends ViewPart {
|
||||
) {
|
||||
super(context);
|
||||
|
||||
const editor = this._context.configuration.editor;
|
||||
const configScrollbarOpts = editor.viewInfo.scrollbar;
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const scrollbar = options.get(EditorOption.scrollbar);
|
||||
const mouseWheelScrollSensitivity = options.get(EditorOption.mouseWheelScrollSensitivity);
|
||||
const fastScrollSensitivity = options.get(EditorOption.fastScrollSensitivity);
|
||||
|
||||
const scrollbarOptions: ScrollableElementCreationOptions = {
|
||||
listenOnDomNode: viewDomNode.domNode,
|
||||
@@ -37,18 +41,18 @@ export class EditorScrollbar extends ViewPart {
|
||||
useShadows: false,
|
||||
lazyRender: true,
|
||||
|
||||
vertical: configScrollbarOpts.vertical,
|
||||
horizontal: configScrollbarOpts.horizontal,
|
||||
verticalHasArrows: configScrollbarOpts.verticalHasArrows,
|
||||
horizontalHasArrows: configScrollbarOpts.horizontalHasArrows,
|
||||
verticalScrollbarSize: configScrollbarOpts.verticalScrollbarSize,
|
||||
verticalSliderSize: configScrollbarOpts.verticalSliderSize,
|
||||
horizontalScrollbarSize: configScrollbarOpts.horizontalScrollbarSize,
|
||||
horizontalSliderSize: configScrollbarOpts.horizontalSliderSize,
|
||||
handleMouseWheel: configScrollbarOpts.handleMouseWheel,
|
||||
arrowSize: configScrollbarOpts.arrowSize,
|
||||
mouseWheelScrollSensitivity: configScrollbarOpts.mouseWheelScrollSensitivity,
|
||||
fastScrollSensitivity: configScrollbarOpts.fastScrollSensitivity,
|
||||
vertical: scrollbar.vertical,
|
||||
horizontal: scrollbar.horizontal,
|
||||
verticalHasArrows: scrollbar.verticalHasArrows,
|
||||
horizontalHasArrows: scrollbar.horizontalHasArrows,
|
||||
verticalScrollbarSize: scrollbar.verticalScrollbarSize,
|
||||
verticalSliderSize: scrollbar.verticalSliderSize,
|
||||
horizontalScrollbarSize: scrollbar.horizontalScrollbarSize,
|
||||
horizontalSliderSize: scrollbar.horizontalSliderSize,
|
||||
handleMouseWheel: scrollbar.handleMouseWheel,
|
||||
arrowSize: scrollbar.arrowSize,
|
||||
mouseWheelScrollSensitivity: mouseWheelScrollSensitivity,
|
||||
fastScrollSensitivity: fastScrollSensitivity,
|
||||
};
|
||||
|
||||
this.scrollbar = this._register(new SmoothScrollableElement(linesContent.domNode, scrollbarOptions, this._context.viewLayout.scrollable));
|
||||
@@ -96,11 +100,13 @@ export class EditorScrollbar extends ViewPart {
|
||||
}
|
||||
|
||||
private _setLayout(): void {
|
||||
const layoutInfo = this._context.configuration.editor.layoutInfo;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this.scrollbarDomNode.setLeft(layoutInfo.contentLeft);
|
||||
|
||||
const side = this._context.configuration.editor.viewInfo.minimap.side;
|
||||
const minimap = options.get(EditorOption.minimap);
|
||||
const side = minimap.side;
|
||||
if (side === 'right') {
|
||||
this.scrollbarDomNode.setWidth(layoutInfo.contentWidth + layoutInfo.minimapWidth);
|
||||
} else {
|
||||
@@ -124,16 +130,23 @@ export class EditorScrollbar extends ViewPart {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.viewInfo) {
|
||||
const editor = this._context.configuration.editor;
|
||||
if (
|
||||
e.hasChanged(EditorOption.scrollbar)
|
||||
|| e.hasChanged(EditorOption.mouseWheelScrollSensitivity)
|
||||
|| e.hasChanged(EditorOption.fastScrollSensitivity)
|
||||
) {
|
||||
const options = this._context.configuration.options;
|
||||
const scrollbar = options.get(EditorOption.scrollbar);
|
||||
const mouseWheelScrollSensitivity = options.get(EditorOption.mouseWheelScrollSensitivity);
|
||||
const fastScrollSensitivity = options.get(EditorOption.fastScrollSensitivity);
|
||||
const newOpts: ScrollableElementChangeOptions = {
|
||||
handleMouseWheel: editor.viewInfo.scrollbar.handleMouseWheel,
|
||||
mouseWheelScrollSensitivity: editor.viewInfo.scrollbar.mouseWheelScrollSensitivity,
|
||||
fastScrollSensitivity: editor.viewInfo.scrollbar.fastScrollSensitivity
|
||||
handleMouseWheel: scrollbar.handleMouseWheel,
|
||||
mouseWheelScrollSensitivity: mouseWheelScrollSensitivity,
|
||||
fastScrollSensitivity: fastScrollSensitivity
|
||||
};
|
||||
this.scrollbar.updateOptions(newOpts);
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
this._setLayout();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -8,6 +8,8 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
|
||||
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class DecorationToRender {
|
||||
_decorationToRenderBrand: void;
|
||||
@@ -84,10 +86,14 @@ export class GlyphMarginOverlay extends DedupOverlay {
|
||||
constructor(context: ViewContext) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin;
|
||||
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._glyphMargin = options.get(EditorOption.glyphMargin);
|
||||
this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
|
||||
this._renderResult = null;
|
||||
this._context.addEventHandler(this);
|
||||
}
|
||||
@@ -101,16 +107,13 @@ export class GlyphMarginOverlay extends DedupOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin;
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._glyphMargin = options.get(EditorOption.glyphMargin);
|
||||
this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
|
||||
return true;
|
||||
}
|
||||
public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean {
|
||||
|
||||
@@ -11,6 +11,8 @@ import { RenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class IndentGuidesOverlay extends DynamicViewOverlay {
|
||||
|
||||
@@ -27,12 +29,16 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
|
||||
super();
|
||||
this._context = context;
|
||||
this._primaryLineNumber = 0;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth;
|
||||
this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides;
|
||||
this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide;
|
||||
const wrappingColumn = this._context.configuration.editor.wrappingInfo.wrappingColumn;
|
||||
this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth);
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._spaceWidth = fontInfo.spaceWidth;
|
||||
this._enabled = options.get(EditorOption.renderIndentGuides);
|
||||
this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide);
|
||||
this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth);
|
||||
|
||||
this._renderResult = null;
|
||||
|
||||
@@ -48,20 +54,15 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.fontInfo) {
|
||||
this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._enabled = this._context.configuration.editor.viewInfo.renderIndentGuides;
|
||||
this._activeIndentEnabled = this._context.configuration.editor.viewInfo.highlightActiveIndentGuide;
|
||||
}
|
||||
if (e.wrappingInfo || e.fontInfo) {
|
||||
const wrappingColumn = this._context.configuration.editor.wrappingInfo.wrappingColumn;
|
||||
this._maxIndentLeft = wrappingColumn === -1 ? -1 : (wrappingColumn * this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth);
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._spaceWidth = fontInfo.spaceWidth;
|
||||
this._enabled = options.get(EditorOption.renderIndentGuides);
|
||||
this._activeIndentEnabled = options.get(EditorOption.highlightActiveIndentGuide);
|
||||
this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth);
|
||||
return true;
|
||||
}
|
||||
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import 'vs/css!./lineNumbers';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
|
||||
import { RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
||||
import { RenderLineNumbersType, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { editorActiveLineNumber, editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
@@ -41,13 +41,15 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
|
||||
}
|
||||
|
||||
private _readConfig(): void {
|
||||
const config = this._context.configuration.editor;
|
||||
this._lineHeight = config.lineHeight;
|
||||
this._renderLineNumbers = config.viewInfo.renderLineNumbers;
|
||||
this._renderCustomLineNumbers = config.viewInfo.renderCustomLineNumbers;
|
||||
this._renderFinalNewline = config.viewInfo.renderFinalNewline;
|
||||
this._lineNumbersLeft = config.layoutInfo.lineNumbersLeft;
|
||||
this._lineNumbersWidth = config.layoutInfo.lineNumbersWidth;
|
||||
const options = this._context.configuration.options;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
const lineNumbers = options.get(EditorOption.lineNumbers);
|
||||
this._renderLineNumbers = lineNumbers.renderType;
|
||||
this._renderCustomLineNumbers = lineNumbers.renderFn;
|
||||
this._renderFinalNewline = options.get(EditorOption.renderFinalNewline);
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._lineNumbersLeft = layoutInfo.lineNumbersLeft;
|
||||
this._lineNumbersWidth = layoutInfo.lineNumbersWidth;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
@@ -16,6 +16,7 @@ import { CharacterMapping, ForeignElementType, RenderLineInput, renderViewLine,
|
||||
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
import { InlineDecorationType } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { HIGH_CONTRAST, ThemeType } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const canUseFastRenderedViewLine = (function () {
|
||||
if (platform.isNative) {
|
||||
@@ -80,17 +81,20 @@ export class ViewLineOptions {
|
||||
|
||||
constructor(config: IConfiguration, themeType: ThemeType) {
|
||||
this.themeType = themeType;
|
||||
this.renderWhitespace = config.editor.viewInfo.renderWhitespace;
|
||||
this.renderControlCharacters = config.editor.viewInfo.renderControlCharacters;
|
||||
this.spaceWidth = config.editor.fontInfo.spaceWidth;
|
||||
const options = config.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
this.renderWhitespace = options.get(EditorOption.renderWhitespace);
|
||||
this.renderControlCharacters = options.get(EditorOption.renderControlCharacters);
|
||||
this.spaceWidth = fontInfo.spaceWidth;
|
||||
this.useMonospaceOptimizations = (
|
||||
config.editor.fontInfo.isMonospace
|
||||
&& !config.editor.viewInfo.disableMonospaceOptimizations
|
||||
fontInfo.isMonospace
|
||||
&& !options.get(EditorOption.disableMonospaceOptimizations)
|
||||
&& !options.get(EditorOption.fontLigatures)
|
||||
);
|
||||
this.canUseHalfwidthRightwardsArrow = config.editor.fontInfo.canUseHalfwidthRightwardsArrow;
|
||||
this.lineHeight = config.editor.lineHeight;
|
||||
this.stopRenderingLineAfter = config.editor.viewInfo.stopRenderingLineAfter;
|
||||
this.fontLigatures = config.editor.viewInfo.fontLigatures;
|
||||
this.canUseHalfwidthRightwardsArrow = fontInfo.canUseHalfwidthRightwardsArrow;
|
||||
this.lineHeight = options.get(EditorOption.lineHeight);
|
||||
this.stopRenderingLineAfter = options.get(EditorOption.stopRenderingLineAfter);
|
||||
this.fontLigatures = options.get(EditorOption.fontLigatures);
|
||||
}
|
||||
|
||||
public equals(other: ViewLineOptions): boolean {
|
||||
|
||||
@@ -12,12 +12,14 @@ import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/v
|
||||
import { DomReadingContext, ViewLine, ViewLineOptions } from 'vs/editor/browser/viewParts/lines/viewLine';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { HorizontalRange, IViewLines, LineVisibleRanges } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
import { Viewport } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
class LastRenderedData {
|
||||
|
||||
@@ -71,7 +73,8 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
private _typicalHalfwidthCharacterWidth: number;
|
||||
private _isViewportWrapping: boolean;
|
||||
private _revealHorizontalRightPadding: number;
|
||||
private _scrollOff: number;
|
||||
private _selections: Selection[];
|
||||
private _cursorSurroundingLines: number;
|
||||
private _canUseLayerHinting: boolean;
|
||||
private _viewLineOptions: ViewLineOptions;
|
||||
|
||||
@@ -90,18 +93,22 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
this.domNode = this._visibleLines.domNode;
|
||||
|
||||
const conf = this._context.configuration;
|
||||
const options = this._context.configuration.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
|
||||
this._lineHeight = conf.editor.lineHeight;
|
||||
this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this._isViewportWrapping = conf.editor.wrappingInfo.isViewportWrapping;
|
||||
this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding;
|
||||
this._scrollOff = conf.editor.viewInfo.cursorSurroundingLines;
|
||||
this._canUseLayerHinting = conf.editor.canUseLayerHinting;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this._isViewportWrapping = wrappingInfo.isViewportWrapping;
|
||||
this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding);
|
||||
this._cursorSurroundingLines = options.get(EditorOption.cursorSurroundingLines);
|
||||
this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting);
|
||||
this._viewLineOptions = new ViewLineOptions(conf, this._context.theme.type);
|
||||
this._selections = [];
|
||||
|
||||
PartFingerprints.write(this.domNode, PartFingerprint.ViewLines);
|
||||
this.domNode.setClassName('view-lines');
|
||||
Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo);
|
||||
Configuration.applyFontInfo(this.domNode, fontInfo);
|
||||
|
||||
// --- width & height
|
||||
this._maxLineWidth = 0;
|
||||
@@ -135,35 +142,25 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
this._visibleLines.onConfigurationChanged(e);
|
||||
if (e.wrappingInfo) {
|
||||
if (e.hasChanged(EditorOption.wrappingInfo)) {
|
||||
this._maxLineWidth = 0;
|
||||
}
|
||||
|
||||
const conf = this._context.configuration;
|
||||
const options = this._context.configuration.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = conf.editor.lineHeight;
|
||||
}
|
||||
if (e.fontInfo) {
|
||||
this._typicalHalfwidthCharacterWidth = conf.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
}
|
||||
if (e.wrappingInfo) {
|
||||
this._isViewportWrapping = conf.editor.wrappingInfo.isViewportWrapping;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._revealHorizontalRightPadding = conf.editor.viewInfo.revealHorizontalRightPadding;
|
||||
this._scrollOff = conf.editor.viewInfo.cursorSurroundingLines;
|
||||
}
|
||||
if (e.canUseLayerHinting) {
|
||||
this._canUseLayerHinting = conf.editor.canUseLayerHinting;
|
||||
}
|
||||
if (e.fontInfo) {
|
||||
Configuration.applyFontInfo(this.domNode, conf.editor.fontInfo);
|
||||
}
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this._isViewportWrapping = wrappingInfo.isViewportWrapping;
|
||||
this._revealHorizontalRightPadding = options.get(EditorOption.revealHorizontalRightPadding);
|
||||
this._cursorSurroundingLines = options.get(EditorOption.cursorSurroundingLines);
|
||||
this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting);
|
||||
Configuration.applyFontInfo(this.domNode, fontInfo);
|
||||
|
||||
this._onOptionsMaybeChanged();
|
||||
|
||||
if (e.layoutInfo) {
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
this._maxLineWidth = 0;
|
||||
}
|
||||
|
||||
@@ -188,6 +185,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
return false;
|
||||
}
|
||||
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
|
||||
this._selections = e.selections;
|
||||
const rendStartLineNumber = this._visibleLines.getStartLineNumber();
|
||||
const rendEndLineNumber = this._visibleLines.getEndLineNumber();
|
||||
let r = false;
|
||||
@@ -223,7 +221,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
public onRevealRangeRequest(e: viewEvents.ViewRevealRangeRequestEvent): boolean {
|
||||
// Using the future viewport here in order to handle multiple
|
||||
// incoming reveal range requests that might all desire to be animated
|
||||
const desiredScrollTop = this._computeScrollTopToRevealRange(this._context.viewLayout.getFutureViewport(), e.range, e.verticalType);
|
||||
const desiredScrollTop = this._computeScrollTopToRevealRange(this._context.viewLayout.getFutureViewport(), e.source, e.range, e.verticalType);
|
||||
|
||||
// validate the new desired scroll top
|
||||
let newScrollPosition = this._context.viewLayout.validateScrollPosition({ scrollTop: desiredScrollTop });
|
||||
@@ -589,7 +587,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
}
|
||||
}
|
||||
|
||||
private _computeScrollTopToRevealRange(viewport: Viewport, range: Range, verticalType: viewEvents.VerticalRevealType): number {
|
||||
private _computeScrollTopToRevealRange(viewport: Viewport, source: string, range: Range, verticalType: viewEvents.VerticalRevealType): number {
|
||||
const viewportStartY = viewport.top;
|
||||
const viewportHeight = viewport.height;
|
||||
const viewportEndY = viewportStartY + viewportHeight;
|
||||
@@ -600,9 +598,16 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
|
||||
boxStartY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.startLineNumber);
|
||||
boxEndY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.endLineNumber) + this._lineHeight;
|
||||
|
||||
const context = Math.min((viewportHeight / this._lineHeight) / 2, this._scrollOff);
|
||||
boxStartY -= context * this._lineHeight;
|
||||
boxEndY += Math.max(0, (context - 1)) * this._lineHeight;
|
||||
const shouldIgnoreScrollOff = source === 'mouse' && (
|
||||
this._selections.length > 1 // scroll off might trigger scrolling and mess up with multi cursor
|
||||
|| (this._selections.length > 0 && this._selections[0].isEmpty()) // we don't want to single click triggering selection
|
||||
);
|
||||
|
||||
if (!shouldIgnoreScrollOff) {
|
||||
const context = Math.min((viewportHeight / this._lineHeight) / 2, this._cursorSurroundingLines);
|
||||
boxStartY -= context * this._lineHeight;
|
||||
boxEndY += Math.max(0, (context - 1)) * this._lineHeight;
|
||||
}
|
||||
|
||||
if (verticalType === viewEvents.VerticalRevealType.Simple || verticalType === viewEvents.VerticalRevealType.Bottom) {
|
||||
// Reveal one line more when the last line would be covered by the scrollbar - arrow down case or revealing a line explicitly at bottom
|
||||
|
||||
@@ -8,6 +8,8 @@ import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/gl
|
||||
import { RenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class LinesDecorationsOverlay extends DedupOverlay {
|
||||
|
||||
@@ -20,8 +22,10 @@ export class LinesDecorationsOverlay extends DedupOverlay {
|
||||
constructor(context: ViewContext) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._decorationsLeft = this._context.configuration.editor.layoutInfo.decorationsLeft;
|
||||
this._decorationsWidth = this._context.configuration.editor.layoutInfo.decorationsWidth;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._decorationsLeft = layoutInfo.decorationsLeft;
|
||||
this._decorationsWidth = layoutInfo.decorationsWidth;
|
||||
this._renderResult = null;
|
||||
this._context.addEventHandler(this);
|
||||
}
|
||||
@@ -35,10 +39,10 @@ export class LinesDecorationsOverlay extends DedupOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.layoutInfo) {
|
||||
this._decorationsLeft = this._context.configuration.editor.layoutInfo.decorationsLeft;
|
||||
this._decorationsWidth = this._context.configuration.editor.layoutInfo.decorationsWidth;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._decorationsLeft = layoutInfo.decorationsLeft;
|
||||
this._decorationsWidth = layoutInfo.decorationsWidth;
|
||||
return true;
|
||||
}
|
||||
public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean {
|
||||
@@ -107,4 +111,4 @@ export class LinesDecorationsOverlay extends DedupOverlay {
|
||||
}
|
||||
return this._renderResult[lineNumber - startLineNumber];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import { ViewPart } from 'vs/editor/browser/view/viewPart';
|
||||
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class Margin extends ViewPart {
|
||||
|
||||
@@ -23,10 +25,13 @@ export class Margin extends ViewPart {
|
||||
|
||||
constructor(context: ViewContext) {
|
||||
super(context);
|
||||
this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting;
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
|
||||
|
||||
this._domNode = createFastDomNode(document.createElement('div'));
|
||||
this._domNode.setClassName(Margin.OUTER_CLASS_NAME);
|
||||
@@ -51,15 +56,13 @@ export class Margin extends ViewPart {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.canUseLayerHinting) {
|
||||
this._canUseLayerHinting = this._context.configuration.editor.canUseLayerHinting;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
if (e.layoutInfo) {
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
|
||||
}
|
||||
this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting);
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
|
||||
this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import * as platform from 'vs/base/common/platform';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ILine, RenderedLinesCollection } from 'vs/editor/browser/view/viewLayer';
|
||||
import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/view/viewPart';
|
||||
import { RenderMinimap } from 'vs/editor/common/config/editorOptions';
|
||||
import { RenderMinimap, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { RGBA8 } from 'vs/editor/common/core/rgba';
|
||||
import { IConfiguration, ScrollType } from 'vs/editor/common/editorCommon';
|
||||
@@ -23,10 +23,12 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { getOrCreateMinimapCharRenderer } from 'vs/editor/common/view/runtimeMinimapCharRenderer';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ViewLineData, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { scrollbarShadow, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ViewLineData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { scrollbarShadow, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, minimapSelection } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { ModelDecorationMinimapOptions } from 'vs/editor/common/model/textModel';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
|
||||
function getMinimapLineHeight(renderMinimap: RenderMinimap): number {
|
||||
if (renderMinimap === RenderMinimap.Large) {
|
||||
@@ -107,17 +109,18 @@ class MinimapOptions {
|
||||
public readonly canvasOuterHeight: number;
|
||||
|
||||
constructor(configuration: IConfiguration) {
|
||||
const pixelRatio = configuration.editor.pixelRatio;
|
||||
const layoutInfo = configuration.editor.layoutInfo;
|
||||
const viewInfo = configuration.editor.viewInfo;
|
||||
const fontInfo = configuration.editor.fontInfo;
|
||||
const options = configuration.options;
|
||||
const pixelRatio = options.get(EditorOption.pixelRatio);
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
this.renderMinimap = layoutInfo.renderMinimap | 0;
|
||||
this.scrollBeyondLastLine = viewInfo.scrollBeyondLastLine;
|
||||
this.showSlider = viewInfo.minimap.showSlider;
|
||||
this.scrollBeyondLastLine = options.get(EditorOption.scrollBeyondLastLine);
|
||||
const minimapOpts = options.get(EditorOption.minimap);
|
||||
this.showSlider = minimapOpts.showSlider;
|
||||
this.pixelRatio = pixelRatio;
|
||||
this.typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this.lineHeight = configuration.editor.lineHeight;
|
||||
this.lineHeight = options.get(EditorOption.lineHeight);
|
||||
this.minimapLeft = layoutInfo.minimapLeft;
|
||||
this.minimapWidth = layoutInfo.minimapWidth;
|
||||
this.minimapHeight = layoutInfo.height;
|
||||
@@ -451,7 +454,8 @@ export class Minimap extends ViewPart {
|
||||
|
||||
private _options: MinimapOptions;
|
||||
private _lastRenderData: RenderData | null;
|
||||
private _lastDecorations: ViewModelDecoration[] | undefined;
|
||||
private _selections: Selection[] = [];
|
||||
private _selectionColor: Color | undefined;
|
||||
private _renderDecorations: boolean = false;
|
||||
private _buffers: MinimapBuffers | null;
|
||||
|
||||
@@ -461,6 +465,7 @@ export class Minimap extends ViewPart {
|
||||
this._options = new MinimapOptions(this._context.configuration);
|
||||
this._lastRenderData = null;
|
||||
this._buffers = null;
|
||||
this._selectionColor = this._context.theme.getColor(minimapSelection);
|
||||
|
||||
this._domNode = createFastDomNode(document.createElement('div'));
|
||||
PartFingerprints.write(this._domNode, PartFingerprint.Minimap);
|
||||
@@ -517,6 +522,7 @@ export class Minimap extends ViewPart {
|
||||
lineNumber = Math.min(lineNumber, this._context.model.getLineCount());
|
||||
|
||||
this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent(
|
||||
'mouse',
|
||||
new Range(lineNumber, 1, lineNumber, 1),
|
||||
viewEvents.VerticalRevealType.Center,
|
||||
false,
|
||||
@@ -629,6 +635,11 @@ export class Minimap extends ViewPart {
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
return this._onOptionsMaybeChanged();
|
||||
}
|
||||
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
|
||||
this._selections = e.selections;
|
||||
this._renderDecorations = true;
|
||||
return true;
|
||||
}
|
||||
public onFlushed(e: viewEvents.ViewFlushedEvent): boolean {
|
||||
this._lastRenderData = null;
|
||||
return true;
|
||||
@@ -678,9 +689,9 @@ export class Minimap extends ViewPart {
|
||||
|
||||
public onThemeChanged(e: viewEvents.ViewThemeChangedEvent): boolean {
|
||||
this._context.model.invalidateMinimapColorCache();
|
||||
// Only bother calling render if decorations are currently shown
|
||||
this._renderDecorations = !!this._lastDecorations;
|
||||
return !!this._lastDecorations;
|
||||
this._selectionColor = this._context.theme.getColor(minimapSelection);
|
||||
this._renderDecorations = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- end event handlers
|
||||
@@ -742,8 +753,16 @@ export class Minimap extends ViewPart {
|
||||
|
||||
canvasContext.clearRect(0, 0, canvasInnerWidth, canvasInnerHeight);
|
||||
|
||||
// Loop over decorations, ignoring those that don't have the minimap property set and rendering rectangles for each line the decoration spans
|
||||
const lineOffsetMap = new Map<number, number[]>();
|
||||
for (let i = 0; i < this._selections.length; i++) {
|
||||
const selection = this._selections[i];
|
||||
|
||||
for (let line = selection.startLineNumber; line <= selection.endLineNumber; line++) {
|
||||
this.renderDecorationOnLine(canvasContext, lineOffsetMap, selection, this._selectionColor, layout, line, lineHeight, lineHeight, tabSize, characterWidth);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over decorations, ignoring those that don't have the minimap property set and rendering rectangles for each line the decoration spans
|
||||
for (let i = 0; i < decorations.length; i++) {
|
||||
const decoration = decorations[i];
|
||||
|
||||
@@ -752,17 +771,17 @@ export class Minimap extends ViewPart {
|
||||
}
|
||||
|
||||
for (let line = decoration.range.startLineNumber; line <= decoration.range.endLineNumber; line++) {
|
||||
this.renderDecorationOnLine(canvasContext, lineOffsetMap, decoration, layout, line, lineHeight, lineHeight, tabSize, characterWidth);
|
||||
const decorationColor = (<ModelDecorationMinimapOptions>decoration.options.minimap).getColor(this._context.theme);
|
||||
this.renderDecorationOnLine(canvasContext, lineOffsetMap, decoration.range, decorationColor, layout, line, lineHeight, lineHeight, tabSize, characterWidth);
|
||||
}
|
||||
}
|
||||
|
||||
this._lastDecorations = decorations;
|
||||
}
|
||||
}
|
||||
|
||||
private renderDecorationOnLine(canvasContext: CanvasRenderingContext2D,
|
||||
lineOffsetMap: Map<number, number[]>,
|
||||
decoration: ViewModelDecoration,
|
||||
decorationRange: Range,
|
||||
decorationColor: Color | undefined,
|
||||
layout: MinimapLayout,
|
||||
lineNumber: number,
|
||||
height: number,
|
||||
@@ -791,7 +810,7 @@ export class Minimap extends ViewPart {
|
||||
lineOffsetMap.set(lineNumber, lineIndexToXOffset);
|
||||
}
|
||||
|
||||
const { startColumn, endColumn, startLineNumber, endLineNumber } = decoration.range;
|
||||
const { startColumn, endColumn, startLineNumber, endLineNumber } = decorationRange;
|
||||
const x = startLineNumber === lineNumber ? lineIndexToXOffset[startColumn - 1] : 0;
|
||||
|
||||
const endColumnForLine = endLineNumber > lineNumber ? lineIndexToXOffset.length - 1 : endColumn - 1;
|
||||
@@ -800,24 +819,21 @@ export class Minimap extends ViewPart {
|
||||
// If the decoration starts at the last character of the column and spans over it, ensure it has a width
|
||||
const width = lineIndexToXOffset[endColumnForLine] - x || 2;
|
||||
|
||||
this.renderDecoration(canvasContext, <ModelDecorationMinimapOptions>decoration.options.minimap, x, y, width, height);
|
||||
this.renderDecoration(canvasContext, decorationColor, x, y, width, height);
|
||||
}
|
||||
|
||||
if (isFirstDecorationForLine) {
|
||||
this.renderLineHighlight(canvasContext, <ModelDecorationMinimapOptions>decoration.options.minimap, y, height);
|
||||
this.renderLineHighlight(canvasContext, decorationColor, y, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private renderLineHighlight(canvasContext: CanvasRenderingContext2D, minimapOptions: ModelDecorationMinimapOptions, y: number, height: number): void {
|
||||
const decorationColor = minimapOptions.getColor(this._context.theme);
|
||||
private renderLineHighlight(canvasContext: CanvasRenderingContext2D, decorationColor: Color | undefined, y: number, height: number): void {
|
||||
canvasContext.fillStyle = decorationColor && decorationColor.transparent(0.5).toString() || '';
|
||||
canvasContext.fillRect(0, y, canvasContext.canvas.width, height);
|
||||
}
|
||||
|
||||
private renderDecoration(canvasContext: CanvasRenderingContext2D, minimapOptions: ModelDecorationMinimapOptions, x: number, y: number, width: number, height: number) {
|
||||
const decorationColor = minimapOptions.getColor(this._context.theme);
|
||||
|
||||
private renderDecoration(canvasContext: CanvasRenderingContext2D, decorationColor: Color | undefined, x: number, y: number, width: number, height: number) {
|
||||
canvasContext.fillStyle = decorationColor && decorationColor.toString() || '';
|
||||
canvasContext.fillRect(x, y, width, height);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import { PartFingerprint, PartFingerprints, ViewPart } from 'vs/editor/browser/v
|
||||
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
interface IWidgetData {
|
||||
widget: IOverlayWidget;
|
||||
@@ -35,12 +37,15 @@ export class ViewOverlayWidgets extends ViewPart {
|
||||
constructor(context: ViewContext) {
|
||||
super(context);
|
||||
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._widgets = {};
|
||||
this._verticalScrollbarWidth = this._context.configuration.editor.layoutInfo.verticalScrollbarWidth;
|
||||
this._minimapWidth = this._context.configuration.editor.layoutInfo.minimapWidth;
|
||||
this._horizontalScrollbarHeight = this._context.configuration.editor.layoutInfo.horizontalScrollbarHeight;
|
||||
this._editorHeight = this._context.configuration.editor.layoutInfo.height;
|
||||
this._editorWidth = this._context.configuration.editor.layoutInfo.width;
|
||||
this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth;
|
||||
this._minimapWidth = layoutInfo.minimapWidth;
|
||||
this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight;
|
||||
this._editorHeight = layoutInfo.height;
|
||||
this._editorWidth = layoutInfo.width;
|
||||
|
||||
this._domNode = createFastDomNode(document.createElement('div'));
|
||||
PartFingerprints.write(this._domNode, PartFingerprint.OverlayWidgets);
|
||||
@@ -59,15 +64,15 @@ export class ViewOverlayWidgets extends ViewPart {
|
||||
// ---- begin view event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.layoutInfo) {
|
||||
this._verticalScrollbarWidth = this._context.configuration.editor.layoutInfo.verticalScrollbarWidth;
|
||||
this._minimapWidth = this._context.configuration.editor.layoutInfo.minimapWidth;
|
||||
this._horizontalScrollbarHeight = this._context.configuration.editor.layoutInfo.horizontalScrollbarHeight;
|
||||
this._editorHeight = this._context.configuration.editor.layoutInfo.height;
|
||||
this._editorWidth = this._context.configuration.editor.layoutInfo.width;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth;
|
||||
this._minimapWidth = layoutInfo.minimapWidth;
|
||||
this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight;
|
||||
this._editorHeight = layoutInfo.height;
|
||||
this._editorWidth = layoutInfo.width;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---- end view event handlers
|
||||
|
||||
@@ -15,6 +15,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { ITheme } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
class Settings {
|
||||
|
||||
@@ -42,22 +43,24 @@ class Settings {
|
||||
public readonly w: number[];
|
||||
|
||||
constructor(config: IConfiguration, theme: ITheme) {
|
||||
this.lineHeight = config.editor.lineHeight;
|
||||
this.pixelRatio = config.editor.pixelRatio;
|
||||
this.overviewRulerLanes = config.editor.viewInfo.overviewRulerLanes;
|
||||
const options = config.options;
|
||||
this.lineHeight = options.get(EditorOption.lineHeight);
|
||||
this.pixelRatio = options.get(EditorOption.pixelRatio);
|
||||
this.overviewRulerLanes = options.get(EditorOption.overviewRulerLanes);
|
||||
|
||||
this.renderBorder = config.editor.viewInfo.overviewRulerBorder;
|
||||
this.renderBorder = options.get(EditorOption.overviewRulerBorder);
|
||||
const borderColor = theme.getColor(editorOverviewRulerBorder);
|
||||
this.borderColor = borderColor ? borderColor.toString() : null;
|
||||
|
||||
this.hideCursor = config.editor.viewInfo.hideCursorInOverviewRuler;
|
||||
this.hideCursor = options.get(EditorOption.hideCursorInOverviewRuler);
|
||||
const cursorColor = theme.getColor(editorCursorForeground);
|
||||
this.cursorColor = cursorColor ? cursorColor.transparent(0.7).toString() : null;
|
||||
|
||||
this.themeType = theme.type;
|
||||
|
||||
const minimapEnabled = config.editor.viewInfo.minimap.enabled;
|
||||
const minimapSide = config.editor.viewInfo.minimap.side;
|
||||
const minimapOpts = options.get(EditorOption.minimap);
|
||||
const minimapEnabled = minimapOpts.enabled;
|
||||
const minimapSide = minimapOpts.side;
|
||||
const backgroundColor = (minimapEnabled ? TokenizationRegistry.getDefaultBackground() : null);
|
||||
if (backgroundColor === null || minimapSide === 'left') {
|
||||
this.backgroundColor = null;
|
||||
@@ -65,7 +68,8 @@ class Settings {
|
||||
this.backgroundColor = Color.Format.CSS.formatHex(backgroundColor);
|
||||
}
|
||||
|
||||
const position = config.editor.layoutInfo.overviewRuler;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
const position = layoutInfo.overviewRuler;
|
||||
this.top = position.top;
|
||||
this.right = position.right;
|
||||
this.domWidth = position.width;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { IOverviewRuler } from 'vs/editor/browser/editorBrowser';
|
||||
import { OverviewRulerPosition } from 'vs/editor/common/config/editorOptions';
|
||||
import { OverviewRulerPosition, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { ColorZone, OverviewRulerZone, OverviewZoneManager } from 'vs/editor/common/view/overviewZoneManager';
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
@@ -20,6 +20,7 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler {
|
||||
constructor(context: ViewContext, cssClassName: string) {
|
||||
super();
|
||||
this._context = context;
|
||||
const options = this._context.configuration.options;
|
||||
|
||||
this._domNode = createFastDomNode(document.createElement('canvas'));
|
||||
this._domNode.setClassName(cssClassName);
|
||||
@@ -30,9 +31,9 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler {
|
||||
this._zoneManager.setDOMWidth(0);
|
||||
this._zoneManager.setDOMHeight(0);
|
||||
this._zoneManager.setOuterHeight(this._context.viewLayout.getScrollHeight());
|
||||
this._zoneManager.setLineHeight(this._context.configuration.editor.lineHeight);
|
||||
this._zoneManager.setLineHeight(options.get(EditorOption.lineHeight));
|
||||
|
||||
this._zoneManager.setPixelRatio(this._context.configuration.editor.pixelRatio);
|
||||
this._zoneManager.setPixelRatio(options.get(EditorOption.pixelRatio));
|
||||
|
||||
this._context.addEventHandler(this);
|
||||
}
|
||||
@@ -45,13 +46,15 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler {
|
||||
// ---- begin view event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._zoneManager.setLineHeight(this._context.configuration.editor.lineHeight);
|
||||
const options = this._context.configuration.options;
|
||||
|
||||
if (e.hasChanged(EditorOption.lineHeight)) {
|
||||
this._zoneManager.setLineHeight(options.get(EditorOption.lineHeight));
|
||||
this._render();
|
||||
}
|
||||
|
||||
if (e.pixelRatio) {
|
||||
this._zoneManager.setPixelRatio(this._context.configuration.editor.pixelRatio);
|
||||
if (e.hasChanged(EditorOption.pixelRatio)) {
|
||||
this._zoneManager.setPixelRatio(options.get(EditorOption.pixelRatio));
|
||||
this._domNode.setWidth(this._zoneManager.getDOMWidth());
|
||||
this._domNode.setHeight(this._zoneManager.getDOMHeight());
|
||||
this._domNode.domNode.width = this._zoneManager.getCanvasWidth();
|
||||
|
||||
@@ -11,6 +11,7 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class Rulers extends ViewPart {
|
||||
|
||||
@@ -26,8 +27,9 @@ export class Rulers extends ViewPart {
|
||||
this.domNode.setAttribute('aria-hidden', 'true');
|
||||
this.domNode.setClassName('view-rulers');
|
||||
this._renderedRulers = [];
|
||||
this._rulers = this._context.configuration.editor.viewInfo.rulers;
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
const options = this._context.configuration.options;
|
||||
this._rulers = options.get(EditorOption.rulers);
|
||||
this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
@@ -37,12 +39,10 @@ export class Rulers extends ViewPart {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.viewInfo || e.layoutInfo || e.fontInfo) {
|
||||
this._rulers = this._context.configuration.editor.viewInfo.rulers;
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
const options = this._context.configuration.options;
|
||||
this._rulers = options.get(EditorOption.rulers);
|
||||
this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
return true;
|
||||
}
|
||||
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {
|
||||
return e.scrollHeightChanged;
|
||||
|
||||
@@ -11,6 +11,8 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export class ScrollDecorationViewPart extends ViewPart {
|
||||
|
||||
@@ -27,7 +29,9 @@ export class ScrollDecorationViewPart extends ViewPart {
|
||||
this._width = 0;
|
||||
this._updateWidth();
|
||||
this._shouldShow = false;
|
||||
this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows;
|
||||
const options = this._context.configuration.options;
|
||||
const scrollbar = options.get(EditorOption.scrollbar);
|
||||
this._useShadows = scrollbar.useShadows;
|
||||
this._domNode = createFastDomNode(document.createElement('div'));
|
||||
this._domNode.setAttribute('role', 'presentation');
|
||||
this._domNode.setAttribute('aria-hidden', 'true');
|
||||
@@ -50,32 +54,26 @@ export class ScrollDecorationViewPart extends ViewPart {
|
||||
return this._domNode;
|
||||
}
|
||||
|
||||
private _updateWidth(): boolean {
|
||||
const layoutInfo = this._context.configuration.editor.layoutInfo;
|
||||
let newWidth = 0;
|
||||
private _updateWidth(): void {
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
if (layoutInfo.renderMinimap === 0 || (layoutInfo.minimapWidth > 0 && layoutInfo.minimapLeft === 0)) {
|
||||
newWidth = layoutInfo.width;
|
||||
this._width = layoutInfo.width;
|
||||
} else {
|
||||
newWidth = layoutInfo.width - layoutInfo.minimapWidth - layoutInfo.verticalScrollbarWidth;
|
||||
this._width = layoutInfo.width - layoutInfo.minimapWidth - layoutInfo.verticalScrollbarWidth;
|
||||
}
|
||||
if (this._width !== newWidth) {
|
||||
this._width = newWidth;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
let shouldRender = false;
|
||||
if (e.viewInfo) {
|
||||
this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows;
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
shouldRender = this._updateWidth();
|
||||
}
|
||||
return this._updateShouldShow() || shouldRender;
|
||||
const options = this._context.configuration.options;
|
||||
const scrollbar = options.get(EditorOption.scrollbar);
|
||||
this._useShadows = scrollbar.useShadows;
|
||||
this._updateWidth();
|
||||
this._updateShouldShow();
|
||||
return true;
|
||||
}
|
||||
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {
|
||||
this._scrollTop = e.scrollTop;
|
||||
@@ -99,4 +97,4 @@ registerThemingParticipant((theme, collector) => {
|
||||
if (shadow) {
|
||||
collector.addRule(`.monaco-editor .scroll-decoration { box-shadow: ${shadow} 0 6px 6px -6px inset; }`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { editorInactiveSelection, editorSelectionBackground, editorSelectionForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const enum CornerStyle {
|
||||
EXTERN,
|
||||
@@ -83,9 +84,10 @@ export class SelectionsOverlay extends DynamicViewOverlay {
|
||||
constructor(context: ViewContext) {
|
||||
super();
|
||||
this._context = context;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection;
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
const options = this._context.configuration.options;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._roundedSelection = options.get(EditorOption.roundedSelection);
|
||||
this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
this._selections = [];
|
||||
this._renderResult = null;
|
||||
this._context.addEventHandler(this);
|
||||
@@ -100,15 +102,10 @@ export class SelectionsOverlay extends DynamicViewOverlay {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection;
|
||||
}
|
||||
if (e.fontInfo) {
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._roundedSelection = options.get(EditorOption.roundedSelection);
|
||||
this._typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
return true;
|
||||
}
|
||||
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
|
||||
@@ -420,4 +417,4 @@ registerThemingParticipant((theme, collector) => {
|
||||
|
||||
function abs(n: number): number {
|
||||
return n < 0 ? -n : n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as dom from 'vs/base/browser/dom';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { Configuration } from 'vs/editor/browser/config/configuration';
|
||||
import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
|
||||
import { TextEditorCursorStyle, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
@@ -51,11 +51,13 @@ export class ViewCursor {
|
||||
|
||||
constructor(context: ViewContext) {
|
||||
this._context = context;
|
||||
const options = this._context.configuration.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this._lineCursorWidth = Math.min(this._context.configuration.editor.viewInfo.cursorWidth, this._typicalHalfwidthCharacterWidth);
|
||||
this._cursorStyle = options.get(EditorOption.cursorStyle);
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth);
|
||||
|
||||
this._isVisible = true;
|
||||
|
||||
@@ -65,7 +67,7 @@ export class ViewCursor {
|
||||
this._domNode.setHeight(this._lineHeight);
|
||||
this._domNode.setTop(0);
|
||||
this._domNode.setLeft(0);
|
||||
Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo);
|
||||
Configuration.applyFontInfo(this._domNode, fontInfo);
|
||||
this._domNode.setDisplay('none');
|
||||
|
||||
this._position = new Position(1, 1);
|
||||
@@ -97,17 +99,14 @@ export class ViewCursor {
|
||||
}
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
}
|
||||
if (e.fontInfo) {
|
||||
Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo);
|
||||
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
|
||||
this._lineCursorWidth = Math.min(this._context.configuration.editor.viewInfo.cursorWidth, this._typicalHalfwidthCharacterWidth);
|
||||
}
|
||||
const options = this._context.configuration.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
this._cursorStyle = options.get(EditorOption.cursorStyle);
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
|
||||
this._lineCursorWidth = Math.min(options.get(EditorOption.cursorWidth), this._typicalHalfwidthCharacterWidth);
|
||||
Configuration.applyFontInfo(this._domNode, fontInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { IntervalTimer, TimeoutTimer } from 'vs/base/common/async';
|
||||
import { ViewPart } from 'vs/editor/browser/view/viewPart';
|
||||
import { IViewCursorRenderData, ViewCursor } from 'vs/editor/browser/viewParts/viewCursors/viewCursor';
|
||||
import { TextEditorCursorBlinkingStyle, TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
|
||||
import { TextEditorCursorBlinkingStyle, TextEditorCursorStyle, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { editorCursorBackground, editorCursorForeground } from 'vs/editor/common/view/editorColorRegistry';
|
||||
import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
|
||||
@@ -43,10 +43,11 @@ export class ViewCursors extends ViewPart {
|
||||
constructor(context: ViewContext) {
|
||||
super(context);
|
||||
|
||||
this._readOnly = this._context.configuration.editor.readOnly;
|
||||
this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking;
|
||||
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
|
||||
this._cursorSmoothCaretAnimation = this._context.configuration.editor.viewInfo.cursorSmoothCaretAnimation;
|
||||
const options = this._context.configuration.options;
|
||||
this._readOnly = options.get(EditorOption.readOnly);
|
||||
this._cursorBlinking = options.get(EditorOption.cursorBlinking);
|
||||
this._cursorStyle = options.get(EditorOption.cursorStyle);
|
||||
this._cursorSmoothCaretAnimation = options.get(EditorOption.cursorSmoothCaretAnimation);
|
||||
this._selectionIsEmpty = true;
|
||||
|
||||
this._isVisible = false;
|
||||
@@ -84,21 +85,17 @@ export class ViewCursors extends ViewPart {
|
||||
// --- begin event handlers
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
const options = this._context.configuration.options;
|
||||
|
||||
if (e.readOnly) {
|
||||
this._readOnly = this._context.configuration.editor.readOnly;
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking;
|
||||
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
|
||||
this._cursorSmoothCaretAnimation = this._context.configuration.editor.viewInfo.cursorSmoothCaretAnimation;
|
||||
}
|
||||
this._readOnly = options.get(EditorOption.readOnly);
|
||||
this._cursorBlinking = options.get(EditorOption.cursorBlinking);
|
||||
this._cursorStyle = options.get(EditorOption.cursorStyle);
|
||||
this._cursorSmoothCaretAnimation = options.get(EditorOption.cursorSmoothCaretAnimation);
|
||||
|
||||
this._updateBlinking();
|
||||
this._updateDomClassName();
|
||||
|
||||
this._primaryCursor.onConfigurationChanged(e);
|
||||
this._updateBlinking();
|
||||
if (e.viewInfo) {
|
||||
this._updateDomClassName();
|
||||
}
|
||||
for (let i = 0, len = this._secondaryCursors.length; i < len; i++) {
|
||||
this._secondaryCursors[i].onConfigurationChanged(e);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import { RenderingContext, RestrictedRenderingContext } from 'vs/editor/common/v
|
||||
import { ViewContext } from 'vs/editor/common/view/viewContext';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { IViewWhitespaceViewportData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
|
||||
export interface IMyViewZone {
|
||||
whitespaceId: string;
|
||||
@@ -40,9 +42,12 @@ export class ViewZones extends ViewPart {
|
||||
|
||||
constructor(context: ViewContext) {
|
||||
super(context);
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
|
||||
this.domNode = createFastDomNode(document.createElement('div'));
|
||||
this.domNode.setClassName('view-zones');
|
||||
@@ -84,15 +89,15 @@ export class ViewZones extends ViewPart {
|
||||
}
|
||||
|
||||
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
|
||||
const options = this._context.configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
if (e.lineHeight) {
|
||||
this._lineHeight = this._context.configuration.editor.lineHeight;
|
||||
return this._recomputeWhitespacesProps();
|
||||
}
|
||||
this._lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._contentWidth = layoutInfo.contentWidth;
|
||||
this._contentLeft = layoutInfo.contentLeft;
|
||||
|
||||
if (e.layoutInfo) {
|
||||
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
|
||||
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
|
||||
if (e.hasChanged(EditorOption.lineHeight)) {
|
||||
this._recomputeWhitespacesProps();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
|
||||
import { ICommandDelegate } from 'vs/editor/browser/view/viewController';
|
||||
import { IContentWidgetData, IOverlayWidgetData, View } from 'vs/editor/browser/view/viewImpl';
|
||||
import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EditorLayoutInfo, IEditorOptions, EditorOption, IComputedEditorOptions, FindComputedEditorOptionValueById } from 'vs/editor/common/config/editorOptions';
|
||||
import { Cursor, CursorStateChangedEvent } from 'vs/editor/common/controller/cursor';
|
||||
import { CursorColumns, ICursors } from 'vs/editor/common/controller/cursorCommon';
|
||||
import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
@@ -125,8 +125,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
private readonly _onDidChangeModelDecorations: Emitter<IModelDecorationsChangedEvent> = this._register(new Emitter<IModelDecorationsChangedEvent>());
|
||||
public readonly onDidChangeModelDecorations: Event<IModelDecorationsChangedEvent> = this._onDidChangeModelDecorations.event;
|
||||
|
||||
private readonly _onDidChangeConfiguration: Emitter<editorOptions.IConfigurationChangedEvent> = this._register(new Emitter<editorOptions.IConfigurationChangedEvent>());
|
||||
public readonly onDidChangeConfiguration: Event<editorOptions.IConfigurationChangedEvent> = this._onDidChangeConfiguration.event;
|
||||
private readonly _onDidChangeConfiguration: Emitter<ConfigurationChangedEvent> = this._register(new Emitter<ConfigurationChangedEvent>());
|
||||
public readonly onDidChangeConfiguration: Event<ConfigurationChangedEvent> = this._onDidChangeConfiguration.event;
|
||||
|
||||
protected readonly _onDidChangeModel: Emitter<editorCommon.IModelChangedEvent> = this._register(new Emitter<editorCommon.IModelChangedEvent>());
|
||||
public readonly onDidChangeModel: Event<editorCommon.IModelChangedEvent> = this._onDidChangeModel.event;
|
||||
@@ -140,8 +140,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
private readonly _onDidAttemptReadOnlyEdit: Emitter<void> = this._register(new Emitter<void>());
|
||||
public readonly onDidAttemptReadOnlyEdit: Event<void> = this._onDidAttemptReadOnlyEdit.event;
|
||||
|
||||
private readonly _onDidLayoutChange: Emitter<editorOptions.EditorLayoutInfo> = this._register(new Emitter<editorOptions.EditorLayoutInfo>());
|
||||
public readonly onDidLayoutChange: Event<editorOptions.EditorLayoutInfo> = this._onDidLayoutChange.event;
|
||||
private readonly _onDidLayoutChange: Emitter<EditorLayoutInfo> = this._register(new Emitter<EditorLayoutInfo>());
|
||||
public readonly onDidLayoutChange: Event<EditorLayoutInfo> = this._onDidLayoutChange.event;
|
||||
|
||||
private readonly _editorTextFocus: BooleanEventEmitter = this._register(new BooleanEventEmitter());
|
||||
public readonly onDidFocusEditorText: Event<void> = this._editorTextFocus.onDidChangeToTrue;
|
||||
@@ -236,7 +236,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
options: editorOptions.IEditorOptions,
|
||||
options: IEditorOptions,
|
||||
codeEditorWidgetOptions: ICodeEditorWidgetOptions,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@@ -259,10 +259,12 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
this._register(this._configuration.onDidChange((e) => {
|
||||
this._onDidChangeConfiguration.fire(e);
|
||||
|
||||
if (e.layoutInfo) {
|
||||
this._onDidLayoutChange.fire(this._configuration.editor.layoutInfo);
|
||||
const options = this._configuration.options;
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this._onDidLayoutChange.fire(layoutInfo);
|
||||
}
|
||||
if (this._configuration.editor.showUnused) {
|
||||
if (options.get(EditorOption.showUnused)) {
|
||||
this._domElement.classList.add(SHOW_UNUSED_ENABLED_CLASS);
|
||||
} else {
|
||||
this._domElement.classList.remove(SHOW_UNUSED_ENABLED_CLASS);
|
||||
@@ -327,7 +329,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
this._codeEditorService.addCodeEditor(this);
|
||||
}
|
||||
|
||||
protected _createConfiguration(options: editorOptions.IEditorOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
|
||||
protected _createConfiguration(options: IEditorOptions, accessibilityService: IAccessibilityService): editorCommon.IConfiguration {
|
||||
return new Configuration(this.isSimpleWidget, options, this._domElement, accessibilityService);
|
||||
}
|
||||
|
||||
@@ -362,15 +364,19 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
return this._instantiationService.invokeFunction(fn);
|
||||
}
|
||||
|
||||
public updateOptions(newOptions: editorOptions.IEditorOptions): void {
|
||||
public updateOptions(newOptions: IEditorOptions): void {
|
||||
this._configuration.updateOptions(newOptions);
|
||||
}
|
||||
|
||||
public getConfiguration(): editorOptions.InternalEditorOptions {
|
||||
return this._configuration.editor;
|
||||
public getOptions(): IComputedEditorOptions {
|
||||
return this._configuration.options;
|
||||
}
|
||||
|
||||
public getRawConfiguration(): editorOptions.IEditorOptions {
|
||||
public getOption<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T> {
|
||||
return this._configuration.options.get(id);
|
||||
}
|
||||
|
||||
public getRawOptions(): IEditorOptions {
|
||||
return this._configuration.getRawOptions();
|
||||
}
|
||||
|
||||
@@ -526,7 +532,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
const validatedModelRange = this._modelData.model.validateRange(modelRange);
|
||||
const viewRange = this._modelData.viewModel.coordinatesConverter.convertModelRangeToViewRange(validatedModelRange);
|
||||
|
||||
this._modelData.cursor.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType);
|
||||
this._modelData.cursor.emitCursorRevealRange('api', viewRange, verticalType, revealHorizontal, scrollType);
|
||||
}
|
||||
|
||||
public revealLine(lineNumber: number, scrollType: editorCommon.ScrollType = editorCommon.ScrollType.Smooth): void {
|
||||
@@ -972,7 +978,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
if (!this._modelData) {
|
||||
return false;
|
||||
}
|
||||
if (this._configuration.editor.readOnly) {
|
||||
if (this._configuration.options.get(EditorOption.readOnly)) {
|
||||
// read only editor => sorry!
|
||||
return false;
|
||||
}
|
||||
@@ -984,7 +990,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
if (!this._modelData) {
|
||||
return false;
|
||||
}
|
||||
if (this._configuration.editor.readOnly) {
|
||||
if (this._configuration.options.get(EditorOption.readOnly)) {
|
||||
// read only editor => sorry!
|
||||
return false;
|
||||
}
|
||||
@@ -1028,7 +1034,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
if (!this._modelData) {
|
||||
return null;
|
||||
}
|
||||
return this._modelData.model.getLineDecorations(lineNumber, this._id, this._configuration.editor.readOnly);
|
||||
return this._modelData.model.getLineDecorations(lineNumber, this._id, this._configuration.options.get(EditorOption.readOnly));
|
||||
}
|
||||
|
||||
public deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[]): string[] {
|
||||
@@ -1119,8 +1125,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
}
|
||||
}
|
||||
|
||||
public getLayoutInfo(): editorOptions.EditorLayoutInfo {
|
||||
return this._configuration.editor.layoutInfo;
|
||||
public getLayoutInfo(): EditorLayoutInfo {
|
||||
const options = this._configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
return layoutInfo;
|
||||
}
|
||||
|
||||
public createOverviewRuler(cssClassName: string): editorBrowser.IOverviewRuler | null {
|
||||
@@ -1164,7 +1172,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
}
|
||||
|
||||
public hasWidgetFocus(): boolean {
|
||||
return this._focusTracker && this._focusTracker.hasFocus();
|
||||
return (this._editorWidgetFocus.getValue() === BooleanEventValue.True);
|
||||
}
|
||||
|
||||
public addContentWidget(widget: editorBrowser.IContentWidget): void {
|
||||
@@ -1268,7 +1276,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
}
|
||||
|
||||
const position = this._modelData.model.validatePosition(rawPosition);
|
||||
const layoutInfo = this._configuration.editor.layoutInfo;
|
||||
const options = this._configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
const top = CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, position.lineNumber, position.column) - this.getScrollTop();
|
||||
const left = this._modelData.view.getOffsetForColumn(position.lineNumber, position.column) + layoutInfo.glyphMarginWidth + layoutInfo.lineNumbersWidth + layoutInfo.decorationsWidth - this.getScrollLeft();
|
||||
@@ -1276,7 +1285,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
return {
|
||||
top: top,
|
||||
left: left,
|
||||
height: this._configuration.editor.lineHeight
|
||||
height: options.get(EditorOption.lineHeight)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1295,7 +1304,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
||||
}
|
||||
|
||||
public applyFontInfo(target: HTMLElement): void {
|
||||
Configuration.applyFontInfoSlow(target, this._configuration.editor.fontInfo);
|
||||
Configuration.applyFontInfoSlow(target, this._configuration.options.get(EditorOption.fontInfo));
|
||||
}
|
||||
|
||||
protected _attachModel(model: ITextModel | null): void {
|
||||
@@ -1539,6 +1548,10 @@ export class BooleanEventEmitter extends Disposable {
|
||||
this._value = BooleanEventValue.NotSet;
|
||||
}
|
||||
|
||||
public getValue(): BooleanEventValue {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public setValue(_value: boolean) {
|
||||
const value = (_value ? BooleanEventValue.True : BooleanEventValue.False);
|
||||
if (this._value === value) {
|
||||
@@ -1601,10 +1614,10 @@ class EditorContextKeysManager extends Disposable {
|
||||
}
|
||||
|
||||
private _updateFromConfig(): void {
|
||||
const config = this._editor.getConfiguration();
|
||||
const options = this._editor.getOptions();
|
||||
|
||||
this._editorTabMovesFocus.set(config.tabFocusMode);
|
||||
this._editorReadonly.set(config.readOnly);
|
||||
this._editorTabMovesFocus.set(options.get(EditorOption.tabFocusMode));
|
||||
this._editorReadonly.set(options.get(EditorOption.readOnly));
|
||||
}
|
||||
|
||||
private _updateFromSelection(): void {
|
||||
|
||||
@@ -20,7 +20,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffReview } from 'vs/editor/browser/widget/diffReview';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { IDiffEditorOptions, IEditorOptions, EditorLayoutInfo, IComputedEditorOptions, EditorOption, EditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
@@ -81,7 +81,7 @@ class VisualEditorState {
|
||||
|
||||
constructor(
|
||||
private _contextMenuService: IContextMenuService,
|
||||
private _clipboardService: IClipboardService
|
||||
private _clipboardService: IClipboardService | null
|
||||
) {
|
||||
this._zones = [];
|
||||
this.inlineDiffMargins = [];
|
||||
@@ -131,7 +131,7 @@ class VisualEditorState {
|
||||
this._zones.push(zoneId);
|
||||
this._zonesMap[String(zoneId)] = true;
|
||||
|
||||
if (newDecorations.zones[i].diff && viewZone.marginDomNode) {
|
||||
if (newDecorations.zones[i].diff && viewZone.marginDomNode && this._clipboardService) {
|
||||
this.inlineDiffMargins.push(new InlineDiffMargin(zoneId, viewZone.marginDomNode, editor, newDecorations.zones[i].diff!, this._contextMenuService, this._clipboardService));
|
||||
}
|
||||
}
|
||||
@@ -212,12 +212,12 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
private readonly _notificationService: INotificationService;
|
||||
|
||||
private readonly _reviewPane: DiffReview;
|
||||
// {{SQL CARBON EDIT}}
|
||||
private _options: editorOptions.IDiffEditorOptions;
|
||||
private _options: IDiffEditorOptions; // {{SQL CARBON EDIT}}
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
options: editorOptions.IDiffEditorOptions,
|
||||
options: IDiffEditorOptions,
|
||||
clipboardService: IClipboardService | null,
|
||||
@IEditorWorkerService editorWorkerService: IEditorWorkerService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@@ -225,7 +225,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
@IThemeService themeService: IThemeService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -235,8 +234,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._contextKeyService.createKey('isInDiffEditor', true);
|
||||
this._themeService = themeService;
|
||||
this._notificationService = notificationService;
|
||||
// {{SQL CARBON EDIT}}
|
||||
this._options = options;
|
||||
|
||||
this._options = options; // {{SQL CARBON EDIT}}
|
||||
|
||||
this.id = (++DIFF_EDITOR_ID);
|
||||
|
||||
@@ -428,7 +427,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._layoutOverviewRulers();
|
||||
}
|
||||
|
||||
private _createLeftHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
private _createLeftHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
const editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
|
||||
|
||||
this._register(editor.onDidScrollChange((e) => {
|
||||
@@ -461,7 +460,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return editor;
|
||||
}
|
||||
|
||||
private _createRightHandSideEditor(options: editorOptions.IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
private _createRightHandSideEditor(options: IDiffEditorOptions, instantiationService: IInstantiationService): CodeEditorWidget {
|
||||
const editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options));
|
||||
|
||||
this._register(editor.onDidScrollChange((e) => {
|
||||
@@ -486,7 +485,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}));
|
||||
|
||||
this._register(editor.onDidChangeConfiguration((e) => {
|
||||
if (e.fontInfo && editor.getModel()) {
|
||||
if (e.hasChanged(EditorOption.fontInfo) && editor.getModel()) {
|
||||
this._onViewZonesChanged();
|
||||
}
|
||||
}));
|
||||
@@ -500,7 +499,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return editor;
|
||||
}
|
||||
|
||||
protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: editorOptions.IEditorOptions): CodeEditorWidget {
|
||||
protected _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: IEditorOptions): CodeEditorWidget {
|
||||
return instantiationService.createInstance(CodeEditorWidget, container, options, {});
|
||||
}
|
||||
|
||||
@@ -574,7 +573,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return this.modifiedEditor;
|
||||
}
|
||||
|
||||
public updateOptions(newOptions: editorOptions.IDiffEditorOptions): void {
|
||||
public updateOptions(newOptions: IDiffEditorOptions): void {
|
||||
|
||||
// Handle side by side
|
||||
let renderSideBySideChanged = false;
|
||||
@@ -974,8 +973,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
}
|
||||
}
|
||||
|
||||
private _adjustOptionsForSubEditor(options: editorOptions.IDiffEditorOptions): editorOptions.IDiffEditorOptions {
|
||||
let clonedOptions: editorOptions.IDiffEditorOptions = objects.deepClone(options || {});
|
||||
private _adjustOptionsForSubEditor(options: IDiffEditorOptions): IDiffEditorOptions {
|
||||
let clonedOptions: IDiffEditorOptions = objects.deepClone(options || {});
|
||||
clonedOptions.inDiffEditor = true;
|
||||
clonedOptions.wordWrap = 'off';
|
||||
clonedOptions.wordWrapMinified = false;
|
||||
@@ -993,7 +992,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return clonedOptions;
|
||||
}
|
||||
|
||||
private _adjustOptionsForLeftHandSide(options: editorOptions.IDiffEditorOptions, isEditable: boolean): editorOptions.IEditorOptions {
|
||||
private _adjustOptionsForLeftHandSide(options: IDiffEditorOptions, isEditable: boolean): IEditorOptions {
|
||||
let result = this._adjustOptionsForSubEditor(options);
|
||||
result.readOnly = !isEditable;
|
||||
result.overviewRulerLanes = 1;
|
||||
@@ -1001,9 +1000,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
return result;
|
||||
}
|
||||
|
||||
private _adjustOptionsForRightHandSide(options: editorOptions.IDiffEditorOptions): editorOptions.IEditorOptions {
|
||||
private _adjustOptionsForRightHandSide(options: IDiffEditorOptions): IEditorOptions {
|
||||
let result = this._adjustOptionsForSubEditor(options);
|
||||
result.revealHorizontalRightPadding = editorOptions.EDITOR_DEFAULTS.viewInfo.revealHorizontalRightPadding + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
|
||||
result.revealHorizontalRightPadding = EditorOptions.revealHorizontalRightPadding.defaultValue + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
|
||||
result.scrollbar!.verticalHasArrows = false;
|
||||
result.extraEditorClassName = 'modified-in-monaco-diff-editor';
|
||||
return result;
|
||||
@@ -1849,7 +1848,7 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito
|
||||
|
||||
this.decorationsLeft = dataSource.getOriginalEditor().getLayoutInfo().decorationsLeft;
|
||||
|
||||
this._register(dataSource.getOriginalEditor().onDidLayoutChange((layoutInfo: editorOptions.EditorLayoutInfo) => {
|
||||
this._register(dataSource.getOriginalEditor().onDidLayoutChange((layoutInfo: EditorLayoutInfo) => {
|
||||
if (this.decorationsLeft !== layoutInfo.decorationsLeft) {
|
||||
this.decorationsLeft = layoutInfo.decorationsLeft;
|
||||
dataSource.relayoutEditors();
|
||||
@@ -1965,14 +1964,14 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito
|
||||
class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
|
||||
private readonly originalModel: ITextModel;
|
||||
private readonly modifiedEditorConfiguration: editorOptions.InternalEditorOptions;
|
||||
private readonly modifiedEditorOptions: IComputedEditorOptions;
|
||||
private readonly modifiedEditorTabSize: number;
|
||||
private readonly renderIndicators: boolean;
|
||||
|
||||
constructor(lineChanges: editorCommon.ILineChange[], originalForeignVZ: IEditorWhitespace[], modifiedForeignVZ: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor, renderIndicators: boolean) {
|
||||
super(lineChanges, originalForeignVZ, modifiedForeignVZ);
|
||||
this.originalModel = originalEditor.getModel()!;
|
||||
this.modifiedEditorConfiguration = modifiedEditor.getConfiguration();
|
||||
this.modifiedEditorOptions = modifiedEditor.getOptions();
|
||||
this.modifiedEditorTabSize = modifiedEditor.getModel()!.getOptions().tabSize;
|
||||
this.renderIndicators = renderIndicators;
|
||||
}
|
||||
@@ -2012,13 +2011,16 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
|
||||
let sb = createStringBuilder(10000);
|
||||
let marginHTML: string[] = [];
|
||||
let lineDecorationsWidth = this.modifiedEditorConfiguration.layoutInfo.decorationsWidth;
|
||||
let lineHeight = this.modifiedEditorConfiguration.lineHeight;
|
||||
const typicalHalfwidthCharacterWidth = this.modifiedEditorConfiguration.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
const layoutInfo = this.modifiedEditorOptions.get(EditorOption.layoutInfo);
|
||||
const fontInfo = this.modifiedEditorOptions.get(EditorOption.fontInfo);
|
||||
const lineDecorationsWidth = layoutInfo.decorationsWidth;
|
||||
|
||||
let lineHeight = this.modifiedEditorOptions.get(EditorOption.lineHeight);
|
||||
const typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
|
||||
let maxCharsPerLine = 0;
|
||||
const originalContent: string[] = [];
|
||||
for (let lineNumber = lineChange.originalStartLineNumber; lineNumber <= lineChange.originalEndLineNumber; lineNumber++) {
|
||||
maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorConfiguration, this.modifiedEditorTabSize, lineNumber, decorations, sb));
|
||||
maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorOptions, this.modifiedEditorTabSize, lineNumber, decorations, sb));
|
||||
originalContent.push(this.originalModel.getLineContent(lineNumber));
|
||||
|
||||
if (this.renderIndicators) {
|
||||
@@ -2028,17 +2030,17 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
]);
|
||||
}
|
||||
}
|
||||
maxCharsPerLine += this.modifiedEditorConfiguration.viewInfo.scrollBeyondLastColumn;
|
||||
maxCharsPerLine += this.modifiedEditorOptions.get(EditorOption.scrollBeyondLastColumn);
|
||||
|
||||
let domNode = document.createElement('div');
|
||||
domNode.className = 'view-lines line-delete';
|
||||
domNode.innerHTML = sb.build();
|
||||
Configuration.applyFontInfoSlow(domNode, this.modifiedEditorConfiguration.fontInfo);
|
||||
Configuration.applyFontInfoSlow(domNode, fontInfo);
|
||||
|
||||
let marginDomNode = document.createElement('div');
|
||||
marginDomNode.className = 'inline-deleted-margin-view-zone';
|
||||
marginDomNode.innerHTML = marginHTML.join('');
|
||||
Configuration.applyFontInfoSlow(marginDomNode, this.modifiedEditorConfiguration.fontInfo);
|
||||
Configuration.applyFontInfoSlow(marginDomNode, fontInfo);
|
||||
|
||||
return {
|
||||
shouldNotShrink: true,
|
||||
@@ -2057,9 +2059,10 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
};
|
||||
}
|
||||
|
||||
private _renderOriginalLine(count: number, originalModel: ITextModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number {
|
||||
private _renderOriginalLine(count: number, originalModel: ITextModel, options: IComputedEditorOptions, tabSize: number, lineNumber: number, decorations: InlineDecoration[], sb: IStringBuilder): number {
|
||||
const lineTokens = originalModel.getLineTokens(lineNumber);
|
||||
const lineContent = lineTokens.getLineContent();
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
const actualDecorations = LineDecoration.filter(decorations, lineNumber, 1, lineContent.length + 1);
|
||||
|
||||
@@ -2069,14 +2072,14 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
sb.appendASCIIString(' char-delete');
|
||||
}
|
||||
sb.appendASCIIString('" style="top:');
|
||||
sb.appendASCIIString(String(count * config.lineHeight));
|
||||
sb.appendASCIIString(String(count * options.get(EditorOption.lineHeight)));
|
||||
sb.appendASCIIString('px;width:1000000px;">');
|
||||
|
||||
const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, originalModel.mightContainNonBasicASCII());
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, originalModel.mightContainRTL());
|
||||
const output = renderViewLine(new RenderLineInput(
|
||||
(config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations),
|
||||
config.fontInfo.canUseHalfwidthRightwardsArrow,
|
||||
(fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations) && !options.get(EditorOption.fontLigatures)),
|
||||
fontInfo.canUseHalfwidthRightwardsArrow,
|
||||
lineContent,
|
||||
false,
|
||||
isBasicASCII,
|
||||
@@ -2085,11 +2088,11 @@ class InlineViewZonesComputer extends ViewZonesComputer {
|
||||
lineTokens,
|
||||
actualDecorations,
|
||||
tabSize,
|
||||
config.fontInfo.spaceWidth,
|
||||
config.viewInfo.stopRenderingLineAfter,
|
||||
config.viewInfo.renderWhitespace,
|
||||
config.viewInfo.renderControlCharacters,
|
||||
config.viewInfo.fontLigatures,
|
||||
fontInfo.spaceWidth,
|
||||
options.get(EditorOption.stopRenderingLineAfter),
|
||||
options.get(EditorOption.renderWhitespace),
|
||||
options.get(EditorOption.renderControlCharacters),
|
||||
options.get(EditorOption.fontLigatures),
|
||||
null // Send no selections, original line cannot be selected
|
||||
), sb);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { IComputedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ILineChange, ScrollType } from 'vs/editor/common/editorCommon';
|
||||
@@ -524,8 +524,8 @@ export class DiffReview extends Disposable {
|
||||
|
||||
private _render(): void {
|
||||
|
||||
const originalOpts = this._diffEditor.getOriginalEditor().getConfiguration();
|
||||
const modifiedOpts = this._diffEditor.getModifiedEditor().getConfiguration();
|
||||
const originalOptions = this._diffEditor.getOriginalEditor().getOptions();
|
||||
const modifiedOptions = this._diffEditor.getModifiedEditor().getOptions();
|
||||
|
||||
const originalModel = this._diffEditor.getOriginalEditor().getModel();
|
||||
const modifiedModel = this._diffEditor.getModifiedEditor().getModel();
|
||||
@@ -551,7 +551,7 @@ export class DiffReview extends Disposable {
|
||||
let container = document.createElement('div');
|
||||
container.className = 'diff-review-table';
|
||||
container.setAttribute('role', 'list');
|
||||
Configuration.applyFontInfoSlow(container, modifiedOpts.fontInfo);
|
||||
Configuration.applyFontInfoSlow(container, modifiedOptions.get(EditorOption.fontInfo));
|
||||
|
||||
let minOriginalLine = 0;
|
||||
let maxOriginalLine = 0;
|
||||
@@ -620,7 +620,7 @@ export class DiffReview extends Disposable {
|
||||
let modLine = minModifiedLine;
|
||||
for (let i = 0, len = diffs.length; i < len; i++) {
|
||||
const diffEntry = diffs[i];
|
||||
DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOpts, originalModel, originalModelOpts, modifiedOpts, modifiedModel, modifiedModelOpts);
|
||||
DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOptions, originalModel, originalModelOpts, modifiedOptions, modifiedModel, modifiedModelOpts);
|
||||
if (diffEntry.modifiedLineStart !== 0) {
|
||||
modLine = diffEntry.modifiedLineEnd;
|
||||
}
|
||||
@@ -633,8 +633,8 @@ export class DiffReview extends Disposable {
|
||||
|
||||
private static _renderSection(
|
||||
dest: HTMLElement, diffEntry: DiffEntry, modLine: number, width: number,
|
||||
originalOpts: editorOptions.InternalEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions,
|
||||
modifiedOpts: editorOptions.InternalEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions
|
||||
originalOptions: IComputedEditorOptions, originalModel: ITextModel, originalModelOpts: TextModelResolvedOptions,
|
||||
modifiedOptions: IComputedEditorOptions, modifiedModel: ITextModel, modifiedModelOpts: TextModelResolvedOptions
|
||||
): void {
|
||||
|
||||
const type = diffEntry.getType();
|
||||
@@ -665,8 +665,11 @@ export class DiffReview extends Disposable {
|
||||
originalLineEnd - originalLineStart
|
||||
);
|
||||
|
||||
const originalLineNumbersWidth = originalOpts.layoutInfo.glyphMarginWidth + originalOpts.layoutInfo.lineNumbersWidth;
|
||||
const modifiedLineNumbersWidth = 10 + modifiedOpts.layoutInfo.glyphMarginWidth + modifiedOpts.layoutInfo.lineNumbersWidth;
|
||||
const originalLayoutInfo = originalOptions.get(EditorOption.layoutInfo);
|
||||
const originalLineNumbersWidth = originalLayoutInfo.glyphMarginWidth + originalLayoutInfo.lineNumbersWidth;
|
||||
|
||||
const modifiedLayoutInfo = modifiedOptions.get(EditorOption.layoutInfo);
|
||||
const modifiedLineNumbersWidth = 10 + modifiedLayoutInfo.glyphMarginWidth + modifiedLayoutInfo.lineNumbersWidth;
|
||||
|
||||
for (let i = 0; i <= cnt; i++) {
|
||||
const originalLine = (originalLineStart === 0 ? 0 : originalLineStart + i);
|
||||
@@ -716,12 +719,12 @@ export class DiffReview extends Disposable {
|
||||
let lineContent: string;
|
||||
if (modifiedLine !== 0) {
|
||||
cell.insertAdjacentHTML('beforeend',
|
||||
this._renderLine(modifiedModel, modifiedOpts, modifiedModelOpts.tabSize, modifiedLine)
|
||||
this._renderLine(modifiedModel, modifiedOptions, modifiedModelOpts.tabSize, modifiedLine)
|
||||
);
|
||||
lineContent = modifiedModel.getLineContent(modifiedLine);
|
||||
} else {
|
||||
cell.insertAdjacentHTML('beforeend',
|
||||
this._renderLine(originalModel, originalOpts, originalModelOpts.tabSize, originalLine)
|
||||
this._renderLine(originalModel, originalOptions, originalModelOpts.tabSize, originalLine)
|
||||
);
|
||||
lineContent = originalModel.getLineContent(originalLine);
|
||||
}
|
||||
@@ -748,8 +751,9 @@ export class DiffReview extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private static _renderLine(model: ITextModel, config: editorOptions.InternalEditorOptions, tabSize: number, lineNumber: number): string {
|
||||
private static _renderLine(model: ITextModel, options: IComputedEditorOptions, tabSize: number, lineNumber: number): string {
|
||||
const lineContent = model.getLineContent(lineNumber);
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
|
||||
const defaultMetadata = (
|
||||
(FontStyle.None << MetadataConsts.FONT_STYLE_OFFSET)
|
||||
@@ -766,8 +770,8 @@ export class DiffReview extends Disposable {
|
||||
const isBasicASCII = ViewLineRenderingData.isBasicASCII(lineContent, model.mightContainNonBasicASCII());
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, model.mightContainRTL());
|
||||
const r = renderViewLine(new RenderLineInput(
|
||||
(config.fontInfo.isMonospace && !config.viewInfo.disableMonospaceOptimizations),
|
||||
config.fontInfo.canUseHalfwidthRightwardsArrow,
|
||||
(fontInfo.isMonospace && !options.get(EditorOption.disableMonospaceOptimizations) && !options.get(EditorOption.fontLigatures)),
|
||||
fontInfo.canUseHalfwidthRightwardsArrow,
|
||||
lineContent,
|
||||
false,
|
||||
isBasicASCII,
|
||||
@@ -776,11 +780,11 @@ export class DiffReview extends Disposable {
|
||||
lineTokens,
|
||||
[],
|
||||
tabSize,
|
||||
config.fontInfo.spaceWidth,
|
||||
config.viewInfo.stopRenderingLineAfter,
|
||||
config.viewInfo.renderWhitespace,
|
||||
config.viewInfo.renderControlCharacters,
|
||||
config.viewInfo.fontLigatures,
|
||||
fontInfo.spaceWidth,
|
||||
options.get(EditorOption.stopRenderingLineAfter),
|
||||
options.get(EditorOption.renderWhitespace),
|
||||
options.get(EditorOption.renderControlCharacters),
|
||||
options.get(EditorOption.fontLigatures),
|
||||
null
|
||||
));
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { IConfigurationChangedEvent, IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
@@ -36,7 +36,7 @@ export class EmbeddedCodeEditorWidget extends CodeEditorWidget {
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IAccessibilityService accessibilityService: IAccessibilityService
|
||||
) {
|
||||
super(domElement, parentEditor.getRawConfiguration(), {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService);
|
||||
super(domElement, parentEditor.getRawOptions(), {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService);
|
||||
|
||||
this._parentEditor = parentEditor;
|
||||
this._overwriteOptions = options;
|
||||
@@ -44,15 +44,15 @@ export class EmbeddedCodeEditorWidget extends CodeEditorWidget {
|
||||
// Overwrite parent's options
|
||||
super.updateOptions(this._overwriteOptions);
|
||||
|
||||
this._register(parentEditor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => this._onParentConfigurationChanged(e)));
|
||||
this._register(parentEditor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => this._onParentConfigurationChanged(e)));
|
||||
}
|
||||
|
||||
getParentEditor(): ICodeEditor {
|
||||
return this._parentEditor;
|
||||
}
|
||||
|
||||
private _onParentConfigurationChanged(e: IConfigurationChangedEvent): void {
|
||||
super.updateOptions(this._parentEditor.getRawConfiguration());
|
||||
private _onParentConfigurationChanged(e: ConfigurationChangedEvent): void {
|
||||
super.updateOptions(this._parentEditor.getRawOptions());
|
||||
super.updateOptions(this._overwriteOptions);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget {
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
super(domElement, parentEditor.getRawConfiguration(), editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, clipboardService);
|
||||
super(domElement, parentEditor.getRawOptions(), clipboardService, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService);
|
||||
|
||||
this._parentEditor = parentEditor;
|
||||
this._overwriteOptions = options;
|
||||
@@ -95,8 +95,8 @@ export class EmbeddedDiffEditorWidget extends DiffEditorWidget {
|
||||
return this._parentEditor;
|
||||
}
|
||||
|
||||
private _onParentConfigurationChanged(e: IConfigurationChangedEvent): void {
|
||||
super.updateOptions(this._parentEditor.getRawConfiguration());
|
||||
private _onParentConfigurationChanged(e: ConfigurationChangedEvent): void {
|
||||
super.updateOptions(this._parentEditor.getRawOptions());
|
||||
super.updateOptions(this._overwriteOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export interface IDiffLinesChange {
|
||||
readonly originalStartLineNumber: number;
|
||||
@@ -58,7 +59,7 @@ export class InlineDiffMargin extends Disposable {
|
||||
this._diffActions = document.createElement('div');
|
||||
this._diffActions.className = 'lightbulb-glyph';
|
||||
this._diffActions.style.position = 'absolute';
|
||||
const lineHeight = editor.getConfiguration().lineHeight;
|
||||
const lineHeight = editor.getOption(EditorOption.lineHeight);
|
||||
const lineFeed = editor.getModel()!.getEOL();
|
||||
this._diffActions.style.right = '0px';
|
||||
this._diffActions.style.visibility = 'hidden';
|
||||
@@ -66,26 +67,27 @@ export class InlineDiffMargin extends Disposable {
|
||||
this._diffActions.style.lineHeight = `${lineHeight}px`;
|
||||
this._marginDomNode.appendChild(this._diffActions);
|
||||
|
||||
const actions = [
|
||||
new Action(
|
||||
'diff.clipboard.copyDeletedContent',
|
||||
nls.localize('diff.clipboard.copyDeletedContent.label', "Copy deleted lines content to clipboard"),
|
||||
undefined,
|
||||
true,
|
||||
async () => {
|
||||
await this._clipboardService.writeText(diff.originalContent.join(lineFeed) + lineFeed);
|
||||
}
|
||||
)
|
||||
];
|
||||
const actions: Action[] = [];
|
||||
|
||||
// default action
|
||||
actions.push(new Action(
|
||||
'diff.clipboard.copyDeletedContent',
|
||||
diff.originalEndLineNumber > diff.modifiedStartLineNumber
|
||||
? nls.localize('diff.clipboard.copyDeletedLinesContent.label', "Copy deleted lines")
|
||||
: nls.localize('diff.clipboard.copyDeletedLinesContent.single.label', "Copy deleted line"),
|
||||
undefined,
|
||||
true,
|
||||
async () => {
|
||||
await this._clipboardService.writeText(diff.originalContent.join(lineFeed) + lineFeed);
|
||||
}
|
||||
));
|
||||
|
||||
let currentLineNumberOffset = 0;
|
||||
|
||||
let copyLineAction: Action | undefined = undefined;
|
||||
|
||||
if (diff.originalEndLineNumber > diff.modifiedStartLineNumber) {
|
||||
copyLineAction = new Action(
|
||||
'diff.clipboard.copyDeletedLineContent',
|
||||
nls.localize('diff.clipboard.copyDeletedLineContent.label', "Copy deleted line {0} content to clipboard", diff.originalStartLineNumber),
|
||||
nls.localize('diff.clipboard.copyDeletedLineContent.label', "Copy deleted line ({0})", diff.originalStartLineNumber),
|
||||
undefined,
|
||||
true,
|
||||
async () => {
|
||||
@@ -96,7 +98,7 @@ export class InlineDiffMargin extends Disposable {
|
||||
actions.push(copyLineAction);
|
||||
}
|
||||
|
||||
const readOnly = editor.getConfiguration().readOnly;
|
||||
const readOnly = editor.getOption(EditorOption.readOnly);
|
||||
if (!readOnly) {
|
||||
actions.push(new Action('diff.inline.revertChange', nls.localize('diff.inline.revertChange.label', "Revert this change"), undefined, true, async () => {
|
||||
if (diff.modifiedEndLineNumber === 0) {
|
||||
@@ -121,24 +123,31 @@ export class InlineDiffMargin extends Disposable {
|
||||
}));
|
||||
}
|
||||
|
||||
this._register(dom.addStandardDisposableListener(this._diffActions, 'mousedown', e => {
|
||||
const { top, height } = dom.getDomNodePagePosition(this._diffActions);
|
||||
let pad = Math.floor(lineHeight / 3) + lineHeight;
|
||||
const showContextMenu = (x: number, y: number) => {
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => {
|
||||
return {
|
||||
x: e.posx,
|
||||
y: top + height + pad
|
||||
x,
|
||||
y
|
||||
};
|
||||
},
|
||||
getActions: () => {
|
||||
if (copyLineAction) {
|
||||
copyLineAction.label = nls.localize('diff.clipboard.copyDeletedLineContent.label', "Copy deleted line {0} content to clipboard", diff.originalStartLineNumber + currentLineNumberOffset);
|
||||
copyLineAction.label = nls.localize('diff.clipboard.copyDeletedLineContent.label', "Copy deleted line ({0})", diff.originalStartLineNumber + currentLineNumberOffset);
|
||||
}
|
||||
return actions;
|
||||
},
|
||||
autoSelectFirstItem: true
|
||||
});
|
||||
};
|
||||
|
||||
this._register(dom.addStandardDisposableListener(this._diffActions, 'mousedown', e => {
|
||||
const { top, height } = dom.getDomNodePagePosition(this._diffActions);
|
||||
let pad = Math.floor(lineHeight / 3);
|
||||
e.preventDefault();
|
||||
|
||||
showContextMenu(e.posx, top + height + pad);
|
||||
|
||||
}));
|
||||
|
||||
this._register(editor.onMouseMove((e: editorBrowser.IEditorMouseEvent) => {
|
||||
@@ -155,6 +164,22 @@ export class InlineDiffMargin extends Disposable {
|
||||
this.visibility = false;
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(editor.onMouseDown((e: editorBrowser.IEditorMouseEvent) => {
|
||||
if (!e.event.rightButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.target.type === editorBrowser.MouseTargetType.CONTENT_VIEW_ZONE || e.target.type === editorBrowser.MouseTargetType.GUTTER_VIEW_ZONE) {
|
||||
const viewZoneId = e.target.detail.viewZoneId;
|
||||
|
||||
if (viewZoneId === this._viewZoneId) {
|
||||
e.event.preventDefault();
|
||||
currentLineNumberOffset = this._updateLightBulbPosition(this._marginDomNode, e.event.browserEvent.y, lineHeight);
|
||||
showContextMenu(e.event.posx, e.event.posy + lineHeight);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private _updateLightBulbPosition(marginDomNode: HTMLElement, y: number, lineHeight: number): number {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditorOptions, ValidatedEditorOptions, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
|
||||
|
||||
/**
|
||||
@@ -14,59 +14,9 @@ import { EditorZoom } from 'vs/editor/common/config/editorZoom';
|
||||
const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
|
||||
|
||||
/**
|
||||
* Font settings maximum and minimum limits
|
||||
* @internal
|
||||
*/
|
||||
const MINIMUM_FONT_SIZE = 8;
|
||||
const MAXIMUM_FONT_SIZE = 100;
|
||||
const MINIMUM_LINE_HEIGHT = 8;
|
||||
const MAXIMUM_LINE_HEIGHT = 150;
|
||||
const MINIMUM_LETTER_SPACING = -5;
|
||||
const MAXIMUM_LETTER_SPACING = 20;
|
||||
|
||||
function safeParseFloat(n: number | string | undefined, defaultValue: number): number {
|
||||
if (typeof n === 'number') {
|
||||
return n;
|
||||
}
|
||||
if (typeof n === 'undefined') {
|
||||
return defaultValue;
|
||||
}
|
||||
let r = parseFloat(n);
|
||||
if (isNaN(r)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function safeParseInt(n: number | string | undefined, defaultValue: number): number {
|
||||
if (typeof n === 'number') {
|
||||
return Math.round(n);
|
||||
}
|
||||
if (typeof n === 'undefined') {
|
||||
return defaultValue;
|
||||
}
|
||||
let r = parseInt(n);
|
||||
if (isNaN(r)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function clamp(n: number, min: number, max: number): number {
|
||||
if (n < min) {
|
||||
return min;
|
||||
}
|
||||
if (n > max) {
|
||||
return max;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
function _string(value: any, defaultValue: string): string {
|
||||
if (typeof value !== 'string') {
|
||||
return defaultValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export class BareFontInfo {
|
||||
readonly _bareFontInfoBrand: void;
|
||||
@@ -74,38 +24,38 @@ export class BareFontInfo {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static createFromRawSettings(opts: {
|
||||
fontFamily?: string;
|
||||
fontWeight?: string;
|
||||
fontSize?: number | string;
|
||||
lineHeight?: number | string;
|
||||
letterSpacing?: number | string;
|
||||
}, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo {
|
||||
public static createFromValidatedSettings(options: ValidatedEditorOptions, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo {
|
||||
const fontFamily = options.get(EditorOption.fontFamily);
|
||||
const fontWeight = options.get(EditorOption.fontWeight);
|
||||
const fontSize = options.get(EditorOption.fontSize);
|
||||
const lineHeight = options.get(EditorOption.lineHeight);
|
||||
const letterSpacing = options.get(EditorOption.letterSpacing);
|
||||
return BareFontInfo._create(fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom);
|
||||
}
|
||||
|
||||
let fontFamily = _string(opts.fontFamily, EDITOR_FONT_DEFAULTS.fontFamily);
|
||||
let fontWeight = _string(opts.fontWeight, EDITOR_FONT_DEFAULTS.fontWeight);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static createFromRawSettings(opts: { fontFamily?: string; fontWeight?: string; fontSize?: number; lineHeight?: number; letterSpacing?: number; }, zoomLevel: number, ignoreEditorZoom: boolean = false): BareFontInfo {
|
||||
const fontFamily = EditorOptions.fontFamily.validate(opts.fontFamily);
|
||||
const fontWeight = EditorOptions.fontWeight.validate(opts.fontWeight);
|
||||
const fontSize = EditorOptions.fontSize.validate(opts.fontSize);
|
||||
const lineHeight = EditorOptions.lineHeight.validate(opts.lineHeight);
|
||||
const letterSpacing = EditorOptions.letterSpacing.validate(opts.letterSpacing);
|
||||
return BareFontInfo._create(fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom);
|
||||
}
|
||||
|
||||
|
||||
let fontSize = safeParseFloat(opts.fontSize, EDITOR_FONT_DEFAULTS.fontSize);
|
||||
fontSize = clamp(fontSize, 0, MAXIMUM_FONT_SIZE);
|
||||
if (fontSize === 0) {
|
||||
fontSize = EDITOR_FONT_DEFAULTS.fontSize;
|
||||
} else if (fontSize < MINIMUM_FONT_SIZE) {
|
||||
fontSize = MINIMUM_FONT_SIZE;
|
||||
}
|
||||
|
||||
let lineHeight = safeParseInt(opts.lineHeight, 0);
|
||||
lineHeight = clamp(lineHeight, 0, MAXIMUM_LINE_HEIGHT);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
private static _create(fontFamily: string, fontWeight: string, fontSize: number, lineHeight: number, letterSpacing: number, zoomLevel: number, ignoreEditorZoom: boolean): BareFontInfo {
|
||||
if (lineHeight === 0) {
|
||||
lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
|
||||
} else if (lineHeight < MINIMUM_LINE_HEIGHT) {
|
||||
lineHeight = MINIMUM_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
let letterSpacing = safeParseFloat(opts.letterSpacing, 0);
|
||||
letterSpacing = clamp(letterSpacing, MINIMUM_LETTER_SPACING, MAXIMUM_LETTER_SPACING);
|
||||
|
||||
let editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
|
||||
const editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : EditorZoom.getZoomLevel() * 0.1);
|
||||
fontSize *= editorZoomLevelMultiplier;
|
||||
lineHeight *= editorZoomLevelMultiplier;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { RawContentChangedType } from 'vs/editor/common/model/textModelEvents';
|
||||
import * as viewEvents from 'vs/editor/common/view/viewEvents';
|
||||
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { dispose } from 'vs/base/common/lifecycle';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
function containsLineMappingChanged(events: viewEvents.ViewEvent[]): boolean {
|
||||
for (let i = 0, len = events.length; i < len; i++) {
|
||||
@@ -295,12 +296,12 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
this._columnSelectData = columnSelectData;
|
||||
}
|
||||
|
||||
public reveal(horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void {
|
||||
this._revealRange(target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType);
|
||||
public reveal(source: string, horizontal: boolean, target: RevealTarget, scrollType: editorCommon.ScrollType): void {
|
||||
this._revealRange(source, target, viewEvents.VerticalRevealType.Simple, horizontal, scrollType);
|
||||
}
|
||||
|
||||
public revealRange(revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) {
|
||||
this.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType);
|
||||
public revealRange(source: string, revealHorizontal: boolean, viewRange: Range, verticalType: viewEvents.VerticalRevealType, scrollType: editorCommon.ScrollType) {
|
||||
this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType);
|
||||
}
|
||||
|
||||
public scrollTo(desiredScrollTop: number): void {
|
||||
@@ -371,7 +372,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
}
|
||||
|
||||
this.setStates('restoreState', CursorChangeReason.NotSet, CursorState.fromModelSelections(desiredSelections));
|
||||
this.reveal(true, RevealTarget.Primary, editorCommon.ScrollType.Immediate);
|
||||
this.reveal('restoreState', true, RevealTarget.Primary, editorCommon.ScrollType.Immediate);
|
||||
}
|
||||
|
||||
private _onModelContentChanged(hadFlushEvent: boolean): void {
|
||||
@@ -399,7 +400,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
return this._columnSelectData;
|
||||
}
|
||||
const primaryCursor = this._cursors.getPrimaryCursor();
|
||||
const primaryPos = primaryCursor.viewState.position;
|
||||
const primaryPos = primaryCursor.viewState.selectionStart.getStartPosition();
|
||||
const viewLineNumber = primaryPos.lineNumber;
|
||||
const viewVisualColumn = CursorColumns.visibleColumnFromColumn2(this.context.config, this.context.viewModel, primaryPos);
|
||||
return {
|
||||
@@ -543,7 +544,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
return true;
|
||||
}
|
||||
|
||||
private _revealRange(revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void {
|
||||
private _revealRange(source: string, revealTarget: RevealTarget, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType): void {
|
||||
const viewPositions = this._cursors.getViewPositions();
|
||||
|
||||
let viewPosition = viewPositions[0];
|
||||
@@ -568,13 +569,13 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
}
|
||||
|
||||
const viewRange = new Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column);
|
||||
this.emitCursorRevealRange(viewRange, verticalType, revealHorizontal, scrollType);
|
||||
this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType);
|
||||
}
|
||||
|
||||
public emitCursorRevealRange(viewRange: Range, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) {
|
||||
public emitCursorRevealRange(source: string, viewRange: Range, verticalType: viewEvents.VerticalRevealType, revealHorizontal: boolean, scrollType: editorCommon.ScrollType) {
|
||||
try {
|
||||
const eventsCollector = this._beginEmit();
|
||||
eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(viewRange, verticalType, revealHorizontal, scrollType));
|
||||
eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, verticalType, revealHorizontal, scrollType));
|
||||
} finally {
|
||||
this._endEmit();
|
||||
}
|
||||
@@ -643,9 +644,17 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
autoClosedEnclosingRanges.push(new Range(lineNumber, openCharIndex + 1, lineNumber, closeCharIndex + 2));
|
||||
}
|
||||
}
|
||||
return cursorStateComputer(undoEdits);
|
||||
const selections = cursorStateComputer(undoEdits);
|
||||
if (selections) {
|
||||
// Don't recover the selection from markers because
|
||||
// we know what it should be.
|
||||
this._isHandling = true;
|
||||
}
|
||||
|
||||
return selections;
|
||||
});
|
||||
if (selections) {
|
||||
this._isHandling = false;
|
||||
this.setSelections(source, selections);
|
||||
}
|
||||
if (autoClosedCharactersRanges.length > 0) {
|
||||
@@ -665,7 +674,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
this._isDoingComposition = false;
|
||||
}
|
||||
|
||||
if (this._configuration.editor.readOnly) {
|
||||
if (this._configuration.options.get(EditorOption.readOnly)) {
|
||||
// All the remaining handlers will try to edit the model,
|
||||
// but we cannot edit when read only...
|
||||
this._onDidAttemptReadOnlyEdit.fire(undefined);
|
||||
@@ -740,7 +749,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
|
||||
this._validateAutoClosedActions();
|
||||
|
||||
if (this._emitStateChangedIfNecessary(source, cursorChangeReason, oldState)) {
|
||||
this._revealRange(RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth);
|
||||
this._revealRange(source, RevealTarget.Primary, viewEvents.VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, IConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditorAutoClosingStrategy, EditorAutoSurroundStrategy, ConfigurationChangedEvent, EditorAutoClosingOvertypeStrategy, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
@@ -55,8 +55,8 @@ export interface ICursors {
|
||||
setColumnSelectData(columnSelectData: IColumnSelectData): void;
|
||||
|
||||
setStates(source: string, reason: CursorChangeReason, states: PartialCursorState[] | null): void;
|
||||
reveal(horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void;
|
||||
revealRange(revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void;
|
||||
reveal(source: string, horizontal: boolean, target: RevealTarget, scrollType: ScrollType): void;
|
||||
revealRange(source: string, revealHorizontal: boolean, viewRange: Range, verticalType: VerticalRevealType, scrollType: ScrollType): void;
|
||||
|
||||
scrollTo(desiredScrollTop: number): void;
|
||||
|
||||
@@ -97,6 +97,7 @@ export class CursorConfiguration {
|
||||
public readonly emptySelectionClipboard: boolean;
|
||||
public readonly copyWithSyntaxHighlighting: boolean;
|
||||
public readonly multiCursorMergeOverlapping: boolean;
|
||||
public readonly multiCursorPaste: 'spread' | 'full';
|
||||
public readonly autoClosingBrackets: EditorAutoClosingStrategy;
|
||||
public readonly autoClosingQuotes: EditorAutoClosingStrategy;
|
||||
public readonly autoClosingOvertype: EditorAutoClosingOvertypeStrategy;
|
||||
@@ -110,19 +111,20 @@ export class CursorConfiguration {
|
||||
private readonly _languageIdentifier: LanguageIdentifier;
|
||||
private _electricChars: { [key: string]: boolean; } | null;
|
||||
|
||||
public static shouldRecreate(e: IConfigurationChangedEvent): boolean {
|
||||
public static shouldRecreate(e: ConfigurationChangedEvent): boolean {
|
||||
return (
|
||||
e.layoutInfo
|
||||
|| e.wordSeparators
|
||||
|| e.emptySelectionClipboard
|
||||
|| e.multiCursorMergeOverlapping
|
||||
|| e.autoClosingBrackets
|
||||
|| e.autoClosingQuotes
|
||||
|| e.autoClosingOvertype
|
||||
|| e.autoSurround
|
||||
|| e.useTabStops
|
||||
|| e.lineHeight
|
||||
|| e.readOnly
|
||||
e.hasChanged(EditorOption.layoutInfo)
|
||||
|| e.hasChanged(EditorOption.wordSeparators)
|
||||
|| e.hasChanged(EditorOption.emptySelectionClipboard)
|
||||
|| e.hasChanged(EditorOption.multiCursorMergeOverlapping)
|
||||
|| e.hasChanged(EditorOption.multiCursorPaste)
|
||||
|| e.hasChanged(EditorOption.autoClosingBrackets)
|
||||
|| e.hasChanged(EditorOption.autoClosingQuotes)
|
||||
|| e.hasChanged(EditorOption.autoClosingOvertype)
|
||||
|| e.hasChanged(EditorOption.autoSurround)
|
||||
|| e.hasChanged(EditorOption.useTabStops)
|
||||
|| e.hasChanged(EditorOption.lineHeight)
|
||||
|| e.hasChanged(EditorOption.readOnly)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,24 +135,26 @@ export class CursorConfiguration {
|
||||
) {
|
||||
this._languageIdentifier = languageIdentifier;
|
||||
|
||||
let c = configuration.editor;
|
||||
const options = configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this.readOnly = c.readOnly;
|
||||
this.readOnly = options.get(EditorOption.readOnly);
|
||||
this.tabSize = modelOptions.tabSize;
|
||||
this.indentSize = modelOptions.indentSize;
|
||||
this.insertSpaces = modelOptions.insertSpaces;
|
||||
this.pageSize = Math.max(1, Math.floor(c.layoutInfo.height / c.fontInfo.lineHeight) - 2);
|
||||
this.lineHeight = c.lineHeight;
|
||||
this.useTabStops = c.useTabStops;
|
||||
this.wordSeparators = c.wordSeparators;
|
||||
this.emptySelectionClipboard = c.emptySelectionClipboard;
|
||||
this.copyWithSyntaxHighlighting = c.copyWithSyntaxHighlighting;
|
||||
this.multiCursorMergeOverlapping = c.multiCursorMergeOverlapping;
|
||||
this.autoClosingBrackets = c.autoClosingBrackets;
|
||||
this.autoClosingQuotes = c.autoClosingQuotes;
|
||||
this.autoClosingOvertype = c.autoClosingOvertype;
|
||||
this.autoSurround = c.autoSurround;
|
||||
this.autoIndent = c.autoIndent;
|
||||
this.lineHeight = options.get(EditorOption.lineHeight);
|
||||
this.pageSize = Math.max(1, Math.floor(layoutInfo.height / this.lineHeight) - 2);
|
||||
this.useTabStops = options.get(EditorOption.useTabStops);
|
||||
this.wordSeparators = options.get(EditorOption.wordSeparators);
|
||||
this.emptySelectionClipboard = options.get(EditorOption.emptySelectionClipboard);
|
||||
this.copyWithSyntaxHighlighting = options.get(EditorOption.copyWithSyntaxHighlighting);
|
||||
this.multiCursorMergeOverlapping = options.get(EditorOption.multiCursorMergeOverlapping);
|
||||
this.multiCursorPaste = options.get(EditorOption.multiCursorPaste);
|
||||
this.autoClosingBrackets = options.get(EditorOption.autoClosingBrackets);
|
||||
this.autoClosingQuotes = options.get(EditorOption.autoClosingQuotes);
|
||||
this.autoClosingOvertype = options.get(EditorOption.autoClosingOvertype);
|
||||
this.autoSurround = options.get(EditorOption.autoSurround);
|
||||
this.autoIndent = options.get(EditorOption.autoIndent);
|
||||
|
||||
this.autoClosingPairsOpen2 = new Map<string, StandardAutoClosingPairConditional[]>();
|
||||
this.autoClosingPairsClose2 = new Map<string, StandardAutoClosingPairConditional[]>();
|
||||
|
||||
@@ -105,7 +105,7 @@ export class TypeOperations {
|
||||
});
|
||||
}
|
||||
|
||||
private static _distributePasteToCursors(selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): string[] | null {
|
||||
private static _distributePasteToCursors(config: CursorConfiguration, selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): string[] | null {
|
||||
if (pasteOnNewLine) {
|
||||
return null;
|
||||
}
|
||||
@@ -118,20 +118,27 @@ export class TypeOperations {
|
||||
return multicursorText;
|
||||
}
|
||||
|
||||
// Remove trailing \n if present
|
||||
if (text.charCodeAt(text.length - 1) === CharCode.LineFeed) {
|
||||
text = text.substr(0, text.length - 1);
|
||||
}
|
||||
let lines = text.split(/\r\n|\r|\n/);
|
||||
if (lines.length === selections.length) {
|
||||
return lines;
|
||||
if (config.multiCursorPaste === 'spread') {
|
||||
// Try to spread the pasted text in case the line count matches the cursor count
|
||||
// Remove trailing \n if present
|
||||
if (text.charCodeAt(text.length - 1) === CharCode.LineFeed) {
|
||||
text = text.substr(0, text.length - 1);
|
||||
}
|
||||
// Remove trailing \r if present
|
||||
if (text.charCodeAt(text.length - 1) === CharCode.CarriageReturn) {
|
||||
text = text.substr(0, text.length - 1);
|
||||
}
|
||||
let lines = text.split(/\r\n|\r|\n/);
|
||||
if (lines.length === selections.length) {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static paste(config: CursorConfiguration, model: ICursorSimpleModel, selections: Selection[], text: string, pasteOnNewLine: boolean, multicursorText: string[]): EditOperationResult {
|
||||
const distributedPaste = this._distributePasteToCursors(selections, text, pasteOnNewLine, multicursorText);
|
||||
const distributedPaste = this._distributePasteToCursors(config, selections, text, pasteOnNewLine, multicursorText);
|
||||
|
||||
if (distributedPaste) {
|
||||
selections = selections.sort(Range.compareRangesUsingStarts);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, IComputedEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
@@ -149,13 +149,13 @@ export interface ILineChange extends IChange {
|
||||
* @internal
|
||||
*/
|
||||
export interface IConfiguration extends IDisposable {
|
||||
onDidChange(listener: (e: editorOptions.IConfigurationChangedEvent) => void): IDisposable;
|
||||
onDidChange(listener: (e: ConfigurationChangedEvent) => void): IDisposable;
|
||||
|
||||
readonly editor: editorOptions.InternalEditorOptions;
|
||||
readonly options: IComputedEditorOptions;
|
||||
|
||||
setMaxLineNumber(maxLineNumber: number): void;
|
||||
updateOptions(newOptions: editorOptions.IEditorOptions): void;
|
||||
getRawOptions(): editorOptions.IEditorOptions;
|
||||
updateOptions(newOptions: IEditorOptions): void;
|
||||
getRawOptions(): IEditorOptions;
|
||||
observeReferenceElement(dimension?: IDimension): void;
|
||||
setIsDominatedByLongLines(isDominatedByLongLines: boolean): void;
|
||||
}
|
||||
@@ -263,7 +263,7 @@ export interface IEditor {
|
||||
/**
|
||||
* Update the editor's options after the editor has been created.
|
||||
*/
|
||||
updateOptions(newOptions: editorOptions.IEditorOptions): void;
|
||||
updateOptions(newOptions: IEditorOptions): void;
|
||||
|
||||
/**
|
||||
* Indicates that the editor becomes visible.
|
||||
|
||||
@@ -2621,8 +2621,8 @@ class DecorationOptions implements model.IDecorationOptions {
|
||||
readonly darkColor: string | ThemeColor;
|
||||
|
||||
constructor(options: model.IDecorationOptions) {
|
||||
this.color = options.color || strings.empty;
|
||||
this.darkColor = options.darkColor || strings.empty;
|
||||
this.color = options.color || '';
|
||||
this.darkColor = options.darkColor || '';
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2658,7 +2658,7 @@ export class ModelDecorationOverviewRulerOptions extends DecorationOptions {
|
||||
}
|
||||
let c = color ? theme.getColor(color.id) : null;
|
||||
if (!c) {
|
||||
return strings.empty;
|
||||
return '';
|
||||
}
|
||||
return c.toString();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ export class SearchParams {
|
||||
matchCase: this.matchCase,
|
||||
wholeWord: false,
|
||||
multiline: multiline,
|
||||
global: true
|
||||
global: true,
|
||||
unicode: true
|
||||
});
|
||||
} catch (err) {
|
||||
return null;
|
||||
|
||||
@@ -1402,6 +1402,15 @@ export interface IWebviewPanelOptions {
|
||||
readonly retainContextWhenHidden?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const enum WebviewEditorState {
|
||||
Readonly = 1,
|
||||
Unchanged = 2,
|
||||
Dirty = 3,
|
||||
}
|
||||
|
||||
export interface CodeLens {
|
||||
range: IRange;
|
||||
id?: string;
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface IDiffComputationResult {
|
||||
}
|
||||
|
||||
export interface IEditorWorkerService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
canComputeDiff(original: URI, modified: URI): boolean;
|
||||
computeDiff(original: URI, modified: URI, ignoreTrimWhitespace: boolean): Promise<IDiffComputationResult | null>;
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { SimpleWorkerClient, logOnceWebWorkerWarning, IWorkerClient } from 'vs/base/common/worker/simpleWorker';
|
||||
import { DefaultWorkerFactory } from 'vs/base/worker/defaultWorkerFactory';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
@@ -46,7 +45,7 @@ function canSyncModel(modelService: IModelService, resource: URI): boolean {
|
||||
}
|
||||
|
||||
export class EditorWorkerServiceImpl extends Disposable implements IEditorWorkerService {
|
||||
public _serviceBrand: any;
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
private readonly _modelService: IModelService;
|
||||
private readonly _workerManager: WorkerManager;
|
||||
@@ -146,7 +145,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
|
||||
}
|
||||
|
||||
provideCompletionItems(model: ITextModel, position: Position): Promise<modes.CompletionList | null> | undefined {
|
||||
const { wordBasedSuggestions } = this._configurationService.getValue<IEditorOptions>(model.uri, position, 'editor');
|
||||
const { wordBasedSuggestions } = this._configurationService.getValue<{ wordBasedSuggestions?: boolean }>(model.uri, position, 'editor');
|
||||
if (!wordBasedSuggestions) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class MarkerDecorations extends Disposable {
|
||||
|
||||
export class MarkerDecorationsService extends Disposable implements IMarkerDecorationsService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _onDidChangeMarker = this._register(new Emitter<ITextModel>());
|
||||
readonly onDidChangeMarker: Event<ITextModel> = this._onDidChangeMarker.event;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
export const IMarkerDecorationsService = createDecorator<IMarkerDecorationsService>('markerDecorationsService');
|
||||
|
||||
export interface IMarkerDecorationsService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
onDidChangeMarker: Event<ITextModel>;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface ILanguageSelection extends IDisposable {
|
||||
}
|
||||
|
||||
export interface IModeService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
onDidCreateMode: Event<IMode>;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class LanguageSelection extends Disposable implements ILanguageSelection {
|
||||
}
|
||||
|
||||
export class ModeServiceImpl implements IModeService {
|
||||
public _serviceBrand: any;
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
private readonly _instantiatedModes: { [modeId: string]: IMode; };
|
||||
private readonly _registry: LanguagesRegistry;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
export const IModelService = createDecorator<IModelService>('modelService');
|
||||
|
||||
export interface IModelService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
createModel(value: string | ITextBufferFactory, languageSelection: ILanguageSelection | null, resource?: URI, isForSimpleWidget?: boolean): ITextModel;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ interface IRawConfig {
|
||||
const DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? DefaultEndOfLine.LF : DefaultEndOfLine.CRLF;
|
||||
|
||||
export class ModelServiceImpl extends Disposable implements IModelService {
|
||||
public _serviceBrand: any;
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
private readonly _configurationService: IConfigurationService;
|
||||
private readonly _configurationServiceSubscription: IDisposable;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
export const ITextModelService = createDecorator<ITextModelService>('textModelService');
|
||||
|
||||
export interface ITextModelService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* Provided a resource URI, it will return a model reference
|
||||
|
||||
@@ -13,7 +13,7 @@ export const ITextResourceConfigurationService = createDecorator<ITextResourceCo
|
||||
|
||||
export interface ITextResourceConfigurationService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* Event that fires when the configuration changes.
|
||||
@@ -38,7 +38,7 @@ export const ITextResourcePropertiesService = createDecorator<ITextResourcePrope
|
||||
|
||||
export interface ITextResourcePropertiesService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* Returns the End of Line characters for the given resource
|
||||
|
||||
@@ -14,7 +14,7 @@ import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/co
|
||||
|
||||
export class TextResourceConfigurationService extends Disposable implements ITextResourceConfigurationService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
private readonly _onDidChangeConfiguration: Emitter<IConfigurationChangeEvent> = this._register(new Emitter<IConfigurationChangeEvent>());
|
||||
public readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
|
||||
|
||||
@@ -332,34 +332,13 @@ export enum CursorChangeReason {
|
||||
Redo = 6
|
||||
}
|
||||
|
||||
export enum RenderMinimap {
|
||||
None = 0,
|
||||
Small = 1,
|
||||
Large = 2,
|
||||
SmallBlocks = 3,
|
||||
LargeBlocks = 4
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes how to indent wrapped lines.
|
||||
*/
|
||||
export enum WrappingIndent {
|
||||
export enum AccessibilitySupport {
|
||||
/**
|
||||
* No indentation => wrapped lines begin at column 1.
|
||||
* This should be the browser case where it is not known if a screen reader is attached or no.
|
||||
*/
|
||||
None = 0,
|
||||
/**
|
||||
* Same => wrapped lines get the same indentation as the parent.
|
||||
*/
|
||||
Same = 1,
|
||||
/**
|
||||
* Indent => wrapped lines get +1 indentation toward the parent.
|
||||
*/
|
||||
Indent = 2,
|
||||
/**
|
||||
* DeepIndent => wrapped lines get +2 indentation toward the parent.
|
||||
*/
|
||||
DeepIndent = 3
|
||||
Unknown = 0,
|
||||
Disabled = 1,
|
||||
Enabled = 2
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,6 +401,14 @@ export enum TextEditorCursorStyle {
|
||||
UnderlineThin = 6
|
||||
}
|
||||
|
||||
export enum RenderMinimap {
|
||||
None = 0,
|
||||
Small = 1,
|
||||
Large = 2,
|
||||
SmallBlocks = 3,
|
||||
LargeBlocks = 4
|
||||
}
|
||||
|
||||
export enum RenderLineNumbersType {
|
||||
Off = 0,
|
||||
On = 1,
|
||||
@@ -430,6 +417,28 @@ export enum RenderLineNumbersType {
|
||||
Custom = 4
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes how to indent wrapped lines.
|
||||
*/
|
||||
export enum WrappingIndent {
|
||||
/**
|
||||
* No indentation => wrapped lines begin at column 1.
|
||||
*/
|
||||
None = 0,
|
||||
/**
|
||||
* Same => wrapped lines get the same indentation as the parent.
|
||||
*/
|
||||
Same = 1,
|
||||
/**
|
||||
* Indent => wrapped lines get +1 indentation toward the parent.
|
||||
*/
|
||||
Indent = 2,
|
||||
/**
|
||||
* DeepIndent => wrapped lines get +2 indentation toward the parent.
|
||||
*/
|
||||
DeepIndent = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* A positioning preference for rendering content widgets.
|
||||
*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ScrollEvent } from 'vs/base/common/scrollable';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
@@ -34,32 +34,14 @@ export class ViewConfigurationChangedEvent {
|
||||
|
||||
public readonly type = ViewEventType.ViewConfigurationChanged;
|
||||
|
||||
public readonly canUseLayerHinting: boolean;
|
||||
public readonly pixelRatio: boolean;
|
||||
public readonly editorClassName: boolean;
|
||||
public readonly lineHeight: boolean;
|
||||
public readonly readOnly: boolean;
|
||||
public readonly accessibilitySupport: boolean;
|
||||
public readonly emptySelectionClipboard: boolean;
|
||||
public readonly copyWithSyntaxHighlighting: boolean;
|
||||
public readonly layoutInfo: boolean;
|
||||
public readonly fontInfo: boolean;
|
||||
public readonly viewInfo: boolean;
|
||||
public readonly wrappingInfo: boolean;
|
||||
public readonly _source: ConfigurationChangedEvent;
|
||||
|
||||
constructor(source: IConfigurationChangedEvent) {
|
||||
this.canUseLayerHinting = source.canUseLayerHinting;
|
||||
this.pixelRatio = source.pixelRatio;
|
||||
this.editorClassName = source.editorClassName;
|
||||
this.lineHeight = source.lineHeight;
|
||||
this.readOnly = source.readOnly;
|
||||
this.accessibilitySupport = source.accessibilitySupport;
|
||||
this.emptySelectionClipboard = source.emptySelectionClipboard;
|
||||
this.copyWithSyntaxHighlighting = source.copyWithSyntaxHighlighting;
|
||||
this.layoutInfo = source.layoutInfo;
|
||||
this.fontInfo = source.fontInfo;
|
||||
this.viewInfo = source.viewInfo;
|
||||
this.wrappingInfo = source.wrappingInfo;
|
||||
constructor(source: ConfigurationChangedEvent) {
|
||||
this._source = source;
|
||||
}
|
||||
|
||||
public hasChanged(id: EditorOption): boolean {
|
||||
return this._source.hasChanged(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +180,13 @@ export class ViewRevealRangeRequestEvent {
|
||||
|
||||
public readonly scrollType: ScrollType;
|
||||
|
||||
constructor(range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) {
|
||||
/**
|
||||
* Source of the call that caused the event.
|
||||
*/
|
||||
readonly source: string;
|
||||
|
||||
constructor(source: string, range: Range, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) {
|
||||
this.source = source;
|
||||
this.range = range;
|
||||
this.verticalType = verticalType;
|
||||
this.revealHorizontal = revealHorizontal;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IScrollDimensions, IScrollPosition, ScrollEvent, Scrollable, ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { LinesLayout } from 'vs/editor/common/viewLayout/linesLayout';
|
||||
import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
@@ -27,14 +27,17 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
||||
super();
|
||||
|
||||
this._configuration = configuration;
|
||||
this._linesLayout = new LinesLayout(lineCount, this._configuration.editor.lineHeight);
|
||||
const options = this._configuration.options;
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
|
||||
this._linesLayout = new LinesLayout(lineCount, options.get(EditorOption.lineHeight));
|
||||
|
||||
this.scrollable = this._register(new Scrollable(0, scheduleAtNextAnimationFrame));
|
||||
this._configureSmoothScrollDuration();
|
||||
|
||||
this.scrollable.setScrollDimensions({
|
||||
width: configuration.editor.layoutInfo.contentWidth,
|
||||
height: configuration.editor.layoutInfo.contentHeight
|
||||
width: layoutInfo.contentWidth,
|
||||
height: layoutInfo.contentHeight
|
||||
});
|
||||
this.onDidScroll = this.scrollable.onScroll;
|
||||
|
||||
@@ -50,22 +53,24 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
||||
}
|
||||
|
||||
private _configureSmoothScrollDuration(): void {
|
||||
this.scrollable.setSmoothScrollDuration(this._configuration.editor.viewInfo.smoothScrolling ? SMOOTH_SCROLLING_TIME : 0);
|
||||
this.scrollable.setSmoothScrollDuration(this._configuration.options.get(EditorOption.smoothScrolling) ? SMOOTH_SCROLLING_TIME : 0);
|
||||
}
|
||||
|
||||
// ---- begin view event handlers
|
||||
|
||||
public onConfigurationChanged(e: IConfigurationChangedEvent): void {
|
||||
if (e.lineHeight) {
|
||||
this._linesLayout.setLineHeight(this._configuration.editor.lineHeight);
|
||||
public onConfigurationChanged(e: ConfigurationChangedEvent): void {
|
||||
const options = this._configuration.options;
|
||||
if (e.hasChanged(EditorOption.lineHeight)) {
|
||||
this._linesLayout.setLineHeight(options.get(EditorOption.lineHeight));
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
this.scrollable.setScrollDimensions({
|
||||
width: this._configuration.editor.layoutInfo.contentWidth,
|
||||
height: this._configuration.editor.layoutInfo.contentHeight
|
||||
width: layoutInfo.contentWidth,
|
||||
height: layoutInfo.contentHeight
|
||||
});
|
||||
}
|
||||
if (e.viewInfo) {
|
||||
if (e.hasChanged(EditorOption.smoothScrolling)) {
|
||||
this._configureSmoothScrollDuration();
|
||||
}
|
||||
this._updateHeight();
|
||||
@@ -83,7 +88,9 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
||||
// ---- end view event handlers
|
||||
|
||||
private _getHorizontalScrollbarHeight(scrollDimensions: IScrollDimensions): number {
|
||||
if (this._configuration.editor.viewInfo.scrollbar.horizontal === ScrollbarVisibility.Hidden) {
|
||||
const options = this._configuration.options;
|
||||
const scrollbar = options.get(EditorOption.scrollbar);
|
||||
if (scrollbar.horizontal === ScrollbarVisibility.Hidden) {
|
||||
// horizontal scrollbar not visible
|
||||
return 0;
|
||||
}
|
||||
@@ -91,15 +98,16 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
||||
// horizontal scrollbar not visible
|
||||
return 0;
|
||||
}
|
||||
return this._configuration.editor.viewInfo.scrollbar.horizontalScrollbarSize;
|
||||
return scrollbar.horizontalScrollbarSize;
|
||||
}
|
||||
|
||||
private _getTotalHeight(): number {
|
||||
const options = this._configuration.options;
|
||||
const scrollDimensions = this.scrollable.getScrollDimensions();
|
||||
|
||||
let result = this._linesLayout.getLinesTotalHeight();
|
||||
if (this._configuration.editor.viewInfo.scrollBeyondLastLine) {
|
||||
result += scrollDimensions.height - this._configuration.editor.lineHeight;
|
||||
if (options.get(EditorOption.scrollBeyondLastLine)) {
|
||||
result += scrollDimensions.height - options.get(EditorOption.lineHeight);
|
||||
} else {
|
||||
result += this._getHorizontalScrollbarHeight(scrollDimensions);
|
||||
}
|
||||
@@ -138,9 +146,11 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
||||
}
|
||||
|
||||
private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number {
|
||||
let isViewportWrapping = this._configuration.editor.wrappingInfo.isViewportWrapping;
|
||||
const options = this._configuration.options;
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
let isViewportWrapping = wrappingInfo.isViewportWrapping;
|
||||
if (!isViewportWrapping) {
|
||||
const extraHorizontalSpace = this._configuration.editor.viewInfo.scrollBeyondLastColumn * this._configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
|
||||
const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth();
|
||||
return Math.max(maxLineWidth + extraHorizontalSpace, viewportWidth, whitespaceMinWidth);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { IModelDecoration, ITextModel } from 'vs/editor/common/model';
|
||||
import { IViewModelLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection';
|
||||
import { ICoordinatesConverter, InlineDecoration, InlineDecorationType, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export interface IDecorationsViewportData {
|
||||
/**
|
||||
@@ -103,7 +104,7 @@ export class ViewModelDecorations implements IDisposable {
|
||||
}
|
||||
|
||||
private _getDecorationsViewportData(viewportRange: Range): IDecorationsViewportData {
|
||||
const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.editor.readOnly);
|
||||
const modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, this.configuration.options.get(EditorOption.readOnly));
|
||||
const startLineNumber = viewportRange.startLineNumber;
|
||||
const endLineNumber = viewportRange.endLineNumber;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IConfigurationChangedEvent, EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EDITOR_FONT_DEFAULTS, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
@@ -59,21 +59,27 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
this.lines = new IdentityLinesCollection(this.model);
|
||||
|
||||
} else {
|
||||
const conf = this.configuration.editor;
|
||||
const options = this.configuration.options;
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const wordWrapBreakAfterCharacters = options.get(EditorOption.wordWrapBreakAfterCharacters);
|
||||
const wordWrapBreakBeforeCharacters = options.get(EditorOption.wordWrapBreakBeforeCharacters);
|
||||
const wordWrapBreakObtrusiveCharacters = options.get(EditorOption.wordWrapBreakObtrusiveCharacters);
|
||||
const wrappingIndent = options.get(EditorOption.wrappingIndent);
|
||||
|
||||
let hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory(
|
||||
conf.wrappingInfo.wordWrapBreakBeforeCharacters,
|
||||
conf.wrappingInfo.wordWrapBreakAfterCharacters,
|
||||
conf.wrappingInfo.wordWrapBreakObtrusiveCharacters
|
||||
wordWrapBreakBeforeCharacters,
|
||||
wordWrapBreakAfterCharacters,
|
||||
wordWrapBreakObtrusiveCharacters
|
||||
);
|
||||
|
||||
this.lines = new SplitLinesCollection(
|
||||
this.model,
|
||||
hardWrappingLineMapperFactory,
|
||||
this.model.getOptions().tabSize,
|
||||
conf.wrappingInfo.wrappingColumn,
|
||||
conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth,
|
||||
conf.wrappingInfo.wrappingIndent
|
||||
wrappingInfo.wrappingColumn,
|
||||
fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth,
|
||||
wrappingIndent
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,7 +142,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
this.hasFocus = hasFocus;
|
||||
}
|
||||
|
||||
private _onConfigurationChanged(eventsCollector: viewEvents.ViewEventsCollector, e: IConfigurationChangedEvent): void {
|
||||
private _onConfigurationChanged(eventsCollector: viewEvents.ViewEventsCollector, e: ConfigurationChangedEvent): void {
|
||||
|
||||
// We might need to restore the current centered view range, so save it (if available)
|
||||
let previousViewportStartModelPosition: Position | null = null;
|
||||
@@ -146,9 +152,12 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
}
|
||||
let restorePreviousViewportStart = false;
|
||||
|
||||
const conf = this.configuration.editor;
|
||||
const options = this.configuration.options;
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const wrappingIndent = options.get(EditorOption.wrappingIndent);
|
||||
|
||||
if (this.lines.setWrappingSettings(conf.wrappingInfo.wrappingIndent, conf.wrappingInfo.wrappingColumn, conf.fontInfo.typicalFullwidthCharacterWidth / conf.fontInfo.typicalHalfwidthCharacterWidth)) {
|
||||
if (this.lines.setWrappingSettings(wrappingIndent, wrappingInfo.wrappingColumn, fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth)) {
|
||||
eventsCollector.emit(new viewEvents.ViewFlushedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
@@ -161,7 +170,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
}
|
||||
}
|
||||
|
||||
if (e.readOnly) {
|
||||
if (e.hasChanged(EditorOption.readOnly)) {
|
||||
// Must read again all decorations due to readOnly filtering
|
||||
this.decorations.reset();
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
@@ -552,7 +561,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
}
|
||||
|
||||
public getAllOverviewRulerDecorations(theme: ITheme): IOverviewRulerDecorations {
|
||||
return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.editor.readOnly, theme);
|
||||
return this.lines.getAllOverviewRulerDecorations(this.editorId, this.configuration.options.get(EditorOption.readOnly), theme);
|
||||
}
|
||||
|
||||
public invalidateOverviewRulerColorCache(): void {
|
||||
@@ -666,7 +675,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
range = new Range(lineNumber, this.model.getLineMinColumn(lineNumber), lineNumber, this.model.getLineMaxColumn(lineNumber));
|
||||
}
|
||||
|
||||
const fontInfo = this.configuration.editor.fontInfo;
|
||||
const fontInfo = this.configuration.options.get(EditorOption.fontInfo);
|
||||
const colorMap = this._getColorMap();
|
||||
const fontFamily = fontInfo.fontFamily === EDITOR_FONT_DEFAULTS.fontFamily ? fontInfo.fontFamily : `'${fontInfo.fontFamily}', ${EDITOR_FONT_DEFAULTS.fontFamily}`;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
|
||||
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant, themeColorFromId } from 'vs/platform/theme/common/themeService';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const overviewRulerBracketMatchForeground = registerColor('editorOverviewRuler.bracketMatchForeground', { dark: '#A0A0A0', light: '#A0A0A0', hc: '#A0A0A0' }, nls.localize('overviewRulerBracketMatchForeground', 'Overview ruler marker color for matching brackets.'));
|
||||
|
||||
@@ -104,7 +105,7 @@ export class BracketMatchingController extends Disposable implements editorCommo
|
||||
this._lastVersionId = 0;
|
||||
this._decorations = [];
|
||||
this._updateBracketsSoon = this._register(new RunOnceScheduler(() => this._updateBrackets(), 50));
|
||||
this._matchBrackets = this._editor.getConfiguration().contribInfo.matchBrackets;
|
||||
this._matchBrackets = this._editor.getOption(EditorOption.matchBrackets);
|
||||
|
||||
this._updateBracketsSoon.schedule();
|
||||
this._register(editor.onDidChangeCursorPosition((e) => {
|
||||
@@ -130,7 +131,7 @@ export class BracketMatchingController extends Disposable implements editorCommo
|
||||
this._updateBracketsSoon.schedule();
|
||||
}));
|
||||
this._register(editor.onDidChangeConfiguration((e) => {
|
||||
this._matchBrackets = this._editor.getConfiguration().contribInfo.matchBrackets;
|
||||
this._matchBrackets = this._editor.getOption(EditorOption.matchBrackets);
|
||||
if (!this._matchBrackets && this._decorations.length > 0) {
|
||||
// Remove existing decorations if bracket matching is off
|
||||
this._decorations = this._editor.deltaDecorations(this._decorations, []);
|
||||
@@ -332,4 +333,4 @@ MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
|
||||
title: nls.localize({ key: 'miGoToBracket', comment: ['&& denotes a mnemonic'] }, "Go to &&Bracket")
|
||||
},
|
||||
order: 2
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste';
|
||||
|
||||
@@ -94,7 +95,7 @@ class ExecCommandCutAction extends ExecCommandAction {
|
||||
return;
|
||||
}
|
||||
|
||||
const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard;
|
||||
const emptySelectionClipboard = editor.getOption(EditorOption.emptySelectionClipboard);
|
||||
|
||||
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
|
||||
return;
|
||||
@@ -143,7 +144,7 @@ class ExecCommandCopyAction extends ExecCommandAction {
|
||||
return;
|
||||
}
|
||||
|
||||
const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard;
|
||||
const emptySelectionClipboard = editor.getOption(EditorOption.emptySelectionClipboard);
|
||||
|
||||
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
|
||||
return;
|
||||
@@ -209,7 +210,7 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
|
||||
return;
|
||||
}
|
||||
|
||||
const emptySelectionClipboard = editor.getConfiguration().emptySelectionClipboard;
|
||||
const emptySelectionClipboard = editor.getOption(EditorOption.emptySelectionClipboard);
|
||||
|
||||
if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -15,7 +15,7 @@ import { CodeAction, CodeActionContext, CodeActionProviderRegistry, CodeActionTr
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { CodeActionFilter, CodeActionKind, CodeActionTrigger, filtersAction, mayIncludeActionsOfKind } from './codeActionTrigger';
|
||||
import { TextModelCancellationTokenSource } from 'vs/editor/browser/core/editorState';
|
||||
import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore, IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export interface CodeActionSet extends IDisposable {
|
||||
readonly actions: readonly CodeAction[];
|
||||
@@ -143,6 +143,6 @@ registerLanguageCommand('_executeCodeActionProvider', async function (accessor,
|
||||
{ type: 'manual', filter: { includeSourceActions: true, kind: kind && kind.value ? new CodeActionKind(kind.value) : undefined } },
|
||||
CancellationToken.None);
|
||||
|
||||
setTimeout(() => codeActionSet.dispose(), 0);
|
||||
setTimeout(() => codeActionSet.dispose(), 100);
|
||||
return codeActionSet.actions;
|
||||
});
|
||||
|
||||
@@ -3,30 +3,32 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { escapeRegExpCharacters } from 'vs/base/common/strings';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, EditorCommand, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { CodeAction } from 'vs/editor/common/modes';
|
||||
import { CodeActionSet } from 'vs/editor/contrib/codeAction/codeAction';
|
||||
import { CodeActionUi } from 'vs/editor/contrib/codeAction/codeActionUi';
|
||||
import { MessageController } from 'vs/editor/contrib/message/messageController';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { CodeActionModel, CodeActionsState, SUPPORTED_CODE_ACTIONS } from './codeActionModel';
|
||||
import { CodeActionAutoApply, CodeActionFilter, CodeActionKind, CodeActionTrigger } from './codeActionTrigger';
|
||||
import { CodeActionSet } from 'vs/editor/contrib/codeAction/codeAction';
|
||||
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
|
||||
function contextKeyForSupportedActions(kind: CodeActionKind) {
|
||||
return ContextKeyExpr.regex(
|
||||
@@ -56,6 +58,7 @@ export class QuickFixController extends Disposable implements IEditorContributio
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -107,21 +110,42 @@ export class QuickFixController extends Disposable implements IEditorContributio
|
||||
}
|
||||
|
||||
private _applyCodeAction(action: CodeAction): Promise<void> {
|
||||
return applyCodeAction(action, this._bulkEditService, this._commandService, this._editor);
|
||||
return this._instantiationService.invokeFunction(applyCodeAction, action, this._bulkEditService, this._commandService, this._editor);
|
||||
}
|
||||
}
|
||||
|
||||
export async function applyCodeAction(
|
||||
accessor: ServicesAccessor,
|
||||
action: CodeAction,
|
||||
bulkEditService: IBulkEditService,
|
||||
commandService: ICommandService,
|
||||
editor?: ICodeEditor,
|
||||
): Promise<void> {
|
||||
const notificationService = accessor.get(INotificationService);
|
||||
if (action.edit) {
|
||||
await bulkEditService.apply(action.edit, { editor });
|
||||
}
|
||||
if (action.command) {
|
||||
await commandService.executeCommand(action.command.id, ...(action.command.arguments || []));
|
||||
try {
|
||||
await commandService.executeCommand(action.command.id, ...(action.command.arguments || []));
|
||||
} catch (err) {
|
||||
const message = asMessage(err);
|
||||
notificationService.error(
|
||||
typeof message === 'string'
|
||||
? message
|
||||
: nls.localize('applyCodeActionFailed', "An unknown error occurred while applying the code action"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function asMessage(err: any): string | undefined {
|
||||
if (typeof err === 'string') {
|
||||
return err;
|
||||
} else if (err instanceof Error && typeof err.message === 'string') {
|
||||
return err.message;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { getCodeActions, CodeActionSet } from './codeAction';
|
||||
import { CodeActionTrigger } from './codeActionTrigger';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export const SUPPORTED_CODE_ACTIONS = new RawContextKey<string>('supportedCodeAction', '');
|
||||
|
||||
@@ -192,7 +193,7 @@ export class CodeActionModel extends Disposable {
|
||||
const model = this._editor.getModel();
|
||||
if (model
|
||||
&& CodeActionProviderRegistry.has(model)
|
||||
&& !this._editor.getConfiguration().readOnly
|
||||
&& !this._editor.getOption(EditorOption.readOnly)
|
||||
) {
|
||||
const supportedActions: string[] = [];
|
||||
for (const provider of CodeActionProviderRegistry.all(model)) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { CodeActionSet } from 'vs/editor/contrib/codeAction/codeAction';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
namespace LightBulbState {
|
||||
|
||||
@@ -78,7 +79,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
// a bit of extra work to make sure the menu
|
||||
// doesn't cover the line-text
|
||||
const { top, height } = dom.getDomNodePagePosition(this._domNode);
|
||||
const { lineHeight } = this._editor.getConfiguration();
|
||||
const lineHeight = this._editor.getOption(EditorOption.lineHeight);
|
||||
|
||||
let pad = Math.floor(lineHeight / 3);
|
||||
if (this._state.widgetPosition.position !== null && this._state.widgetPosition.position.lineNumber < this._state.editorPosition.lineNumber) {
|
||||
@@ -106,7 +107,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
}));
|
||||
this._register(this._editor.onDidChangeConfiguration(e => {
|
||||
// hide when told to do so
|
||||
if (e.contribInfo && !this._editor.getConfiguration().contribInfo.lightbulbEnabled) {
|
||||
if (e.hasChanged(EditorOption.lightbulb) && !this._editor.getOption(EditorOption.lightbulb).enabled) {
|
||||
this.hide();
|
||||
}
|
||||
}));
|
||||
@@ -137,8 +138,8 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
return this.hide();
|
||||
}
|
||||
|
||||
const config = this._editor.getConfiguration();
|
||||
if (!config.contribInfo.lightbulbEnabled) {
|
||||
const options = this._editor.getOptions();
|
||||
if (!options.get(EditorOption.lightbulb).enabled) {
|
||||
return this.hide();
|
||||
}
|
||||
|
||||
@@ -149,9 +150,10 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
}
|
||||
|
||||
const tabSize = model.getOptions().tabSize;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const lineContent = model.getLineContent(lineNumber);
|
||||
const indent = TextModel.computeIndentLevel(lineContent, tabSize);
|
||||
const lineHasSpace = config.fontInfo.spaceWidth * indent > 22;
|
||||
const lineHasSpace = fontInfo.spaceWidth * indent > 22;
|
||||
const isFolded = (lineNumber: number) => {
|
||||
return lineNumber > 2 && this._editor.getTopForLineNumber(lineNumber) === this._editor.getTopForLineNumber(lineNumber - 1);
|
||||
};
|
||||
@@ -162,7 +164,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
|
||||
effectiveLineNumber -= 1;
|
||||
} else if (!isFolded(lineNumber + 1)) {
|
||||
effectiveLineNumber += 1;
|
||||
} else if (column * config.fontInfo.spaceWidth < 22) {
|
||||
} else if (column * fontInfo.spaceWidth < 22) {
|
||||
// cannot show lightbulb above/below and showing
|
||||
// it inline would overlay the cursor...
|
||||
return this.hide();
|
||||
|
||||
@@ -17,7 +17,7 @@ import { once } from 'vs/base/common/functional';
|
||||
export const ICodeLensCache = createDecorator<ICodeLensCache>('ICodeLensCache');
|
||||
|
||||
export interface ICodeLensCache {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
put(model: ITextModel, data: CodeLensModel): void;
|
||||
get(model: ITextModel): CodeLensModel | undefined;
|
||||
delete(model: ITextModel): void;
|
||||
@@ -38,7 +38,7 @@ class CacheItem {
|
||||
|
||||
export class CodeLensCache implements ICodeLensCache {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _fakeProvider = new class implements CodeLensProvider {
|
||||
provideCodeLenses(): CodeLensList {
|
||||
|
||||
@@ -22,14 +22,14 @@ export class CodeLensModel {
|
||||
|
||||
lenses: CodeLensItem[] = [];
|
||||
|
||||
private readonly _dispoables = new DisposableStore();
|
||||
private readonly _disposables = new DisposableStore();
|
||||
|
||||
dispose(): void {
|
||||
this._dispoables.dispose();
|
||||
this._disposables.dispose();
|
||||
}
|
||||
|
||||
add(list: CodeLensList, provider: CodeLensProvider): void {
|
||||
this._dispoables.add(list);
|
||||
this._disposables.add(list);
|
||||
for (const symbol of list.lenses) {
|
||||
this.lenses.push({ symbol, provider });
|
||||
}
|
||||
@@ -89,8 +89,10 @@ registerLanguageCommand('_executeCodeLensProvider', function (accessor, args) {
|
||||
}
|
||||
|
||||
const result: CodeLens[] = [];
|
||||
const disposables = new DisposableStore();
|
||||
return getCodeLensData(model, CancellationToken.None).then(value => {
|
||||
|
||||
disposables.add(value);
|
||||
let resolve: Promise<any>[] = [];
|
||||
|
||||
for (const item of value.lenses) {
|
||||
@@ -101,9 +103,13 @@ registerLanguageCommand('_executeCodeLensProvider', function (accessor, args) {
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all(resolve).finally(() => setTimeout(() => value.dispose(), 0));
|
||||
return Promise.all(resolve);
|
||||
|
||||
}).then(() => {
|
||||
return result;
|
||||
}).finally(() => {
|
||||
// make sure to return results, then (on next tick)
|
||||
// dispose the results
|
||||
setTimeout(() => disposables.dispose(), 100);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ import { CodeLensWidget, CodeLensHelper } from 'vs/editor/contrib/codelens/codel
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { ICodeLensCache } from 'vs/editor/contrib/codelens/codeLensCache';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
|
||||
@@ -40,13 +41,13 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
@INotificationService private readonly _notificationService: INotificationService,
|
||||
@ICodeLensCache private readonly _codeLensCache: ICodeLensCache
|
||||
) {
|
||||
this._isEnabled = this._editor.getConfiguration().contribInfo.codeLens;
|
||||
this._isEnabled = this._editor.getOption(EditorOption.codeLens);
|
||||
|
||||
this._globalToDispose.add(this._editor.onDidChangeModel(() => this._onModelChange()));
|
||||
this._globalToDispose.add(this._editor.onDidChangeModelLanguage(() => this._onModelChange()));
|
||||
this._globalToDispose.add(this._editor.onDidChangeConfiguration(() => {
|
||||
const prevIsEnabled = this._isEnabled;
|
||||
this._isEnabled = this._editor.getConfiguration().contribInfo.codeLens;
|
||||
this._isEnabled = this._editor.getOption(EditorOption.codeLens);
|
||||
if (prevIsEnabled !== this._isEnabled) {
|
||||
this._onModelChange();
|
||||
}
|
||||
@@ -204,7 +205,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
|
||||
}
|
||||
}));
|
||||
this._localToDispose.add(this._editor.onDidChangeConfiguration(e => {
|
||||
if (e.fontInfo) {
|
||||
if (e.hasChanged(EditorOption.fontInfo)) {
|
||||
for (const lens of this._lenses) {
|
||||
lens.updateHeight();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { editorCodeLensForeground } from 'vs/editor/common/view/editorColorRegis
|
||||
import { CodeLensItem } from 'vs/editor/contrib/codelens/codelens';
|
||||
import { editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
class CodeLensViewZone implements editorBrowser.IViewZone {
|
||||
|
||||
@@ -80,7 +81,9 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
|
||||
}
|
||||
|
||||
updateHeight(): void {
|
||||
const { fontInfo, lineHeight } = this._editor.getConfiguration();
|
||||
const options = this._editor.getOptions();
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const lineHeight = options.get(EditorOption.lineHeight);
|
||||
this._domNode.style.height = `${Math.round(lineHeight * 1.1)}px`;
|
||||
this._domNode.style.lineHeight = `${lineHeight}px`;
|
||||
this._domNode.style.fontSize = `${Math.round(fontInfo.fontSize * 0.9)}px`;
|
||||
|
||||
@@ -19,6 +19,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { ColorProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { IColorData, getColors } from 'vs/editor/contrib/colorPicker/color';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const MAX_DECORATORS = 500;
|
||||
|
||||
@@ -84,7 +85,7 @@ export class ColorDetector extends Disposable implements IEditorContribution {
|
||||
}
|
||||
}
|
||||
|
||||
return this._editor.getConfiguration().contribInfo.colorDecorators;
|
||||
return this._editor.getOption(EditorOption.colorDecorators);
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
|
||||
@@ -22,6 +22,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class ContextMenuController implements IEditorContribution {
|
||||
|
||||
@@ -66,7 +67,7 @@ export class ContextMenuController implements IEditorContribution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._editor.getConfiguration().contribInfo.contextmenu) {
|
||||
if (!this._editor.getOption(EditorOption.contextmenu)) {
|
||||
this._editor.focus();
|
||||
// Ensure the cursor is at the position of the mouse click
|
||||
if (e.target.position && !this._editor.getSelection().containsPosition(e.target.position)) {
|
||||
@@ -104,7 +105,7 @@ export class ContextMenuController implements IEditorContribution {
|
||||
}
|
||||
|
||||
public showContextMenu(anchor?: IAnchor | null): void {
|
||||
if (!this._editor.getConfiguration().contribInfo.contextmenu) {
|
||||
if (!this._editor.getOption(EditorOption.contextmenu)) {
|
||||
return; // Context menu is turned off through configuration
|
||||
}
|
||||
if (!this._editor.hasModel()) {
|
||||
@@ -147,7 +148,7 @@ export class ContextMenuController implements IEditorContribution {
|
||||
}
|
||||
|
||||
// Disable hover
|
||||
const oldHoverSetting = this._editor.getConfiguration().contribInfo.hover;
|
||||
const oldHoverSetting = this._editor.getOption(EditorOption.hover);
|
||||
this._editor.updateOptions({
|
||||
hover: {
|
||||
enabled: false
|
||||
|
||||
@@ -19,6 +19,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
function hasTriggerModifier(e: IKeyboardEvent | IMouseEvent): boolean {
|
||||
if (isMacintosh) {
|
||||
@@ -67,7 +68,7 @@ export class DragAndDropController extends Disposable implements editorCommon.IE
|
||||
}
|
||||
|
||||
private onEditorKeyDown(e: IKeyboardEvent): void {
|
||||
if (!this._editor.getConfiguration().dragAndDrop) {
|
||||
if (!this._editor.getOption(EditorOption.dragAndDrop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ export class DragAndDropController extends Disposable implements editorCommon.IE
|
||||
}
|
||||
|
||||
private onEditorKeyUp(e: IKeyboardEvent): void {
|
||||
if (!this._editor.getConfiguration().dragAndDrop) {
|
||||
if (!this._editor.getOption(EditorOption.dragAndDrop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,6 +386,9 @@ export class OutlineModel extends TreeElement {
|
||||
|
||||
protected constructor(readonly textModel: ITextModel) {
|
||||
super();
|
||||
|
||||
this.id = 'root';
|
||||
this.parent = undefined;
|
||||
}
|
||||
|
||||
adopt(): OutlineModel {
|
||||
|
||||
@@ -26,6 +26,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const SEARCH_STRING_MAX_LENGTH = 524288;
|
||||
|
||||
@@ -120,7 +121,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
||||
if (shouldRestartFind) {
|
||||
this._start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: false && this._editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromSelection: false && this._editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
@@ -352,7 +353,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
||||
}
|
||||
|
||||
public getGlobalBufferTerm(): string {
|
||||
if (this._editor.getConfiguration().contribInfo.find.globalFindClipboard
|
||||
if (this._editor.getOption(EditorOption.find).globalFindClipboard
|
||||
&& this._clipboardService
|
||||
&& this._editor.hasModel()
|
||||
&& !this._editor.getModel().isTooLargeForSyncing()
|
||||
@@ -363,7 +364,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
|
||||
}
|
||||
|
||||
public setGlobalBufferTerm(text: string) {
|
||||
if (this._editor.getConfiguration().contribInfo.find.globalFindClipboard
|
||||
if (this._editor.getOption(EditorOption.find).globalFindClipboard
|
||||
&& this._clipboardService
|
||||
&& this._editor.hasModel()
|
||||
&& !this._editor.getModel().isTooLargeForSyncing()
|
||||
@@ -398,7 +399,7 @@ export class FindController extends CommonFindController implements IFindControl
|
||||
this._createFindWidget();
|
||||
}
|
||||
|
||||
if (!this._widget!.getPosition() && this._editor.getConfiguration().contribInfo.find.autoFindInSelection) {
|
||||
if (!this._widget!.getPosition() && this._editor.getOption(EditorOption.find).autoFindInSelection) {
|
||||
// not visible yet so we need to set search scope if `editor.find.autoFindInSelection` is `true`
|
||||
opts.updateSearchScope = true;
|
||||
}
|
||||
@@ -456,8 +457,8 @@ export class StartFindAction extends EditorAction {
|
||||
if (controller) {
|
||||
controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getConfiguration().contribInfo.find.globalFindClipboard,
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).globalFindClipboard,
|
||||
shouldFocus: FindStartFocusAction.FocusFindInput,
|
||||
shouldAnimate: true,
|
||||
updateSearchScope: false
|
||||
@@ -507,7 +508,7 @@ export abstract class MatchFindAction extends EditorAction {
|
||||
if (controller && !this._run(controller)) {
|
||||
controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: true,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
@@ -619,7 +620,7 @@ export abstract class SelectionMatchFindAction extends EditorAction {
|
||||
if (!this._run(controller)) {
|
||||
controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
@@ -698,7 +699,7 @@ export class StartFindReplaceAction extends EditorAction {
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor | null, editor: ICodeEditor): void {
|
||||
if (!editor.hasModel() || editor.getConfiguration().readOnly) {
|
||||
if (!editor.hasModel() || editor.getOption(EditorOption.readOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -708,7 +709,7 @@ export class StartFindReplaceAction extends EditorAction {
|
||||
// we only seed search string from selection when the current selection is single line and not empty,
|
||||
// + the find input is not focused
|
||||
let seedSearchStringFromSelection = !currentSelection.isEmpty()
|
||||
&& currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection
|
||||
&& currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getOption(EditorOption.find).seedSearchStringFromSelection
|
||||
&& !findInputFocused;
|
||||
/*
|
||||
* if the existing search string in find widget is empty and we don't seed search string from selection, it means the Find Input is still empty, so we should focus the Find Input instead of Replace Input.
|
||||
@@ -725,7 +726,7 @@ export class StartFindReplaceAction extends EditorAction {
|
||||
controller.start({
|
||||
forceRevealReplace: true,
|
||||
seedSearchStringFromSelection: seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
shouldFocus: shouldFocus,
|
||||
shouldAnimate: true,
|
||||
updateSearchScope: false
|
||||
|
||||
@@ -22,6 +22,7 @@ import { ReplaceAllCommand } from 'vs/editor/contrib/find/replaceAllCommand';
|
||||
import { ReplacePattern, parseReplaceString } from 'vs/editor/contrib/find/replacePattern';
|
||||
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export const CONTEXT_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('findWidgetVisible', false);
|
||||
export const CONTEXT_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = CONTEXT_FIND_WIDGET_VISIBLE.toNegated();
|
||||
@@ -287,12 +288,12 @@ export class FindModelBoundToEditorModel {
|
||||
|
||||
let position = new Position(lineNumber, column);
|
||||
|
||||
let prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false);
|
||||
let prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false);
|
||||
|
||||
if (prevMatch && prevMatch.range.isEmpty() && prevMatch.range.getStartPosition().equals(position)) {
|
||||
// Looks like we're stuck at this position, unacceptable!
|
||||
position = this._prevSearchPosition(position);
|
||||
prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, false);
|
||||
prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false);
|
||||
}
|
||||
|
||||
if (!prevMatch) {
|
||||
@@ -379,12 +380,12 @@ export class FindModelBoundToEditorModel {
|
||||
|
||||
let position = new Position(lineNumber, column);
|
||||
|
||||
let nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches);
|
||||
let nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, captureMatches);
|
||||
|
||||
if (forceMove && nextMatch && nextMatch.range.isEmpty() && nextMatch.range.getStartPosition().equals(position)) {
|
||||
// Looks like we're stuck at this position, unacceptable!
|
||||
position = this._nextSearchPosition(position);
|
||||
nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches);
|
||||
nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, captureMatches);
|
||||
}
|
||||
|
||||
if (!nextMatch) {
|
||||
@@ -438,7 +439,7 @@ export class FindModelBoundToEditorModel {
|
||||
|
||||
private _findMatches(findScope: Range | null, captureMatches: boolean, limitResultCount: number): FindMatch[] {
|
||||
let searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
|
||||
return this._editor.getModel().findMatches(this._state.searchString, searchRange, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null, captureMatches, limitResultCount);
|
||||
return this._editor.getModel().findMatches(this._state.searchString, searchRange, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, captureMatches, limitResultCount);
|
||||
}
|
||||
|
||||
public replaceAll(): void {
|
||||
@@ -459,7 +460,7 @@ export class FindModelBoundToEditorModel {
|
||||
}
|
||||
|
||||
private _largeReplaceAll(): void {
|
||||
const searchParams = new SearchParams(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getConfiguration().wordSeparators : null);
|
||||
const searchParams = new SearchParams(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null);
|
||||
const searchData = searchParams.parseSearchRequest();
|
||||
if (!searchData) {
|
||||
return;
|
||||
@@ -467,7 +468,7 @@ export class FindModelBoundToEditorModel {
|
||||
|
||||
let searchRegex = searchData.regex;
|
||||
if (!searchRegex.multiline) {
|
||||
let mod = 'm';
|
||||
let mod = 'mu';
|
||||
if (searchRegex.ignoreCase) {
|
||||
mod += 'i';
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import { toDisposable } from 'vs/base/common/lifecycle';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, IViewZone, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CONTEXT_FIND_INPUT_FOCUSED, CONTEXT_REPLACE_INPUT_FOCUSED, FIND_IDS, MATCHES_LIMIT } from 'vs/editor/contrib/find/findModel';
|
||||
import { FindReplaceState, FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/findState';
|
||||
@@ -67,6 +67,7 @@ let FIND_ALL_CONTROLS_WIDTH = 17/** Find Input margin-left */ + (MAX_MATCHES_COU
|
||||
const FIND_INPUT_AREA_HEIGHT = 33; // The height of Find Widget when Replace Input is not visible.
|
||||
const ctrlEnterReplaceAllWarningPromptedKey = 'ctrlEnterReplaceAll.windows.donotask';
|
||||
|
||||
const ctrlKeyMod = (platform.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd);
|
||||
export class FindWidgetViewZone implements IViewZone {
|
||||
public readonly afterLineNumber: number;
|
||||
public heightInPx: number;
|
||||
@@ -111,7 +112,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
private readonly _notificationService: INotificationService;
|
||||
|
||||
private _domNode!: HTMLElement;
|
||||
private _cachedHeight: number | null;
|
||||
private _cachedHeight: number | null = null;
|
||||
private _findInput!: FindInput;
|
||||
private _replaceInput!: ReplaceInput;
|
||||
|
||||
@@ -175,24 +176,24 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
this._tryUpdateWidgetWidth();
|
||||
this._findInput.inputBox.layout();
|
||||
|
||||
this._register(this._codeEditor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.readOnly) {
|
||||
if (this._codeEditor.getConfiguration().readOnly) {
|
||||
this._register(this._codeEditor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
|
||||
if (e.hasChanged(EditorOption.readOnly)) {
|
||||
if (this._codeEditor.getOption(EditorOption.readOnly)) {
|
||||
// Hide replace part if editor becomes read only
|
||||
this._state.change({ isReplaceRevealed: false }, false);
|
||||
}
|
||||
this._updateButtons();
|
||||
}
|
||||
if (e.layoutInfo) {
|
||||
if (e.hasChanged(EditorOption.layoutInfo)) {
|
||||
this._tryUpdateWidgetWidth();
|
||||
}
|
||||
|
||||
if (e.accessibilitySupport) {
|
||||
if (e.hasChanged(EditorOption.accessibilitySupport)) {
|
||||
this.updateAccessibilitySupport();
|
||||
}
|
||||
|
||||
if (e.contribInfo) {
|
||||
const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop;
|
||||
if (e.hasChanged(EditorOption.find)) {
|
||||
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
|
||||
if (addExtraSpaceOnTop && !this._viewZone) {
|
||||
this._viewZone = new FindWidgetViewZone(0);
|
||||
this._showViewZone();
|
||||
@@ -238,7 +239,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}));
|
||||
|
||||
this._codeEditor.addOverlayWidget(this);
|
||||
if (this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop) {
|
||||
if (this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop) {
|
||||
this._viewZone = new FindWidgetViewZone(0); // Put it before the first line then users can scroll beyond the first line.
|
||||
}
|
||||
|
||||
@@ -315,7 +316,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}
|
||||
if (e.isReplaceRevealed) {
|
||||
if (this._state.isReplaceRevealed) {
|
||||
if (!this._codeEditor.getConfiguration().readOnly && !this._isReplaceVisible) {
|
||||
if (!this._codeEditor.getOption(EditorOption.readOnly) && !this._isReplaceVisible) {
|
||||
this._isReplaceVisible = true;
|
||||
this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
|
||||
this._updateButtons();
|
||||
@@ -456,7 +457,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
this._toggleReplaceBtn.toggleClass('expand', this._isReplaceVisible);
|
||||
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
|
||||
|
||||
let canReplace = !this._codeEditor.getConfiguration().readOnly;
|
||||
let canReplace = !this._codeEditor.getOption(EditorOption.readOnly);
|
||||
this._toggleReplaceBtn.setEnabled(this._isVisible && canReplace);
|
||||
}
|
||||
|
||||
@@ -466,7 +467,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
|
||||
const selection = this._codeEditor.getSelection();
|
||||
const isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false;
|
||||
if (isSelection && this._codeEditor.getConfiguration().contribInfo.find.autoFindInSelection) {
|
||||
if (isSelection && this._codeEditor.getOption(EditorOption.find).autoFindInSelection) {
|
||||
this._toggleSelectionFind.checked = true;
|
||||
} else {
|
||||
this._toggleSelectionFind.checked = false;
|
||||
@@ -487,7 +488,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
this._codeEditor.layoutOverlayWidget(this);
|
||||
|
||||
let adjustEditorScrollTop = true;
|
||||
if (this._codeEditor.getConfiguration().contribInfo.find.seedSearchStringFromSelection && selection) {
|
||||
if (this._codeEditor.getOption(EditorOption.find).seedSearchStringFromSelection && selection) {
|
||||
const domNode = this._codeEditor.getDomNode();
|
||||
if (domNode) {
|
||||
const editorCoords = dom.getDomNodePagePosition(domNode);
|
||||
@@ -534,7 +535,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}
|
||||
|
||||
private _layoutViewZone() {
|
||||
const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop;
|
||||
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
|
||||
|
||||
if (!addExtraSpaceOnTop) {
|
||||
this._removeViewZone();
|
||||
@@ -562,7 +563,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
return;
|
||||
}
|
||||
|
||||
const addExtraSpaceOnTop = this._codeEditor.getConfiguration().contribInfo.find.addExtraSpaceOnTop;
|
||||
const addExtraSpaceOnTop = this._codeEditor.getOption(EditorOption.find).addExtraSpaceOnTop;
|
||||
|
||||
if (!addExtraSpaceOnTop) {
|
||||
return;
|
||||
@@ -642,7 +643,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
return;
|
||||
}
|
||||
|
||||
const editorContentWidth = this._codeEditor.getConfiguration().layoutInfo.contentWidth;
|
||||
const layoutInfo = this._codeEditor.getLayoutInfo();
|
||||
const editorContentWidth = layoutInfo.contentWidth;
|
||||
|
||||
if (editorContentWidth <= 0) {
|
||||
// for example, diff view original editor
|
||||
@@ -652,8 +654,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
dom.removeClass(this._domNode, 'hiddenEditor');
|
||||
}
|
||||
|
||||
const editorWidth = this._codeEditor.getConfiguration().layoutInfo.width;
|
||||
const minimapWidth = this._codeEditor.getConfiguration().layoutInfo.minimapWidth;
|
||||
const editorWidth = layoutInfo.width;
|
||||
const minimapWidth = layoutInfo.minimapWidth;
|
||||
let collapsedFindWidget = false;
|
||||
let reducedFindWidget = false;
|
||||
let narrowFindWidget = false;
|
||||
@@ -775,20 +777,10 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}
|
||||
|
||||
private _onFindInputKeyDown(e: IKeyboardEvent): void {
|
||||
if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) {
|
||||
const inputElement = this._findInput.inputBox.inputElement;
|
||||
const start = inputElement.selectionStart;
|
||||
const end = inputElement.selectionEnd;
|
||||
const content = inputElement.value;
|
||||
|
||||
if (start && end) {
|
||||
const value = content.substr(0, start) + '\n' + content.substr(end);
|
||||
this._findInput.inputBox.value = value;
|
||||
inputElement.setSelectionRange(start + 1, start + 1);
|
||||
this._findInput.inputBox.layout();
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (e.equals(ctrlKeyMod | KeyCode.Enter)) {
|
||||
this._findInput.inputBox.insertAtCursor('\n');
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.equals(KeyCode.Tab)) {
|
||||
@@ -817,7 +809,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}
|
||||
|
||||
private _onReplaceInputKeyDown(e: IKeyboardEvent): void {
|
||||
if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) {
|
||||
if (e.equals(ctrlKeyMod | KeyCode.Enter)) {
|
||||
if (platform.isWindows && platform.isNative && !this._ctrlEnterReplaceAllWarningPrompted) {
|
||||
// this is the first time when users press Ctrl + Enter to replace all
|
||||
this._notificationService.info(
|
||||
@@ -830,19 +822,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
|
||||
}
|
||||
|
||||
const inputElement = this._replaceInput.inputBox.inputElement;
|
||||
const start = inputElement.selectionStart;
|
||||
const end = inputElement.selectionEnd;
|
||||
const content = inputElement.value;
|
||||
|
||||
if (start && end) {
|
||||
const value = content.substr(0, start) + '\n' + content.substr(end);
|
||||
this._replaceInput.inputBox.value = value;
|
||||
inputElement.setSelectionRange(start + 1, start + 1);
|
||||
this._replaceInput.inputBox.layout();
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
this._replaceInput.inputBox.insertAtCursor('\n');
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.equals(KeyCode.Tab)) {
|
||||
@@ -1187,7 +1169,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
if (!this._resized || currentWidth === FIND_WIDGET_INITIAL_WIDTH) {
|
||||
// 1. never resized before, double click should maximizes it
|
||||
// 2. users resized it already but its width is the same as default
|
||||
width = this._codeEditor.getConfiguration().layoutInfo.width - 28 - this._codeEditor.getConfiguration().layoutInfo.minimapWidth - 15;
|
||||
const layoutInfo = this._codeEditor.getLayoutInfo();
|
||||
width = layoutInfo.width - 28 - layoutInfo.minimapWidth - 15;
|
||||
this._resized = true;
|
||||
} else {
|
||||
/**
|
||||
@@ -1208,7 +1191,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
|
||||
}
|
||||
|
||||
private updateAccessibilitySupport(): void {
|
||||
const value = this._codeEditor.getConfiguration().accessibilitySupport;
|
||||
const value = this._codeEditor.getOption(EditorOption.accessibilitySupport);
|
||||
this._findInput.setFocusInputOnOptionClick(value !== AccessibilitySupport.Enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,15 @@ suite('Replace Pattern test', () => {
|
||||
assert.equal(buildReplaceStringWithCasePreserved(actual, 'newfoo-newbar-newabc'), 'Newfoo-Newbar-Newabc');
|
||||
actual = ['Foo-Bar-abc'];
|
||||
assert.equal(buildReplaceStringWithCasePreserved(actual, 'newfoo-newbar'), 'Newfoo-newbar');
|
||||
|
||||
actual = ['Foo_Bar'];
|
||||
assert.equal(buildReplaceStringWithCasePreserved(actual, 'newfoo_newbar'), 'Newfoo_Newbar');
|
||||
actual = ['Foo_Bar_Abc'];
|
||||
assert.equal(buildReplaceStringWithCasePreserved(actual, 'newfoo_newbar_newabc'), 'Newfoo_Newbar_Newabc');
|
||||
actual = ['Foo_Bar_abc'];
|
||||
assert.equal(buildReplaceStringWithCasePreserved(actual, 'newfoo_newbar'), 'Newfoo_newbar');
|
||||
actual = ['Foo_Bar-abc'];
|
||||
assert.equal(buildReplaceStringWithCasePreserved(actual, 'newfoo_newbar-abc'), 'Newfoo_newbar-abc');
|
||||
});
|
||||
|
||||
test('preserve case', () => {
|
||||
@@ -217,5 +226,21 @@ suite('Replace Pattern test', () => {
|
||||
replacePattern = parseReplaceString('newfoo-newbar');
|
||||
actual = replacePattern.buildReplaceString(['Foo-Bar-abc'], true);
|
||||
assert.equal(actual, 'Newfoo-newbar');
|
||||
|
||||
replacePattern = parseReplaceString('newfoo_newbar');
|
||||
actual = replacePattern.buildReplaceString(['Foo_Bar'], true);
|
||||
assert.equal(actual, 'Newfoo_Newbar');
|
||||
|
||||
replacePattern = parseReplaceString('newfoo_newbar_newabc');
|
||||
actual = replacePattern.buildReplaceString(['Foo_Bar_Abc'], true);
|
||||
assert.equal(actual, 'Newfoo_Newbar_Newabc');
|
||||
|
||||
replacePattern = parseReplaceString('newfoo_newbar');
|
||||
actual = replacePattern.buildReplaceString(['Foo_Bar_abc'], true);
|
||||
assert.equal(actual, 'Newfoo_newbar');
|
||||
|
||||
replacePattern = parseReplaceString('newfoo_newbar-abc');
|
||||
actual = replacePattern.buildReplaceString(['Foo_Bar-abc'], true);
|
||||
assert.equal(actual, 'Newfoo_newbar-abc');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { FoldingModel, setCollapseStateAtLevel, CollapseMemento, setCollapseStat
|
||||
import { FoldingDecorationProvider } from './foldingDecorations';
|
||||
import { FoldingRegions, FoldingRegion } from './foldingRanges';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { IMarginData, IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget';
|
||||
import { HiddenRangeModel } from 'vs/editor/contrib/folding/hiddenRangeModel';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
@@ -87,9 +87,10 @@ export class FoldingController extends Disposable implements IEditorContribution
|
||||
) {
|
||||
super();
|
||||
this.editor = editor;
|
||||
this._isEnabled = this.editor.getConfiguration().contribInfo.folding;
|
||||
this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover';
|
||||
this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation';
|
||||
const options = this.editor.getOptions();
|
||||
this._isEnabled = options.get(EditorOption.folding);
|
||||
this._autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover';
|
||||
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
|
||||
|
||||
this.foldingModel = null;
|
||||
this.hiddenRangeModel = null;
|
||||
@@ -108,22 +109,23 @@ export class FoldingController extends Disposable implements IEditorContribution
|
||||
|
||||
this._register(this.editor.onDidChangeModel(() => this.onModelChanged()));
|
||||
|
||||
this._register(this.editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.contribInfo) {
|
||||
this._register(this.editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
|
||||
if (e.hasChanged(EditorOption.folding) || e.hasChanged(EditorOption.showFoldingControls) || e.hasChanged(EditorOption.foldingStrategy)) {
|
||||
let oldIsEnabled = this._isEnabled;
|
||||
this._isEnabled = this.editor.getConfiguration().contribInfo.folding;
|
||||
const options = this.editor.getOptions();
|
||||
this._isEnabled = options.get(EditorOption.folding);
|
||||
this.foldingEnabled.set(this._isEnabled);
|
||||
if (oldIsEnabled !== this._isEnabled) {
|
||||
this.onModelChanged();
|
||||
}
|
||||
let oldShowFoldingControls = this._autoHideFoldingControls;
|
||||
this._autoHideFoldingControls = this.editor.getConfiguration().contribInfo.showFoldingControls === 'mouseover';
|
||||
this._autoHideFoldingControls = options.get(EditorOption.showFoldingControls) === 'mouseover';
|
||||
if (oldShowFoldingControls !== this._autoHideFoldingControls) {
|
||||
this.foldingDecorationProvider.autoHideFoldingControls = this._autoHideFoldingControls;
|
||||
this.onModelContentChanged();
|
||||
}
|
||||
let oldUseFoldingProviders = this._useFoldingProviders;
|
||||
this._useFoldingProviders = this.editor.getConfiguration().contribInfo.foldingStrategy !== 'indentation';
|
||||
this._useFoldingProviders = options.get(EditorOption.foldingStrategy) !== 'indentation';
|
||||
if (oldUseFoldingProviders !== this._useFoldingProviders) {
|
||||
this.onFoldingStrategyChanged();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
class FormatOnType implements editorCommon.IEditorContribution {
|
||||
|
||||
@@ -59,7 +60,7 @@ class FormatOnType implements editorCommon.IEditorContribution {
|
||||
this._callOnModel.clear();
|
||||
|
||||
// we are disabled
|
||||
if (!this._editor.getConfiguration().contribInfo.formatOnType) {
|
||||
if (!this._editor.getOption(EditorOption.formatOnType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ class FormatOnPaste implements editorCommon.IEditorContribution {
|
||||
this._callOnModel.clear();
|
||||
|
||||
// we are disabled
|
||||
if (!this.editor.getConfiguration().contribInfo.formatOnPaste) {
|
||||
if (!this.editor.getOption(EditorOption.formatOnPaste)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
function hasModifier(e: { ctrlKey: boolean; shiftKey: boolean; altKey: boolean; metaKey: boolean }, modifier: 'ctrlKey' | 'shiftKey' | 'altKey' | 'metaKey'): boolean {
|
||||
return !!e[modifier];
|
||||
@@ -116,14 +117,14 @@ export class ClickLinkGesture extends Disposable {
|
||||
super();
|
||||
|
||||
this._editor = editor;
|
||||
this._opts = createOptions(this._editor.getConfiguration().multiCursorModifier);
|
||||
this._opts = createOptions(this._editor.getOption(EditorOption.multiCursorModifier));
|
||||
|
||||
this.lastMouseMoveEvent = null;
|
||||
this.hasTriggerKeyOnMouseDown = false;
|
||||
|
||||
this._register(this._editor.onDidChangeConfiguration((e) => {
|
||||
if (e.multiCursorModifier) {
|
||||
const newOpts = createOptions(this._editor.getConfiguration().multiCursorModifier);
|
||||
if (e.hasChanged(EditorOption.multiCursorModifier)) {
|
||||
const newOpts = createOptions(this._editor.getOption(EditorOption.multiCursorModifier));
|
||||
if (this._opts.equals(newOpts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefiniti
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { EditorStateCancellationTokenSource, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState';
|
||||
import { ISymbolNavigationService } from 'vs/editor/contrib/goToDefinition/goToDefinitionResultsNavigation';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export class DefinitionActionConfig {
|
||||
|
||||
@@ -137,7 +138,7 @@ export class DefinitionAction extends EditorAction {
|
||||
const msg = model.getAriaMessage();
|
||||
alert(msg);
|
||||
|
||||
const { gotoLocation } = editor.getConfiguration().contribInfo;
|
||||
const gotoLocation = editor.getOption(EditorOption.gotoLocation);
|
||||
if (this._configuration.openInPeek || (gotoLocation.multiple === 'peek' && model.references.length > 1)) {
|
||||
this._openInPeek(editorService, editor, model);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export const ctxHasSymbols = new RawContextKey('hasSymbols', false);
|
||||
export const ISymbolNavigationService = createDecorator<ISymbolNavigationService>('ISymbolNavigationService');
|
||||
|
||||
export interface ISymbolNavigationService {
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
reset(): void;
|
||||
put(anchor: OneReference): void;
|
||||
revealNext(source: ICodeEditor): Promise<any>;
|
||||
@@ -32,7 +32,7 @@ export interface ISymbolNavigationService {
|
||||
|
||||
class SymbolNavigationService implements ISymbolNavigationService {
|
||||
|
||||
_serviceBrand: any;
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _ctxHasSymbols: IContextKey<boolean>;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import 'vs/css!./media/gotoErrorWidget';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IMarker, MarkerSeverity, IRelatedInformation } from 'vs/platform/markers/common/markers';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
@@ -26,6 +26,7 @@ import { IAction } from 'vs/base/common/actions';
|
||||
import { IActionBarOptions, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { peekViewTitleForeground, peekViewTitleInfoForeground } from 'vs/editor/contrib/referenceSearch/referencesWidget';
|
||||
import { SeverityIcon } from 'vs/platform/severityIcon/common/severityIcon';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
class MessageWidget {
|
||||
|
||||
@@ -37,7 +38,7 @@ class MessageWidget {
|
||||
private readonly _relatedBlock: HTMLDivElement;
|
||||
private readonly _scrollable: ScrollableElement;
|
||||
private readonly _relatedDiagnostics = new WeakMap<HTMLElement, IRelatedInformation>();
|
||||
private readonly _disposables: IDisposable[] = [];
|
||||
private readonly _disposables: DisposableStore = new DisposableStore();
|
||||
|
||||
constructor(parent: HTMLElement, editor: ICodeEditor, onRelatedInformation: (related: IRelatedInformation) => void) {
|
||||
this._editor = editor;
|
||||
@@ -53,7 +54,7 @@ class MessageWidget {
|
||||
|
||||
this._relatedBlock = document.createElement('div');
|
||||
domNode.appendChild(this._relatedBlock);
|
||||
this._disposables.push(dom.addStandardDisposableListener(this._relatedBlock, 'click', event => {
|
||||
this._disposables.add(dom.addStandardDisposableListener(this._relatedBlock, 'click', event => {
|
||||
event.preventDefault();
|
||||
const related = this._relatedDiagnostics.get(event.target);
|
||||
if (related) {
|
||||
@@ -69,11 +70,11 @@ class MessageWidget {
|
||||
verticalScrollbarSize: 3
|
||||
});
|
||||
parent.appendChild(this._scrollable.getDomNode());
|
||||
this._disposables.push(this._scrollable.onScroll(e => {
|
||||
this._disposables.add(this._scrollable.onScroll(e => {
|
||||
domNode.style.left = `-${e.scrollLeft}px`;
|
||||
domNode.style.top = `-${e.scrollTop}px`;
|
||||
}));
|
||||
this._disposables.push(this._scrollable);
|
||||
this._disposables.add(this._scrollable);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
@@ -122,7 +123,7 @@ class MessageWidget {
|
||||
this._editor.applyFontInfo(this._relatedBlock);
|
||||
if (isNonEmptyArray(relatedInformation)) {
|
||||
const relatedInformationNode = this._relatedBlock.appendChild(document.createElement('div'));
|
||||
relatedInformationNode.style.paddingTop = `${Math.floor(this._editor.getConfiguration().lineHeight * 0.66)}px`;
|
||||
relatedInformationNode.style.paddingTop = `${Math.floor(this._editor.getOption(EditorOption.lineHeight) * 0.66)}px`;
|
||||
this._lines += 1;
|
||||
|
||||
for (const related of relatedInformation) {
|
||||
@@ -146,7 +147,7 @@ class MessageWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const fontInfo = this._editor.getConfiguration().fontInfo;
|
||||
const fontInfo = this._editor.getOption(EditorOption.fontInfo);
|
||||
const scrollWidth = Math.ceil(fontInfo.typicalFullwidthCharacterWidth * this._longestLineLength * 0.75);
|
||||
const scrollHeight = fontInfo.lineHeight * this._lines;
|
||||
this._scrollable.setScrollDimensions({ scrollWidth, scrollHeight });
|
||||
|
||||
@@ -55,9 +55,13 @@
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* MarkupContent Layout */
|
||||
.monaco-editor-hover ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
.monaco-editor-hover ol {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.monaco-editor-hover li > p {
|
||||
margin-bottom: 0;
|
||||
|
||||
@@ -11,7 +11,7 @@ import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IEmptyContentData } from 'vs/editor/browser/controller/mouseTarget';
|
||||
import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IEditorContribution, IScrollEvent } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
@@ -74,8 +74,8 @@ export class ModesHoverController implements IEditorContribution {
|
||||
|
||||
this._hookEvents();
|
||||
|
||||
this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.contribInfo) {
|
||||
this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
|
||||
if (e.hasChanged(EditorOption.hover)) {
|
||||
this._hideWidgets();
|
||||
this._unhookEvents();
|
||||
this._hookEvents();
|
||||
@@ -86,7 +86,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
private _hookEvents(): void {
|
||||
const hideWidgetsEventHandler = () => this._hideWidgets();
|
||||
|
||||
const hoverOpts = this._editor.getConfiguration().contribInfo.hover;
|
||||
const hoverOpts = this._editor.getOption(EditorOption.hover);
|
||||
this._isHoverEnabled = hoverOpts.enabled;
|
||||
this._isHoverSticky = hoverOpts.sticky;
|
||||
if (this._isHoverEnabled) {
|
||||
@@ -147,7 +147,6 @@ export class ModesHoverController implements IEditorContribution {
|
||||
}
|
||||
|
||||
private _onEditorMouseMove(mouseEvent: IEditorMouseEvent): void {
|
||||
// const this._editor.getConfiguration().contribInfo.hover.sticky;
|
||||
let targetType = mouseEvent.target.type;
|
||||
|
||||
if (this._isMouseDown && this._hoverClicked && this.contentWidget.isColorPickerVisible()) {
|
||||
@@ -165,7 +164,7 @@ export class ModesHoverController implements IEditorContribution {
|
||||
}
|
||||
|
||||
if (targetType === MouseTargetType.CONTENT_EMPTY) {
|
||||
const epsilon = this._editor.getConfiguration().fontInfo.typicalHalfwidthCharacterWidth / 2;
|
||||
const epsilon = this._editor.getOption(EditorOption.fontInfo).typicalHalfwidthCharacterWidth / 2;
|
||||
const data = <IEmptyContentData>mouseEvent.target.detail;
|
||||
if (data && !data.isAfterLines && typeof data.horizontalDistanceToText === 'number' && data.horizontalDistanceToText < epsilon) {
|
||||
// Let hover kick in even when the mouse is technically in the empty area after a line, given the distance is small enough
|
||||
@@ -265,7 +264,7 @@ class ShowHoverAction extends EditorAction {
|
||||
}
|
||||
const position = editor.getPosition();
|
||||
const range = new Range(position.lineNumber, position.column, position.lineNumber, position.column);
|
||||
const focus = editor.getConfiguration().accessibilitySupport === AccessibilitySupport.Enabled;
|
||||
const focus = editor.getOption(EditorOption.accessibilitySupport) === AccessibilitySupport.Enabled;
|
||||
controller.showContentHover(range, HoverStartMode.Immediate, focus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
|
||||
import { IContentWidget, ICodeEditor, IContentWidgetPosition, ContentWidgetPositionPreference, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
||||
export class ContentHoverWidget extends Widget implements editorBrowser.IContentWidget {
|
||||
export class ContentHoverWidget extends Widget implements IContentWidget {
|
||||
|
||||
private readonly _id: string;
|
||||
protected _editor: editorBrowser.ICodeEditor;
|
||||
protected _editor: ICodeEditor;
|
||||
private _isVisible: boolean;
|
||||
private readonly _containerDomNode: HTMLElement;
|
||||
private readonly _domNode: HTMLElement;
|
||||
@@ -37,7 +37,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
toggleClass(this._containerDomNode, 'hidden', !this._isVisible);
|
||||
}
|
||||
|
||||
constructor(id: string, editor: editorBrowser.ICodeEditor) {
|
||||
constructor(id: string, editor: ICodeEditor) {
|
||||
super();
|
||||
this._id = id;
|
||||
this._editor = editor;
|
||||
@@ -61,8 +61,8 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
}
|
||||
});
|
||||
|
||||
this._register(this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.fontInfo) {
|
||||
this._register(this._editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
|
||||
if (e.hasChanged(EditorOption.fontInfo)) {
|
||||
this.updateFont();
|
||||
}
|
||||
}));
|
||||
@@ -113,14 +113,14 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
}
|
||||
}
|
||||
|
||||
public getPosition(): editorBrowser.IContentWidgetPosition | null {
|
||||
public getPosition(): IContentWidgetPosition | null {
|
||||
if (this.isVisible) {
|
||||
return {
|
||||
position: this._showAtPosition,
|
||||
range: this._showAtRange,
|
||||
preference: [
|
||||
editorBrowser.ContentWidgetPositionPreference.ABOVE,
|
||||
editorBrowser.ContentWidgetPositionPreference.BELOW
|
||||
ContentWidgetPositionPreference.ABOVE,
|
||||
ContentWidgetPositionPreference.BELOW
|
||||
]
|
||||
};
|
||||
}
|
||||
@@ -152,7 +152,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
|
||||
private layout(): void {
|
||||
const height = Math.max(this._editor.getLayoutInfo().height / 4, 250);
|
||||
const { fontSize, lineHeight } = this._editor.getConfiguration().fontInfo;
|
||||
const { fontSize, lineHeight } = this._editor.getOption(EditorOption.fontInfo);
|
||||
|
||||
this._domNode.style.fontSize = `${fontSize}px`;
|
||||
this._domNode.style.lineHeight = `${lineHeight}px`;
|
||||
@@ -161,15 +161,15 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
|
||||
}
|
||||
}
|
||||
|
||||
export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWidget {
|
||||
export class GlyphHoverWidget extends Widget implements IOverlayWidget {
|
||||
|
||||
private readonly _id: string;
|
||||
protected _editor: editorBrowser.ICodeEditor;
|
||||
protected _editor: ICodeEditor;
|
||||
private _isVisible: boolean;
|
||||
private readonly _domNode: HTMLElement;
|
||||
protected _showAtLineNumber: number;
|
||||
|
||||
constructor(id: string, editor: editorBrowser.ICodeEditor) {
|
||||
constructor(id: string, editor: ICodeEditor) {
|
||||
super();
|
||||
this._id = id;
|
||||
this._editor = editor;
|
||||
@@ -182,8 +182,8 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
|
||||
|
||||
this._showAtLineNumber = -1;
|
||||
|
||||
this._register(this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
|
||||
if (e.fontInfo) {
|
||||
this._register(this._editor.onDidChangeConfiguration((e: ConfigurationChangedEvent) => {
|
||||
if (e.hasChanged(EditorOption.fontInfo)) {
|
||||
this.updateFont();
|
||||
}
|
||||
}));
|
||||
@@ -218,7 +218,7 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
|
||||
const editorLayout = this._editor.getLayoutInfo();
|
||||
const topForLineNumber = this._editor.getTopForLineNumber(this._showAtLineNumber);
|
||||
const editorScrollTop = this._editor.getScrollTop();
|
||||
const lineHeight = this._editor.getConfiguration().lineHeight;
|
||||
const lineHeight = this._editor.getOption(EditorOption.lineHeight);
|
||||
const nodeHeight = this._domNode.clientHeight;
|
||||
const top = topForLineNumber - editorScrollTop - ((nodeHeight - lineHeight) / 2);
|
||||
|
||||
@@ -233,7 +233,7 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
|
||||
this.isVisible = false;
|
||||
}
|
||||
|
||||
public getPosition(): editorBrowser.IOverlayWidgetPosition | null {
|
||||
public getPosition(): IOverlayWidgetPosition | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import { QuickFixAction, QuickFixController } from 'vs/editor/contrib/codeAction
|
||||
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
@@ -222,7 +223,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
result => this._withResult(result, true),
|
||||
null,
|
||||
result => this._withResult(result, false),
|
||||
this._editor.getConfiguration().contribInfo.hover.delay
|
||||
this._editor.getOption(EditorOption.hover).delay
|
||||
);
|
||||
|
||||
this._register(dom.addStandardDisposableListener(this.getDomNode(), dom.EventType.FOCUS, () => {
|
||||
@@ -234,7 +235,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
dom.removeClass(this.getDomNode(), 'colorpicker-hover');
|
||||
}));
|
||||
this._register(editor.onDidChangeConfiguration((e) => {
|
||||
this._hoverOperation.setHoverTime(this._editor.getConfiguration().contribInfo.hover.delay);
|
||||
this._hoverOperation.setHoverTime(this._editor.getOption(EditorOption.hover).delay);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -365,7 +366,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
||||
|
||||
// create blank olor picker model and widget first to ensure it's positioned correctly.
|
||||
const model = new ColorPickerModel(color, [], 0);
|
||||
const widget = new ColorPickerWidget(fragment, model, this._editor.getConfiguration().pixelRatio, this._themeService);
|
||||
const widget = new ColorPickerWidget(fragment, model, this._editor.getOption(EditorOption.pixelRatio), this._themeService);
|
||||
|
||||
getColorPresentations(editorModel, colorInfo, msg.provider, CancellationToken.None).then(colorPresentations => {
|
||||
model.colorPresentations = colorPresentations || [];
|
||||
|
||||
@@ -22,6 +22,7 @@ import { IndentConsts } from 'vs/editor/common/modes/supports/indentRules';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import * as indentUtils from 'vs/editor/contrib/indentation/indentUtils';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
export function getReindentEditOperations(model: ITextModel, startLineNumber: number, endLineNumber: number, inheritedIndent?: string): IIdentifiedSingleEditOperation[] {
|
||||
if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) {
|
||||
@@ -443,7 +444,7 @@ export class AutoIndentOnPaste implements IEditorContribution {
|
||||
this.callOnModel = dispose(this.callOnModel);
|
||||
|
||||
// we are disabled
|
||||
if (!this.editor.getConfiguration().autoIndent || this.editor.getConfiguration().contribInfo.formatOnPaste) {
|
||||
if (!this.editor.getOption(EditorOption.autoIndent) || this.editor.getOption(EditorOption.formatOnPaste)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/moveLinesCom
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/sortLinesCommand';
|
||||
import { MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
|
||||
// copy lines
|
||||
|
||||
@@ -111,7 +112,7 @@ abstract class AbstractMoveLinesAction extends EditorAction {
|
||||
|
||||
let commands: ICommand[] = [];
|
||||
let selections = editor.getSelections() || [];
|
||||
let autoIndent = editor.getConfiguration().autoIndent;
|
||||
const autoIndent = editor.getOption(EditorOption.autoIndent);
|
||||
|
||||
for (const selection of selections) {
|
||||
commands.push(new MoveLinesCommand(selection, this.down, autoIndent));
|
||||
@@ -886,7 +887,7 @@ export abstract class AbstractCaseAction extends EditorAction {
|
||||
return;
|
||||
}
|
||||
|
||||
let wordSeparators = editor.getConfiguration().wordSeparators;
|
||||
let wordSeparators = editor.getOption(EditorOption.wordSeparators);
|
||||
|
||||
let commands: ICommand[] = [];
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user