mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5
This commit is contained in:
@@ -484,6 +484,11 @@ const editorConfiguration: IConfigurationNode = {
|
||||
default: true,
|
||||
description: nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.")
|
||||
},
|
||||
'editor.semanticHighlighting.enabled': {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: nls.localize('semanticHighlighting.enabled', "Controls whether the semanticHighlighting is shown for the languages that support it.")
|
||||
},
|
||||
'editor.stablePeek': {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
|
||||
@@ -58,7 +58,7 @@ export interface IEditorOptions {
|
||||
* Render vertical lines at the specified columns.
|
||||
* Defaults to empty array.
|
||||
*/
|
||||
rulers?: number[];
|
||||
rulers?: (number | IRulerOption)[];
|
||||
/**
|
||||
* A string containing the word separators used when doing word navigation.
|
||||
* Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
|
||||
@@ -74,7 +74,7 @@ export interface IEditorOptions {
|
||||
* If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
|
||||
* Otherwise, if it is a truey, line numbers will be rendered normally (equivalent of using an identity function).
|
||||
* Otherwise, line numbers will not be rendered.
|
||||
* Defaults to true.
|
||||
* Defaults to `on`.
|
||||
*/
|
||||
lineNumbers?: LineNumbersType;
|
||||
/**
|
||||
@@ -267,10 +267,10 @@ export interface IEditorOptions {
|
||||
*/
|
||||
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
|
||||
/**
|
||||
* Controls the wrapping algorithm to use.
|
||||
* Defaults to 'monospace'.
|
||||
* Controls the wrapping strategy to use.
|
||||
* Defaults to 'simple'.
|
||||
*/
|
||||
wrappingAlgorithm?: 'monospace' | 'dom';
|
||||
wrappingStrategy?: 'simple' | 'advanced';
|
||||
/**
|
||||
* Configure word wrapping characters. A break will be introduced before these characters.
|
||||
* Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
|
||||
@@ -319,6 +319,11 @@ export interface IEditorOptions {
|
||||
* Defaults to 5.
|
||||
*/
|
||||
fastScrollSensitivity?: number;
|
||||
/**
|
||||
* Enable that the editor scrolls only the predominant axis. Prevents horizontal drift when scrolling vertically on a trackpad.
|
||||
* Defaults to true.
|
||||
*/
|
||||
scrollPredominantAxis?: boolean;
|
||||
/**
|
||||
* The modifier to be used to add multiple cursors with the mouse.
|
||||
* Defaults to 'alt'
|
||||
@@ -385,8 +390,8 @@ export interface IEditorOptions {
|
||||
*/
|
||||
autoSurround?: EditorAutoSurroundStrategy;
|
||||
/**
|
||||
* Enable auto indentation adjustment.
|
||||
* Defaults to false.
|
||||
* Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.
|
||||
* Defaults to advanced.
|
||||
*/
|
||||
autoIndent?: 'none' | 'keep' | 'brackets' | 'advanced' | 'full';
|
||||
/**
|
||||
@@ -555,6 +560,11 @@ export interface IEditorOptions {
|
||||
* Defaults to false.
|
||||
*/
|
||||
peekWidgetDefaultFocus?: 'tree' | 'editor';
|
||||
/**
|
||||
* Controls whether the definition link opens element in the peek widget.
|
||||
* Defaults to false.
|
||||
*/
|
||||
definitionLinkOpensInPeek?: boolean;
|
||||
}
|
||||
|
||||
export interface IEditorConstructionOptions extends IEditorOptions {
|
||||
@@ -625,9 +635,6 @@ export class ConfigurationChangedEvent {
|
||||
constructor(values: boolean[]) {
|
||||
this._values = values;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public hasChanged(id: EditorOption): boolean {
|
||||
return this._values[id];
|
||||
}
|
||||
@@ -1592,55 +1599,6 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOption
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region semantic highlighting
|
||||
|
||||
/**
|
||||
* Configuration options for semantic highlighting
|
||||
*/
|
||||
export interface IEditorSemanticHighlightingOptions {
|
||||
/**
|
||||
* Enable semantic highlighting.
|
||||
* Defaults to true.
|
||||
*/
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type EditorSemanticHighlightingOptions = Readonly<Required<IEditorSemanticHighlightingOptions>>;
|
||||
|
||||
class EditorSemanticHighlighting extends BaseEditorOption<EditorOption.semanticHighlighting, EditorSemanticHighlightingOptions> {
|
||||
|
||||
constructor() {
|
||||
const defaults: EditorSemanticHighlightingOptions = {
|
||||
enabled: true
|
||||
};
|
||||
super(
|
||||
EditorOption.semanticHighlighting, 'semanticHighlighting', defaults,
|
||||
{
|
||||
'editor.semanticHighlighting.enabled': {
|
||||
type: 'boolean',
|
||||
default: defaults.enabled,
|
||||
description: nls.localize('semanticHighlighting.enabled', "Controls whether the semanticHighlighting is shown for the languages that support it.")
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public validate(_input: any): EditorSemanticHighlightingOptions {
|
||||
if (typeof _input !== 'object') {
|
||||
return this.defaultValue;
|
||||
}
|
||||
const input = _input as IEditorSemanticHighlightingOptions;
|
||||
return {
|
||||
enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region layoutInfo
|
||||
|
||||
/**
|
||||
@@ -2362,16 +2320,37 @@ export function filterValidationDecorations(options: IComputedEditorOptions): bo
|
||||
|
||||
//#region rulers
|
||||
|
||||
class EditorRulers extends SimpleEditorOption<EditorOption.rulers, number[]> {
|
||||
export interface IRulerOption {
|
||||
readonly column: number;
|
||||
readonly color: string | null;
|
||||
}
|
||||
|
||||
class EditorRulers extends BaseEditorOption<EditorOption.rulers, IRulerOption[]> {
|
||||
|
||||
constructor() {
|
||||
const defaults: number[] = [];
|
||||
const defaults: IRulerOption[] = [];
|
||||
const columnSchema: IJSONSchema = { type: 'number', description: nls.localize('rulers.size', "Number of monospace characters at which this editor ruler will render.") };
|
||||
super(
|
||||
EditorOption.rulers, 'rulers', defaults,
|
||||
{
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'number'
|
||||
anyOf: [
|
||||
columnSchema,
|
||||
{
|
||||
type: [
|
||||
'object'
|
||||
],
|
||||
properties: {
|
||||
column: columnSchema,
|
||||
color: {
|
||||
type: 'string',
|
||||
description: nls.localize('rulers.color', "Color of this editor ruler."),
|
||||
format: 'color-hex'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
default: defaults,
|
||||
description: nls.localize('rulers', "Render vertical rulers after a certain number of monospace characters. Use multiple values for multiple rulers. No rulers are drawn if array is empty.")
|
||||
@@ -2379,13 +2358,24 @@ class EditorRulers extends SimpleEditorOption<EditorOption.rulers, number[]> {
|
||||
);
|
||||
}
|
||||
|
||||
public validate(input: any): number[] {
|
||||
public validate(input: any): IRulerOption[] {
|
||||
if (Array.isArray(input)) {
|
||||
let rulers: number[] = [];
|
||||
for (let value of input) {
|
||||
rulers.push(EditorIntOption.clampedInt(value, 0, 0, 10000));
|
||||
let rulers: IRulerOption[] = [];
|
||||
for (let _element of input) {
|
||||
if (typeof _element === 'number') {
|
||||
rulers.push({
|
||||
column: EditorIntOption.clampedInt(_element, 0, 0, 10000),
|
||||
color: null
|
||||
});
|
||||
} else if (typeof _element === 'object') {
|
||||
const element = _element as IRulerOption;
|
||||
rulers.push({
|
||||
column: EditorIntOption.clampedInt(element.column, 0, 0, 10000),
|
||||
color: element.color
|
||||
});
|
||||
}
|
||||
}
|
||||
rulers.sort((a, b) => a - b);
|
||||
rulers.sort((a, b) => a.column - b.column);
|
||||
return rulers;
|
||||
}
|
||||
return this.defaultValue;
|
||||
@@ -2674,6 +2664,10 @@ export interface ISuggestOptions {
|
||||
* Show snippet-suggestions.
|
||||
*/
|
||||
showSnippets?: boolean;
|
||||
/**
|
||||
* Controls the visibility of the status bar at the bottom of the suggest widget.
|
||||
*/
|
||||
hideStatusBar?: boolean;
|
||||
}
|
||||
|
||||
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
|
||||
@@ -2683,7 +2677,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
|
||||
constructor() {
|
||||
const defaults: InternalSuggestOptions = {
|
||||
insertMode: 'insert',
|
||||
insertHighlight: false,
|
||||
insertHighlight: true,
|
||||
filterGraceful: true,
|
||||
snippetsPreventQuickSuggestions: true,
|
||||
localityBonus: false,
|
||||
@@ -2715,6 +2709,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
|
||||
showFolders: true,
|
||||
showTypeParameters: true,
|
||||
showSnippets: true,
|
||||
hideStatusBar: true
|
||||
};
|
||||
super(
|
||||
EditorOption.suggest, 'suggest', defaults,
|
||||
@@ -2752,7 +2747,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
|
||||
'editor.suggest.snippetsPreventQuickSuggestions': {
|
||||
type: 'boolean',
|
||||
default: defaults.snippetsPreventQuickSuggestions,
|
||||
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Control whether an active snippet prevents quick suggestions.")
|
||||
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Controls whether an active snippet prevents quick suggestions.")
|
||||
},
|
||||
'editor.suggest.showIcons': {
|
||||
type: 'boolean',
|
||||
@@ -2899,6 +2894,11 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
|
||||
},
|
||||
'editor.suggest.hideStatusBar': {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
markdownDescription: nls.localize('editor.suggest.hideStatusBar', "Controls the visibility of the status bar at the bottom of the suggest widget.")
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -2943,6 +2943,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
|
||||
showFolders: EditorBooleanOption.boolean(input.showFolders, this.defaultValue.showFolders),
|
||||
showTypeParameters: EditorBooleanOption.boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
|
||||
showSnippets: EditorBooleanOption.boolean(input.showSnippets, this.defaultValue.showSnippets),
|
||||
hideStatusBar: EditorBooleanOption.boolean(input.hideStatusBar, this.defaultValue.hideStatusBar),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3189,6 +3190,7 @@ export const enum EditorOption {
|
||||
overviewRulerLanes,
|
||||
parameterHints,
|
||||
peekWidgetDefaultFocus,
|
||||
definitionLinkOpensInPeek,
|
||||
quickSuggestions,
|
||||
quickSuggestionsDelay,
|
||||
readOnly,
|
||||
@@ -3204,10 +3206,10 @@ export const enum EditorOption {
|
||||
scrollbar,
|
||||
scrollBeyondLastColumn,
|
||||
scrollBeyondLastLine,
|
||||
scrollPredominantAxis,
|
||||
selectionClipboard,
|
||||
selectionHighlight,
|
||||
selectOnLineNumbers,
|
||||
semanticHighlighting,
|
||||
showFoldingControls,
|
||||
showUnused,
|
||||
snippetSuggestions,
|
||||
@@ -3227,7 +3229,7 @@ export const enum EditorOption {
|
||||
wordWrapColumn,
|
||||
wordWrapMinified,
|
||||
wrappingIndent,
|
||||
wrappingAlgorithm,
|
||||
wrappingStrategy,
|
||||
|
||||
// Leave these at the end (because they have dependencies!)
|
||||
editorClassName,
|
||||
@@ -3437,7 +3439,13 @@ export const EditorOptions = {
|
||||
EditorOption.foldingStrategy, 'foldingStrategy',
|
||||
'auto' as 'auto' | 'indentation',
|
||||
['auto', 'indentation'] as const,
|
||||
{ markdownDescription: nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges. `auto` uses a language specific folding strategy, if available. `indentation` uses the indentation based folding strategy.") }
|
||||
{
|
||||
enumDescriptions: [
|
||||
nls.localize('foldingStrategy.auto', "Use a language-specific folding strategy if available, else the indentation-based one."),
|
||||
nls.localize('foldingStrategy.indentation', "Use the indentation-based folding strategy."),
|
||||
],
|
||||
description: nls.localize('foldingStrategy', "Controls the strategy for computing folding ranges.")
|
||||
}
|
||||
)),
|
||||
foldingHighlight: register(new EditorBooleanOption(
|
||||
EditorOption.foldingHighlight, 'foldingHighlight', true,
|
||||
@@ -3574,12 +3582,16 @@ export const EditorOptions = {
|
||||
['tree', 'editor'] as const,
|
||||
{
|
||||
enumDescriptions: [
|
||||
nls.localize('peekWidgetDefaultFocus.tree', "Focus the tree when openeing peek"),
|
||||
nls.localize('peekWidgetDefaultFocus.tree', "Focus the tree when opening peek"),
|
||||
nls.localize('peekWidgetDefaultFocus.editor', "Focus the editor when opening peek")
|
||||
],
|
||||
description: nls.localize('peekWidgetDefaultFocus', "Controls whether to focus the inline editor or the tree in the peek widget.")
|
||||
}
|
||||
)),
|
||||
definitionLinkOpensInPeek: register(new EditorBooleanOption(
|
||||
EditorOption.definitionLinkOpensInPeek, 'definitionLinkOpensInPeek', false,
|
||||
{ description: nls.localize('definitionLinkOpensInPeek', "Controls whether the definition link opens element in the peek widget.") }
|
||||
)),
|
||||
quickSuggestions: register(new EditorQuickSuggestions()),
|
||||
quickSuggestionsDelay: register(new EditorIntOption(
|
||||
EditorOption.quickSuggestionsDelay, 'quickSuggestionsDelay',
|
||||
@@ -3653,6 +3665,10 @@ export const EditorOptions = {
|
||||
EditorOption.scrollBeyondLastLine, 'scrollBeyondLastLine', true,
|
||||
{ description: nls.localize('scrollBeyondLastLine', "Controls whether the editor will scroll beyond the last line.") }
|
||||
)),
|
||||
scrollPredominantAxis: register(new EditorBooleanOption(
|
||||
EditorOption.scrollPredominantAxis, 'scrollPredominantAxis', true,
|
||||
{ description: nls.localize('scrollPredominantAxis', "Scroll only along the predominant axis when scrolling both vertically and horizontally at the same time. Prevents horizontal drift when scrolling vertically on a trackpad.") }
|
||||
)),
|
||||
selectionClipboard: register(new EditorBooleanOption(
|
||||
EditorOption.selectionClipboard, 'selectionClipboard', true,
|
||||
{
|
||||
@@ -3667,12 +3683,17 @@ export const EditorOptions = {
|
||||
selectOnLineNumbers: register(new EditorBooleanOption(
|
||||
EditorOption.selectOnLineNumbers, 'selectOnLineNumbers', true,
|
||||
)),
|
||||
semanticHighlighting: register(new EditorSemanticHighlighting()),
|
||||
showFoldingControls: register(new EditorStringEnumOption(
|
||||
EditorOption.showFoldingControls, 'showFoldingControls',
|
||||
'mouseover' as 'always' | 'mouseover',
|
||||
['always', 'mouseover'] as const,
|
||||
{ description: nls.localize('showFoldingControls', "Controls whether the fold controls on the gutter are automatically hidden.") }
|
||||
{
|
||||
enumDescriptions: [
|
||||
nls.localize('showFoldingControls.always', "Always show the folding controls."),
|
||||
nls.localize('showFoldingControls.mouseover', "Only show the folding controls when the mouse is over the gutter."),
|
||||
],
|
||||
description: nls.localize('showFoldingControls', "Controls when the folding controls on the gutter are shown.")
|
||||
}
|
||||
)),
|
||||
showUnused: register(new EditorBooleanOption(
|
||||
EditorOption.showUnused, 'showUnused', true,
|
||||
@@ -3819,16 +3840,16 @@ export const EditorOptions = {
|
||||
description: nls.localize('wrappingIndent', "Controls the indentation of wrapped lines."),
|
||||
}
|
||||
)),
|
||||
wrappingAlgorithm: register(new EditorStringEnumOption(
|
||||
EditorOption.wrappingAlgorithm, 'wrappingAlgorithm',
|
||||
'monospace' as 'monospace' | 'dom',
|
||||
['monospace', 'dom'] as const,
|
||||
wrappingStrategy: register(new EditorStringEnumOption(
|
||||
EditorOption.wrappingStrategy, 'wrappingStrategy',
|
||||
'simple' as 'simple' | 'advanced',
|
||||
['simple', 'advanced'] as const,
|
||||
{
|
||||
enumDescriptions: [
|
||||
nls.localize('wrappingAlgorithm.monospace', "Assumes that all characters are of the same width. This is a fast algorithm."),
|
||||
nls.localize('wrappingAlgorithm.dom', "Delegates wrapping points computation to the DOM. This is a slow algorithm, that might cause freezes for large files.")
|
||||
nls.localize('wrappingStrategy.simple', "Assumes that all characters are of the same width. This is a fast algorithm that works correctly for monospace fonts and certain scripts (like Latin characters) where glyphs are of equal width."),
|
||||
nls.localize('wrappingStrategy.advanced', "Delegates wrapping points computation to the browser. This is a slow algorithm, that might cause freezes for large files, but it works correctly in all cases.")
|
||||
],
|
||||
description: nls.localize('wrappingAlgorithm', "Controls the algorithm that computes wrapping points.")
|
||||
description: nls.localize('wrappingStrategy', "Controls the algorithm that computes wrapping points.")
|
||||
}
|
||||
)),
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { CursorColumns, CursorConfiguration, ICursorSimpleModel, SingleCursorSta
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
|
||||
export class CursorPosition {
|
||||
_cursorPositionBrand: void;
|
||||
@@ -214,7 +215,7 @@ export class MoveOperations {
|
||||
public static moveToEndOfLine(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
|
||||
let lineNumber = cursor.position.lineNumber;
|
||||
let maxColumn = model.getLineMaxColumn(lineNumber);
|
||||
return cursor.move(inSelectionMode, lineNumber, maxColumn, 0);
|
||||
return cursor.move(inSelectionMode, lineNumber, maxColumn, Constants.MAX_SAFE_SMALL_INTEGER - maxColumn);
|
||||
}
|
||||
|
||||
public static moveToBeginningOfBuffer(config: CursorConfiguration, model: ICursorSimpleModel, cursor: SingleCursorState, inSelectionMode: boolean): SingleCursorState {
|
||||
|
||||
@@ -36,6 +36,15 @@ export class RGBA8 {
|
||||
this.a = RGBA8._clamp(a);
|
||||
}
|
||||
|
||||
public equals(other: RGBA8): boolean {
|
||||
return (
|
||||
this.r === other.r
|
||||
&& this.g === other.g
|
||||
&& this.b === other.b
|
||||
&& this.a === other.a
|
||||
);
|
||||
}
|
||||
|
||||
private static _clamp(c: number): number {
|
||||
if (c < 0) {
|
||||
return 0;
|
||||
|
||||
@@ -355,6 +355,12 @@ export interface IEditor {
|
||||
*/
|
||||
revealLineInCenterIfOutsideViewport(lineNumber: number, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Scroll vertically as necessary and reveal a line close to the top of the viewport,
|
||||
* optimized for viewing a code definition.
|
||||
*/
|
||||
revealLineNearTop(lineNumber: number, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Scroll vertically or horizontally as necessary and reveal a position.
|
||||
*/
|
||||
@@ -370,6 +376,12 @@ export interface IEditor {
|
||||
*/
|
||||
revealPositionInCenterIfOutsideViewport(position: IPosition, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport,
|
||||
* optimized for viewing a code definition.
|
||||
*/
|
||||
revealPositionNearTop(position: IPosition, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Returns the primary selection of the editor.
|
||||
*/
|
||||
@@ -422,6 +434,12 @@ export interface IEditor {
|
||||
*/
|
||||
revealLinesInCenterIfOutsideViewport(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Scroll vertically as necessary and reveal lines close to the top of the viewport,
|
||||
* optimized for viewing a code definition.
|
||||
*/
|
||||
revealLinesNearTop(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Scroll vertically or horizontally as necessary and reveal a range.
|
||||
*/
|
||||
@@ -442,6 +460,12 @@ export interface IEditor {
|
||||
*/
|
||||
revealRangeInCenterIfOutsideViewport(range: IRange, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport,
|
||||
* optimized for viewing a code definition.
|
||||
*/
|
||||
revealRangeNearTop(range: IRange, scrollType?: ScrollType): void;
|
||||
|
||||
/**
|
||||
* Directly trigger a handler or an editor action.
|
||||
* @param source The source of the call.
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export namespace EditorContextKeys {
|
||||
|
||||
export const editorSimpleInput = new RawContextKey<boolean>('editorSimpleInput', false);
|
||||
/**
|
||||
* A context key that is set when the editor's text has focus (cursor is blinking).
|
||||
*/
|
||||
|
||||
@@ -290,6 +290,7 @@ export const enum EndOfLineSequence {
|
||||
|
||||
/**
|
||||
* An identifier for a single edit operation.
|
||||
* @internal
|
||||
*/
|
||||
export interface ISingleEditOperationIdentifier {
|
||||
/**
|
||||
|
||||
@@ -670,7 +670,7 @@ export class PieceTreeBase {
|
||||
if (searcher._wordSeparators) {
|
||||
searchText = buffer.buffer.substring(start, end);
|
||||
offsetInBuffer = (offset: number) => offset + start;
|
||||
searcher.reset(-1);
|
||||
searcher.reset(0);
|
||||
} else {
|
||||
searchText = buffer.buffer;
|
||||
offsetInBuffer = (offset: number) => offset;
|
||||
|
||||
@@ -2640,14 +2640,16 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
let goDown = true;
|
||||
let indent = 0;
|
||||
|
||||
let initialIndent = 0;
|
||||
|
||||
for (let distance = 0; goUp || goDown; distance++) {
|
||||
const upLineNumber = lineNumber - distance;
|
||||
const downLineNumber = lineNumber + distance;
|
||||
|
||||
if (distance !== 0 && (upLineNumber < 1 || upLineNumber < minLineNumber)) {
|
||||
if (distance > 1 && (upLineNumber < 1 || upLineNumber < minLineNumber)) {
|
||||
goUp = false;
|
||||
}
|
||||
if (distance !== 0 && (downLineNumber > lineCount || downLineNumber > maxLineNumber)) {
|
||||
if (distance > 1 && (downLineNumber > lineCount || downLineNumber > maxLineNumber)) {
|
||||
goDown = false;
|
||||
}
|
||||
if (distance > 50000) {
|
||||
@@ -2656,10 +2658,9 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
goDown = false;
|
||||
}
|
||||
|
||||
let upLineIndentLevel: number = -1;
|
||||
if (goUp) {
|
||||
// compute indent level going up
|
||||
let upLineIndentLevel: number;
|
||||
|
||||
const currentIndent = this._computeIndentLevel(upLineNumber - 1);
|
||||
if (currentIndent >= 0) {
|
||||
// This line has content (besides whitespace)
|
||||
@@ -2671,30 +2672,11 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
up_resolveIndents(upLineNumber);
|
||||
upLineIndentLevel = this._getIndentLevelForWhitespaceLine(offSide, up_aboveContentLineIndent, up_belowContentLineIndent);
|
||||
}
|
||||
|
||||
if (distance === 0) {
|
||||
// This is the initial line number
|
||||
startLineNumber = upLineNumber;
|
||||
endLineNumber = downLineNumber;
|
||||
indent = upLineIndentLevel;
|
||||
if (indent === 0) {
|
||||
// No need to continue
|
||||
return { startLineNumber, endLineNumber, indent };
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (upLineIndentLevel >= indent) {
|
||||
startLineNumber = upLineNumber;
|
||||
} else {
|
||||
goUp = false;
|
||||
}
|
||||
}
|
||||
|
||||
let downLineIndentLevel = -1;
|
||||
if (goDown) {
|
||||
// compute indent level going down
|
||||
let downLineIndentLevel: number;
|
||||
|
||||
const currentIndent = this._computeIndentLevel(downLineNumber - 1);
|
||||
if (currentIndent >= 0) {
|
||||
// This line has content (besides whitespace)
|
||||
@@ -2706,7 +2688,50 @@ export class TextModel extends Disposable implements model.ITextModel {
|
||||
down_resolveIndents(downLineNumber);
|
||||
downLineIndentLevel = this._getIndentLevelForWhitespaceLine(offSide, down_aboveContentLineIndent, down_belowContentLineIndent);
|
||||
}
|
||||
}
|
||||
|
||||
if (distance === 0) {
|
||||
initialIndent = upLineIndentLevel;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (distance === 1) {
|
||||
if (downLineNumber <= lineCount && downLineIndentLevel >= 0 && initialIndent + 1 === downLineIndentLevel) {
|
||||
// This is the beginning of a scope, we have special handling here, since we want the
|
||||
// child scope indent to be active, not the parent scope
|
||||
goUp = false;
|
||||
startLineNumber = downLineNumber;
|
||||
endLineNumber = downLineNumber;
|
||||
indent = downLineIndentLevel;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (upLineNumber >= 1 && upLineIndentLevel >= 0 && upLineIndentLevel - 1 === initialIndent) {
|
||||
// This is the end of a scope, just like above
|
||||
goDown = false;
|
||||
startLineNumber = upLineNumber;
|
||||
endLineNumber = upLineNumber;
|
||||
indent = upLineIndentLevel;
|
||||
continue;
|
||||
}
|
||||
|
||||
startLineNumber = lineNumber;
|
||||
endLineNumber = lineNumber;
|
||||
indent = initialIndent;
|
||||
if (indent === 0) {
|
||||
// No need to continue
|
||||
return { startLineNumber, endLineNumber, indent };
|
||||
}
|
||||
}
|
||||
|
||||
if (goUp) {
|
||||
if (upLineIndentLevel >= indent) {
|
||||
startLineNumber = upLineNumber;
|
||||
} else {
|
||||
goUp = false;
|
||||
}
|
||||
}
|
||||
if (goDown) {
|
||||
if (downLineIndentLevel >= indent) {
|
||||
endLineNumber = downLineNumber;
|
||||
} else {
|
||||
|
||||
@@ -80,6 +80,7 @@ export interface IModelDecorationsChangedEvent {
|
||||
|
||||
/**
|
||||
* An event describing that some ranges of lines have been tokenized (their tokens have changed).
|
||||
* @internal
|
||||
*/
|
||||
export interface IModelTokensChangedEvent {
|
||||
readonly tokenizationSupportChanged: boolean;
|
||||
|
||||
@@ -786,6 +786,15 @@ export class TokensStore2 {
|
||||
const bEndCharacter = bTokens.getEndCharacter(bIndex);
|
||||
const bMetadata = bTokens.getMetadata(bIndex);
|
||||
|
||||
const bMask = (
|
||||
((bMetadata & MetadataConsts.SEMANTIC_USE_ITALIC) ? MetadataConsts.ITALIC_MASK : 0)
|
||||
| ((bMetadata & MetadataConsts.SEMANTIC_USE_BOLD) ? MetadataConsts.BOLD_MASK : 0)
|
||||
| ((bMetadata & MetadataConsts.SEMANTIC_USE_UNDERLINE) ? MetadataConsts.UNDERLINE_MASK : 0)
|
||||
| ((bMetadata & MetadataConsts.SEMANTIC_USE_FOREGROUND) ? MetadataConsts.FOREGROUND_MASK : 0)
|
||||
| ((bMetadata & MetadataConsts.SEMANTIC_USE_BACKGROUND) ? MetadataConsts.BACKGROUND_MASK : 0)
|
||||
) >>> 0;
|
||||
const aMask = (~bMask) >>> 0;
|
||||
|
||||
// push any token from `a` that is before `b`
|
||||
while (aIndex < aLen && aTokens.getEndOffset(aIndex) <= bStartCharacter) {
|
||||
result[resultLen++] = aTokens.getEndOffset(aIndex);
|
||||
@@ -800,21 +809,24 @@ export class TokensStore2 {
|
||||
}
|
||||
|
||||
// skip any tokens from `a` that are contained inside `b`
|
||||
while (aIndex < aLen && aTokens.getEndOffset(aIndex) <= bEndCharacter) {
|
||||
while (aIndex < aLen && aTokens.getEndOffset(aIndex) < bEndCharacter) {
|
||||
result[resultLen++] = aTokens.getEndOffset(aIndex);
|
||||
result[resultLen++] = (aTokens.getMetadata(aIndex) & aMask) | (bMetadata & bMask);
|
||||
aIndex++;
|
||||
}
|
||||
|
||||
const aMetadata = aTokens.getMetadata(Math.min(Math.max(0, aIndex - 1), aLen - 1));
|
||||
const languageId = TokenMetadata.getLanguageId(aMetadata);
|
||||
const tokenType = TokenMetadata.getTokenType(aMetadata);
|
||||
if (aIndex < aLen && aTokens.getEndOffset(aIndex) === bEndCharacter) {
|
||||
// `a` ends exactly at the same spot as `b`!
|
||||
result[resultLen++] = aTokens.getEndOffset(aIndex);
|
||||
result[resultLen++] = (aTokens.getMetadata(aIndex) & aMask) | (bMetadata & bMask);
|
||||
aIndex++;
|
||||
} else {
|
||||
const aMergeIndex = Math.min(Math.max(0, aIndex - 1), aLen - 1);
|
||||
|
||||
// push the token from `b`
|
||||
result[resultLen++] = bEndCharacter;
|
||||
result[resultLen++] = (
|
||||
(bMetadata & MetadataConsts.LANG_TTYPE_CMPL)
|
||||
| ((languageId << MetadataConsts.LANGUAGEID_OFFSET) >>> 0)
|
||||
| ((tokenType << MetadataConsts.TOKEN_TYPE_OFFSET) >>> 0)
|
||||
);
|
||||
// push the token from `b`
|
||||
result[resultLen++] = bEndCharacter;
|
||||
result[resultLen++] = (aTokens.getMetadata(aMergeIndex) & aMask) | (bMetadata & bMask);
|
||||
}
|
||||
}
|
||||
|
||||
// push the remaining tokens from `a`
|
||||
|
||||
@@ -125,7 +125,15 @@ export const enum MetadataConsts {
|
||||
FOREGROUND_MASK = 0b00000000011111111100000000000000,
|
||||
BACKGROUND_MASK = 0b11111111100000000000000000000000,
|
||||
|
||||
LANG_TTYPE_CMPL = 0b11111111111111111111100000000000,
|
||||
ITALIC_MASK = 0b00000000000000000000100000000000,
|
||||
BOLD_MASK = 0b00000000000000000001000000000000,
|
||||
UNDERLINE_MASK = 0b00000000000000000010000000000000,
|
||||
|
||||
SEMANTIC_USE_ITALIC = 0b00000000000000000000000000000001,
|
||||
SEMANTIC_USE_BOLD = 0b00000000000000000000000000000010,
|
||||
SEMANTIC_USE_UNDERLINE = 0b00000000000000000000000000000100,
|
||||
SEMANTIC_USE_FOREGROUND = 0b00000000000000000000000000001000,
|
||||
SEMANTIC_USE_BACKGROUND = 0b00000000000000000000000000010000,
|
||||
|
||||
LANGUAGEID_OFFSET = 0,
|
||||
TOKEN_TYPE_OFFSET = 8,
|
||||
@@ -1330,10 +1338,10 @@ export interface RenameProvider {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface Session {
|
||||
export interface AuthenticationSession {
|
||||
id: string;
|
||||
accessToken: string;
|
||||
displayName: string;
|
||||
accessToken(): Promise<string>;
|
||||
accountName: string;
|
||||
}
|
||||
|
||||
export interface Command {
|
||||
|
||||
@@ -223,6 +223,7 @@ export class LinkComputer {
|
||||
let state = State.Start;
|
||||
let hasOpenParens = false;
|
||||
let hasOpenSquareBracket = false;
|
||||
let inSquareBrackets = false;
|
||||
let hasOpenCurlyBracket = false;
|
||||
|
||||
while (j < len) {
|
||||
@@ -241,10 +242,12 @@ export class LinkComputer {
|
||||
chClass = (hasOpenParens ? CharacterClass.None : CharacterClass.ForceTermination);
|
||||
break;
|
||||
case CharCode.OpenSquareBracket:
|
||||
inSquareBrackets = true;
|
||||
hasOpenSquareBracket = true;
|
||||
chClass = CharacterClass.None;
|
||||
break;
|
||||
case CharCode.CloseSquareBracket:
|
||||
inSquareBrackets = false;
|
||||
chClass = (hasOpenSquareBracket ? CharacterClass.None : CharacterClass.ForceTermination);
|
||||
break;
|
||||
case CharCode.OpenCurlyBrace:
|
||||
@@ -272,6 +275,10 @@ export class LinkComputer {
|
||||
// `|` terminates a link if the link began with `|`
|
||||
chClass = (linkBeginChCode === CharCode.Pipe) ? CharacterClass.ForceTermination : CharacterClass.None;
|
||||
break;
|
||||
case CharCode.Space:
|
||||
// ` ` allow space in between [ and ]
|
||||
chClass = (inSquareBrackets ? CharacterClass.None : CharacterClass.ForceTermination);
|
||||
break;
|
||||
default:
|
||||
chClass = classifier.get(chCode);
|
||||
}
|
||||
|
||||
@@ -45,11 +45,13 @@ function canSyncModel(modelService: IModelService, resource: URI): boolean {
|
||||
}
|
||||
|
||||
export class EditorWorkerServiceImpl extends Disposable implements IEditorWorkerService {
|
||||
public _serviceBrand: undefined;
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _modelService: IModelService;
|
||||
private readonly _workerManager: WorkerManager;
|
||||
private readonly _logService: ILogService;
|
||||
|
||||
constructor(
|
||||
@IModelService modelService: IModelService,
|
||||
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
|
||||
@@ -60,7 +62,7 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker
|
||||
this._workerManager = this._register(new WorkerManager(this._modelService));
|
||||
this._logService = logService;
|
||||
|
||||
// todo@joh make sure this happens only once
|
||||
// register default link-provider and default completions-provider
|
||||
this._register(modes.LinkProviderRegistry.register('*', {
|
||||
provideLinks: (model, token) => {
|
||||
if (!canSyncModel(this._modelService, model.uri)) {
|
||||
|
||||
@@ -8,13 +8,13 @@ import { Disposable, IDisposable, DisposableStore } from 'vs/base/common/lifecyc
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { EDITOR_MODEL_DEFAULTS, IEditorSemanticHighlightingOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DefaultEndOfLine, EndOfLinePreference, EndOfLineSequence, IIdentifiedSingleEditOperation, ITextBuffer, ITextBufferFactory, ITextModel, ITextModelCreationOptions } from 'vs/editor/common/model';
|
||||
import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel';
|
||||
import { IModelLanguageChangedEvent, IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { LanguageIdentifier, DocumentSemanticTokensProviderRegistry, DocumentSemanticTokensProvider, SemanticTokensLegend, SemanticTokens, SemanticTokensEdits, TokenMetadata } from 'vs/editor/common/modes';
|
||||
import { LanguageIdentifier, DocumentSemanticTokensProviderRegistry, DocumentSemanticTokensProvider, SemanticTokensLegend, SemanticTokens, SemanticTokensEdits, TokenMetadata, FontStyle, MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { PLAINTEXT_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/modesRegistry';
|
||||
import { ILanguageSelection } from 'vs/editor/common/services/modeService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
@@ -26,6 +26,10 @@ import { SparseEncodedTokens, MultilineTokens2 } from 'vs/editor/common/model/to
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
|
||||
|
||||
export interface IEditorSemanticHighlightingOptions {
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
function MODEL_ID(resource: URI): string {
|
||||
return resource.toString();
|
||||
}
|
||||
@@ -629,7 +633,7 @@ class SemanticColoringProviderStyling {
|
||||
|
||||
public getMetadata(tokenTypeIndex: number, tokenModifierSet: number): number {
|
||||
const entry = this._hashTable.get(tokenTypeIndex, tokenModifierSet);
|
||||
let metadata: number | undefined;
|
||||
let metadata: number;
|
||||
if (entry) {
|
||||
metadata = entry.metadata;
|
||||
} else {
|
||||
@@ -643,9 +647,31 @@ class SemanticColoringProviderStyling {
|
||||
modifierSet = modifierSet >> 1;
|
||||
}
|
||||
|
||||
metadata = this._themeService.getTheme().getTokenStyleMetadata(tokenType, tokenModifiers);
|
||||
if (typeof metadata === 'undefined') {
|
||||
const tokenStyle = this._themeService.getTheme().getTokenStyleMetadata(tokenType, tokenModifiers);
|
||||
if (typeof tokenStyle === 'undefined') {
|
||||
metadata = Constants.NO_STYLING;
|
||||
} else {
|
||||
metadata = 0;
|
||||
if (typeof tokenStyle.italic !== 'undefined') {
|
||||
const italicBit = (tokenStyle.italic ? FontStyle.Italic : 0) << MetadataConsts.FONT_STYLE_OFFSET;
|
||||
metadata |= italicBit | MetadataConsts.SEMANTIC_USE_ITALIC;
|
||||
}
|
||||
if (typeof tokenStyle.bold !== 'undefined') {
|
||||
const boldBit = (tokenStyle.bold ? FontStyle.Bold : 0) << MetadataConsts.FONT_STYLE_OFFSET;
|
||||
metadata |= boldBit | MetadataConsts.SEMANTIC_USE_BOLD;
|
||||
}
|
||||
if (typeof tokenStyle.underline !== 'undefined') {
|
||||
const underlineBit = (tokenStyle.underline ? FontStyle.Underline : 0) << MetadataConsts.FONT_STYLE_OFFSET;
|
||||
metadata |= underlineBit | MetadataConsts.SEMANTIC_USE_UNDERLINE;
|
||||
}
|
||||
if (tokenStyle.foreground) {
|
||||
const foregroundBits = (tokenStyle.foreground) << MetadataConsts.FOREGROUND_OFFSET;
|
||||
metadata |= foregroundBits | MetadataConsts.SEMANTIC_USE_FOREGROUND;
|
||||
}
|
||||
if (metadata === 0) {
|
||||
// Nothing!
|
||||
metadata = Constants.NO_STYLING;
|
||||
}
|
||||
}
|
||||
this._hashTable.add(tokenTypeIndex, tokenModifierSet, metadata);
|
||||
}
|
||||
@@ -763,10 +789,21 @@ class ModelSemanticColoring extends Disposable {
|
||||
contentChangeListener.dispose();
|
||||
this._setSemanticTokens(provider, res || null, styling, pendingChanges);
|
||||
}, (err) => {
|
||||
errors.onUnexpectedError(err);
|
||||
if (!err || typeof err.message !== 'string' || err.message.indexOf('busy') === -1) {
|
||||
errors.onUnexpectedError(err);
|
||||
}
|
||||
|
||||
// Semantic tokens eats up all errors and considers errors to mean that the result is temporarily not available
|
||||
// The API does not have a special error kind to express this...
|
||||
this._currentRequestCancellationTokenSource = null;
|
||||
contentChangeListener.dispose();
|
||||
this._setSemanticTokens(provider, null, styling, pendingChanges);
|
||||
|
||||
if (pendingChanges.length > 0) {
|
||||
// More changes occurred while the request was running
|
||||
if (!this._fetchSemanticTokens.isScheduled()) {
|
||||
this._fetchSemanticTokens.schedule();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -231,50 +231,51 @@ export enum EditorOption {
|
||||
overviewRulerLanes = 63,
|
||||
parameterHints = 64,
|
||||
peekWidgetDefaultFocus = 65,
|
||||
quickSuggestions = 66,
|
||||
quickSuggestionsDelay = 67,
|
||||
readOnly = 68,
|
||||
renderControlCharacters = 69,
|
||||
renderIndentGuides = 70,
|
||||
renderFinalNewline = 71,
|
||||
renderLineHighlight = 72,
|
||||
renderValidationDecorations = 73,
|
||||
renderWhitespace = 74,
|
||||
revealHorizontalRightPadding = 75,
|
||||
roundedSelection = 76,
|
||||
rulers = 77,
|
||||
scrollbar = 78,
|
||||
scrollBeyondLastColumn = 79,
|
||||
scrollBeyondLastLine = 80,
|
||||
selectionClipboard = 81,
|
||||
selectionHighlight = 82,
|
||||
selectOnLineNumbers = 83,
|
||||
semanticHighlighting = 84,
|
||||
showFoldingControls = 85,
|
||||
showUnused = 86,
|
||||
snippetSuggestions = 87,
|
||||
smoothScrolling = 88,
|
||||
stopRenderingLineAfter = 89,
|
||||
suggest = 90,
|
||||
suggestFontSize = 91,
|
||||
suggestLineHeight = 92,
|
||||
suggestOnTriggerCharacters = 93,
|
||||
suggestSelection = 94,
|
||||
tabCompletion = 95,
|
||||
useTabStops = 96,
|
||||
wordSeparators = 97,
|
||||
wordWrap = 98,
|
||||
wordWrapBreakAfterCharacters = 99,
|
||||
wordWrapBreakBeforeCharacters = 100,
|
||||
wordWrapColumn = 101,
|
||||
wordWrapMinified = 102,
|
||||
wrappingIndent = 103,
|
||||
wrappingAlgorithm = 104,
|
||||
editorClassName = 105,
|
||||
pixelRatio = 106,
|
||||
tabFocusMode = 107,
|
||||
layoutInfo = 108,
|
||||
wrappingInfo = 109
|
||||
definitionLinkOpensInPeek = 66,
|
||||
quickSuggestions = 67,
|
||||
quickSuggestionsDelay = 68,
|
||||
readOnly = 69,
|
||||
renderControlCharacters = 70,
|
||||
renderIndentGuides = 71,
|
||||
renderFinalNewline = 72,
|
||||
renderLineHighlight = 73,
|
||||
renderValidationDecorations = 74,
|
||||
renderWhitespace = 75,
|
||||
revealHorizontalRightPadding = 76,
|
||||
roundedSelection = 77,
|
||||
rulers = 78,
|
||||
scrollbar = 79,
|
||||
scrollBeyondLastColumn = 80,
|
||||
scrollBeyondLastLine = 81,
|
||||
scrollPredominantAxis = 82,
|
||||
selectionClipboard = 83,
|
||||
selectionHighlight = 84,
|
||||
selectOnLineNumbers = 85,
|
||||
showFoldingControls = 86,
|
||||
showUnused = 87,
|
||||
snippetSuggestions = 88,
|
||||
smoothScrolling = 89,
|
||||
stopRenderingLineAfter = 90,
|
||||
suggest = 91,
|
||||
suggestFontSize = 92,
|
||||
suggestLineHeight = 93,
|
||||
suggestOnTriggerCharacters = 94,
|
||||
suggestSelection = 95,
|
||||
tabCompletion = 96,
|
||||
useTabStops = 97,
|
||||
wordSeparators = 98,
|
||||
wordWrap = 99,
|
||||
wordWrapBreakAfterCharacters = 100,
|
||||
wordWrapBreakBeforeCharacters = 101,
|
||||
wordWrapColumn = 102,
|
||||
wordWrapMinified = 103,
|
||||
wrappingIndent = 104,
|
||||
wrappingStrategy = 105,
|
||||
editorClassName = 106,
|
||||
pixelRatio = 107,
|
||||
tabFocusMode = 108,
|
||||
layoutInfo = 109,
|
||||
wrappingInfo = 110
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,6 +87,7 @@ registerThemingParticipant((theme, collector) => {
|
||||
|
||||
const invisibles = theme.getColor(editorWhitespaces);
|
||||
if (invisibles) {
|
||||
collector.addRule(`.vs-whitespace { color: ${invisibles} !important; }`);
|
||||
collector.addRule(`.monaco-editor .mtkw { color: ${invisibles} !important; }`);
|
||||
collector.addRule(`.monaco-editor .mtkz { color: ${invisibles} !important; }`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -183,7 +183,8 @@ export const enum VerticalRevealType {
|
||||
Center = 1,
|
||||
CenterIfOutsideViewport = 2,
|
||||
Top = 3,
|
||||
Bottom = 4
|
||||
Bottom = 4,
|
||||
NearTop = 5,
|
||||
}
|
||||
|
||||
export class ViewRevealRangeRequestEvent {
|
||||
|
||||
@@ -262,7 +262,6 @@ export class LinesLayout {
|
||||
|
||||
private _checkPendingChanges(): void {
|
||||
if (this._pendingChanges.mustCommit()) {
|
||||
console.warn(`Commiting pending changes before change accessor leaves due to read access.`);
|
||||
this._pendingChanges.commit(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,13 +300,23 @@ export class ViewLayout extends Disposable implements IViewLayout {
|
||||
private _computeContentWidth(maxLineWidth: number): number {
|
||||
const options = this._configuration.options;
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
let isViewportWrapping = wrappingInfo.isViewportWrapping;
|
||||
if (!isViewportWrapping) {
|
||||
const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
if (wrappingInfo.isViewportWrapping) {
|
||||
const layoutInfo = options.get(EditorOption.layoutInfo);
|
||||
const minimap = options.get(EditorOption.minimap);
|
||||
if (maxLineWidth > layoutInfo.contentWidth + fontInfo.typicalHalfwidthCharacterWidth) {
|
||||
// This is a case where viewport wrapping is on, but the line extends above the viewport
|
||||
if (minimap.enabled && minimap.side === 'right') {
|
||||
// We need to accomodate the scrollbar width
|
||||
return maxLineWidth + layoutInfo.verticalScrollbarWidth;
|
||||
}
|
||||
}
|
||||
return maxLineWidth;
|
||||
} else {
|
||||
const extraHorizontalSpace = options.get(EditorOption.scrollBeyondLastColumn) * fontInfo.typicalHalfwidthCharacterWidth;
|
||||
const whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth();
|
||||
return Math.max(maxLineWidth + extraHorizontalSpace, whitespaceMinWidth);
|
||||
}
|
||||
return maxLineWidth;
|
||||
}
|
||||
|
||||
public onMaxLineWidthChanged(maxLineWidth: number): void {
|
||||
|
||||
@@ -549,7 +549,7 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
|
||||
}
|
||||
|
||||
/**
|
||||
* Whitespace is rendered by "replacing" tokens with a special-purpose `vs-whitespace` type that is later recognized in the rendering phase.
|
||||
* Whitespace is rendered by "replacing" tokens with a special-purpose `mtkw` type that is later recognized in the rendering phase.
|
||||
* Moreover, a token is created for every visual indent because on some fonts the glyphs used for rendering whitespace (→ or ·) do not have the same width as .
|
||||
* The rendering phase will generate `style="width:..."` for these tokens.
|
||||
*/
|
||||
@@ -616,7 +616,7 @@ function _applyRenderWhitespace(lineContent: string, len: number, continuesWithW
|
||||
// was in whitespace token
|
||||
if (!isInWhitespace || (!useMonospaceOptimizations && tmpIndent >= tabSize)) {
|
||||
// leaving whitespace token or entering a new indent
|
||||
result[resultLen++] = new LinePart(charIndex, 'vs-whitespace');
|
||||
result[resultLen++] = new LinePart(charIndex, 'mtkw');
|
||||
tmpIndent = tmpIndent % tabSize;
|
||||
}
|
||||
} else {
|
||||
@@ -661,7 +661,7 @@ function _applyRenderWhitespace(lineContent: string, len: number, continuesWithW
|
||||
}
|
||||
}
|
||||
|
||||
result[resultLen++] = new LinePart(len, generateWhitespace ? 'vs-whitespace' : tokenType);
|
||||
result[resultLen++] = new LinePart(len, generateWhitespace ? 'mtkw' : tokenType);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -763,11 +763,12 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
|
||||
const part = parts[partIndex];
|
||||
const partEndIndex = part.endIndex;
|
||||
const partType = part.type;
|
||||
const partRendersWhitespace = (renderWhitespace !== RenderWhitespace.None && (partType.indexOf('vs-whitespace') >= 0));
|
||||
const partRendersWhitespace = (renderWhitespace !== RenderWhitespace.None && (partType.indexOf('mtkw') >= 0));
|
||||
const partRendersWhitespaceWithWidth = partRendersWhitespace && !fontIsMonospace && (partType === 'mtkw'/*only whitespace*/ || !containsForeignElements);
|
||||
charOffsetInPart = 0;
|
||||
|
||||
sb.appendASCIIString('<span class="');
|
||||
sb.appendASCIIString(partType);
|
||||
sb.appendASCIIString(partRendersWhitespaceWithWidth ? 'mtkz' : partType);
|
||||
sb.appendASCII(CharCode.DoubleQuote);
|
||||
|
||||
if (partRendersWhitespace) {
|
||||
@@ -787,13 +788,10 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
|
||||
}
|
||||
}
|
||||
|
||||
if (!fontIsMonospace) {
|
||||
const partIsOnlyWhitespace = (partType === 'vs-whitespace');
|
||||
if (partIsOnlyWhitespace || !containsForeignElements) {
|
||||
sb.appendASCIIString(' style="display:inline-block;width:');
|
||||
sb.appendASCIIString(String(spaceWidth * partContentCnt));
|
||||
sb.appendASCIIString('px"');
|
||||
}
|
||||
if (partRendersWhitespaceWithWidth) {
|
||||
sb.appendASCIIString(' style="width:');
|
||||
sb.appendASCIIString(String(spaceWidth * partContentCnt));
|
||||
sb.appendASCIIString('px"');
|
||||
}
|
||||
sb.appendASCII(CharCode.GreaterThan);
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ export interface ISplitLine {
|
||||
export interface IViewModelLinesCollection extends IDisposable {
|
||||
createCoordinatesConverter(): ICoordinatesConverter;
|
||||
|
||||
setWrappingSettings(fontInfo: FontInfo, wrappingAlgorithm: 'monospace' | 'dom', wrappingColumn: number, wrappingIndent: WrappingIndent): boolean;
|
||||
setWrappingSettings(fontInfo: FontInfo, wrappingStrategy: 'simple' | 'advanced', wrappingColumn: number, wrappingIndent: WrappingIndent): boolean;
|
||||
setTabSize(newTabSize: number): boolean;
|
||||
getHiddenAreas(): Range[];
|
||||
setHiddenAreas(_ranges: Range[]): boolean;
|
||||
@@ -277,7 +277,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
private tabSize: number;
|
||||
private wrappingColumn: number;
|
||||
private wrappingIndent: WrappingIndent;
|
||||
private wrappingAlgorithm: 'monospace' | 'dom';
|
||||
private wrappingStrategy: 'simple' | 'advanced';
|
||||
private lines!: ISplitLine[];
|
||||
|
||||
private prefixSumComputer!: LineNumberMapper;
|
||||
@@ -290,7 +290,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
monospaceLineBreaksComputerFactory: ILineBreaksComputerFactory,
|
||||
fontInfo: FontInfo,
|
||||
tabSize: number,
|
||||
wrappingAlgorithm: 'monospace' | 'dom',
|
||||
wrappingStrategy: 'simple' | 'advanced',
|
||||
wrappingColumn: number,
|
||||
wrappingIndent: WrappingIndent,
|
||||
) {
|
||||
@@ -300,7 +300,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
this._monospaceLineBreaksComputerFactory = monospaceLineBreaksComputerFactory;
|
||||
this.fontInfo = fontInfo;
|
||||
this.tabSize = tabSize;
|
||||
this.wrappingAlgorithm = wrappingAlgorithm;
|
||||
this.wrappingStrategy = wrappingStrategy;
|
||||
this.wrappingColumn = wrappingColumn;
|
||||
this.wrappingIndent = wrappingIndent;
|
||||
|
||||
@@ -484,19 +484,19 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
return true;
|
||||
}
|
||||
|
||||
public setWrappingSettings(fontInfo: FontInfo, wrappingAlgorithm: 'monospace' | 'dom', wrappingColumn: number, wrappingIndent: WrappingIndent): boolean {
|
||||
public setWrappingSettings(fontInfo: FontInfo, wrappingStrategy: 'simple' | 'advanced', wrappingColumn: number, wrappingIndent: WrappingIndent): boolean {
|
||||
const equalFontInfo = this.fontInfo.equals(fontInfo);
|
||||
const equalWrappingAlgorithm = (this.wrappingAlgorithm === wrappingAlgorithm);
|
||||
const equalWrappingStrategy = (this.wrappingStrategy === wrappingStrategy);
|
||||
const equalWrappingColumn = (this.wrappingColumn === wrappingColumn);
|
||||
const equalWrappingIndent = (this.wrappingIndent === wrappingIndent);
|
||||
if (equalFontInfo && equalWrappingAlgorithm && equalWrappingColumn && equalWrappingIndent) {
|
||||
if (equalFontInfo && equalWrappingStrategy && equalWrappingColumn && equalWrappingIndent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const onlyWrappingColumnChanged = (equalFontInfo && equalWrappingAlgorithm && !equalWrappingColumn && equalWrappingIndent);
|
||||
const onlyWrappingColumnChanged = (equalFontInfo && equalWrappingStrategy && !equalWrappingColumn && equalWrappingIndent);
|
||||
|
||||
this.fontInfo = fontInfo;
|
||||
this.wrappingAlgorithm = wrappingAlgorithm;
|
||||
this.wrappingStrategy = wrappingStrategy;
|
||||
this.wrappingColumn = wrappingColumn;
|
||||
this.wrappingIndent = wrappingIndent;
|
||||
|
||||
@@ -515,7 +515,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
|
||||
|
||||
public createLineBreaksComputer(): ILineBreaksComputer {
|
||||
const lineBreaksComputerFactory = (
|
||||
this.wrappingAlgorithm === 'dom'
|
||||
this.wrappingStrategy === 'advanced'
|
||||
? this._domLineBreaksComputerFactory
|
||||
: this._monospaceLineBreaksComputerFactory
|
||||
);
|
||||
@@ -1460,7 +1460,7 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
|
||||
return false;
|
||||
}
|
||||
|
||||
public setWrappingSettings(_fontInfo: FontInfo, _wrappingAlgorithm: 'monospace' | 'dom', _wrappingColumn: number, _wrappingIndent: WrappingIndent): boolean {
|
||||
public setWrappingSettings(_fontInfo: FontInfo, _wrappingStrategy: 'simple' | 'advanced', _wrappingColumn: number, _wrappingIndent: WrappingIndent): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
} else {
|
||||
const options = this.configuration.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const wrappingAlgorithm = options.get(EditorOption.wrappingAlgorithm);
|
||||
const wrappingStrategy = options.get(EditorOption.wrappingStrategy);
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const wrappingIndent = options.get(EditorOption.wrappingIndent);
|
||||
|
||||
@@ -78,7 +78,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
monospaceLineBreaksComputerFactory,
|
||||
fontInfo,
|
||||
this.model.getOptions().tabSize,
|
||||
wrappingAlgorithm,
|
||||
wrappingStrategy,
|
||||
wrappingInfo.wrappingColumn,
|
||||
wrappingIndent
|
||||
);
|
||||
@@ -165,11 +165,11 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
|
||||
const options = this.configuration.options;
|
||||
const fontInfo = options.get(EditorOption.fontInfo);
|
||||
const wrappingAlgorithm = options.get(EditorOption.wrappingAlgorithm);
|
||||
const wrappingStrategy = options.get(EditorOption.wrappingStrategy);
|
||||
const wrappingInfo = options.get(EditorOption.wrappingInfo);
|
||||
const wrappingIndent = options.get(EditorOption.wrappingIndent);
|
||||
|
||||
if (this.lines.setWrappingSettings(fontInfo, wrappingAlgorithm, wrappingInfo.wrappingColumn, wrappingIndent)) {
|
||||
if (this.lines.setWrappingSettings(fontInfo, wrappingStrategy, wrappingInfo.wrappingColumn, wrappingIndent)) {
|
||||
eventsCollector.emit(new viewEvents.ViewFlushedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
|
||||
eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
|
||||
|
||||
Reference in New Issue
Block a user