diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index e7e36871bf1..e5e5ef72371 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -926,6 +926,7 @@ export interface ITextModelWithMarkers extends ITextModel { /** * Describes the behaviour of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehaviour` */ export enum TrackedRangeStickiness { AlwaysGrowsWhenTypingAtEdges = 0, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 7f3c80b83fa..2ae279bad8b 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1639,6 +1639,7 @@ declare module monaco.editor { /** * Describes the behaviour of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehaviour` */ export enum TrackedRangeStickiness { AlwaysGrowsWhenTypingAtEdges = 0, diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index ca27a99e4ef..c83e51b96df 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -701,13 +701,25 @@ declare module 'vscode' { } /** - * Describes the behaviour of decorations when typing/editing near their edges. + * Describes the behaviour of decorations when typing/editing at their edges. */ - export enum TrackedRangeStickiness { - AlwaysGrowsWhenTypingAtEdges = 0, - NeverGrowsWhenTypingAtEdges = 1, - GrowsOnlyWhenTypingBefore = 2, - GrowsOnlyWhenTypingAfter = 3 + export enum DecorationRangeBehaviour { + /** + * The decoration's range will widen when edits occur at the start or end. + */ + OpenOpen = 0, + /** + * The decoration's range will not widen when edits occur at the start of end. + */ + ClosedClosed = 1, + /** + * The decoration's range will widen when edits occur at the start, but not at the end. + */ + OpenClosed = 2, + /** + * The decoration's range will widen when edits occur at the end, but not at the start. + */ + ClosedOpen = 3 } /** @@ -917,10 +929,10 @@ declare module 'vscode' { isWholeLine?: boolean; /** - * Customize the growing behaviour of the decoration when typing at the edges of the decoration. - * Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges + * Customize the growing behaviour of the decoration when edits occur at the edges of the decoration's range. + * Defaults to `DecorationRangeBehaviour.OpenOpen`. */ - stickiness?: TrackedRangeStickiness; + rangeBehaviour?: DecorationRangeBehaviour; /** * The position in the overview ruler where the decoration should be rendered. diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 11fda78db64..1c7a6687056 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -529,7 +529,7 @@ export function createApiFactory( TextEditorLineNumbersStyle: extHostTypes.TextEditorLineNumbersStyle, TextEditorRevealType: extHostTypes.TextEditorRevealType, TextEditorSelectionChangeKind: extHostTypes.TextEditorSelectionChangeKind, - TrackedRangeStickiness: EditorCommon.TrackedRangeStickiness, + DecorationRangeBehaviour: extHostTypes.DecorationRangeBehaviour, Uri: URI, ViewColumn: extHostTypes.ViewColumn, WorkspaceEdit: extHostTypes.WorkspaceEdit, diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index 7548f24f051..2e90e54aba4 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -962,6 +962,28 @@ export enum TextEditorSelectionChangeKind { Command = 3 } +/** + * These values match very carefully the values of `TrackedRangeStickiness` + */ +export enum DecorationRangeBehaviour { + /** + * TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges + */ + OpenOpen = 0, + /** + * TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges + */ + ClosedClosed = 1, + /** + * TrackedRangeStickiness.GrowsOnlyWhenTypingBefore + */ + OpenClosed = 2, + /** + * TrackedRangeStickiness.GrowsOnlyWhenTypingAfter + */ + ClosedOpen = 3 +} + export namespace TextEditorSelectionChangeKind { export function fromValue(s: string) { switch (s) {