Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export abstract class AbstractLineHighlightOverlay extends DynamicViewOverlay {
protected _contentWidth: number;
protected _selectionIsEmpty: boolean;
protected _renderLineHighlightOnlyWhenFocus: boolean;
protected _cursorSurroundingLinesHighlightOnSelection: boolean;
protected _focused: boolean;
/**
* Unique sorted list of view line numbers which have cursors sitting on them.
Expand All @@ -40,6 +41,7 @@ export abstract class AbstractLineHighlightOverlay extends DynamicViewOverlay {
const layoutInfo = options.get(EditorOption.layoutInfo);
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
this._renderLineHighlightOnlyWhenFocus = options.get(EditorOption.renderLineHighlightOnlyWhenFocus);
this._cursorSurroundingLinesHighlightOnSelection = options.get(EditorOption.cursorSurroundingLinesHighlightOnSelection);
this._wordWrap = layoutInfo.isViewportWrapping;
this._contentLeft = layoutInfo.contentLeft;
this._contentWidth = layoutInfo.contentWidth;
Expand Down Expand Up @@ -89,6 +91,7 @@ export abstract class AbstractLineHighlightOverlay extends DynamicViewOverlay {
const layoutInfo = options.get(EditorOption.layoutInfo);
this._renderLineHighlight = options.get(EditorOption.renderLineHighlight);
this._renderLineHighlightOnlyWhenFocus = options.get(EditorOption.renderLineHighlightOnlyWhenFocus);
this._cursorSurroundingLinesHighlightOnSelection = options.get(EditorOption.cursorSurroundingLinesHighlightOnSelection);
this._wordWrap = layoutInfo.isViewportWrapping;
this._contentLeft = layoutInfo.contentLeft;
this._contentWidth = layoutInfo.contentWidth;
Expand Down Expand Up @@ -191,7 +194,7 @@ export abstract class AbstractLineHighlightOverlay extends DynamicViewOverlay {
protected _shouldRenderInContent(): boolean {
return (
(this._renderLineHighlight === 'line' || this._renderLineHighlight === 'all')
&& this._selectionIsEmpty
&& (this._selectionIsEmpty || this._cursorSurroundingLinesHighlightOnSelection)
&& (!this._renderLineHighlightOnlyWhenFocus || this._focused)
);
}
Expand Down
10 changes: 10 additions & 0 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,11 @@ export interface IEditorOptions {
* Defaults to false.
*/
renderLineHighlightOnlyWhenFocus?: boolean;
/**
* Control if the current line highlight should be rendered when there is a selection.
* Defaults to false.
*/
cursorSurroundingLinesHighlightOnSelection?: boolean;
/**
* Inserting and deleting whitespace follows tab stops.
*/
Expand Down Expand Up @@ -5835,6 +5840,7 @@ export const enum EditorOption {
renderFinalNewline,
renderLineHighlight,
renderLineHighlightOnlyWhenFocus,
cursorSurroundingLinesHighlightOnSelection,
renderValidationDecorations,
renderWhitespace,
revealHorizontalRightPadding,
Expand Down Expand Up @@ -6506,6 +6512,10 @@ export const EditorOptions = {
EditorOption.renderLineHighlightOnlyWhenFocus, 'renderLineHighlightOnlyWhenFocus', false,
{ description: nls.localize('renderLineHighlightOnlyWhenFocus', "Controls if the editor should render the current line highlight only when the editor is focused.") }
)),
cursorSurroundingLinesHighlightOnSelection: register(new EditorBooleanOption(
EditorOption.cursorSurroundingLinesHighlightOnSelection, 'cursorSurroundingLinesHighlightOnSelection', false,
{ description: nls.localize('cursorSurroundingLinesHighlightOnSelection', "Controls whether the editor should render the current line highlight when there is a selection.") }
)),
renderValidationDecorations: register(new EditorStringEnumOption(
EditorOption.renderValidationDecorations, 'renderValidationDecorations',
'editable' as 'editable' | 'on' | 'off',
Expand Down
123 changes: 62 additions & 61 deletions src/vs/editor/common/standalone/standaloneEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,67 +286,68 @@ export enum EditorOption {
renderFinalNewline = 109,
renderLineHighlight = 110,
renderLineHighlightOnlyWhenFocus = 111,
renderValidationDecorations = 112,
renderWhitespace = 113,
revealHorizontalRightPadding = 114,
roundedSelection = 115,
rulers = 116,
scrollbar = 117,
scrollBeyondLastColumn = 118,
scrollBeyondLastLine = 119,
scrollPredominantAxis = 120,
selectionClipboard = 121,
selectionHighlight = 122,
selectionHighlightMaxLength = 123,
selectionHighlightMultiline = 124,
selectOnLineNumbers = 125,
showFoldingControls = 126,
showUnused = 127,
snippetSuggestions = 128,
smartSelect = 129,
smoothScrolling = 130,
stickyScroll = 131,
stickyTabStops = 132,
stopRenderingLineAfter = 133,
suggest = 134,
suggestFontSize = 135,
suggestLineHeight = 136,
suggestOnTriggerCharacters = 137,
suggestSelection = 138,
tabCompletion = 139,
tabIndex = 140,
trimWhitespaceOnDelete = 141,
unicodeHighlighting = 142,
unusualLineTerminators = 143,
useShadowDOM = 144,
useTabStops = 145,
wordBreak = 146,
wordSegmenterLocales = 147,
wordSeparators = 148,
wordWrap = 149,
wordWrapBreakAfterCharacters = 150,
wordWrapBreakBeforeCharacters = 151,
wordWrapColumn = 152,
wordWrapOverride1 = 153,
wordWrapOverride2 = 154,
wrappingIndent = 155,
wrappingStrategy = 156,
showDeprecated = 157,
inertialScroll = 158,
inlayHints = 159,
wrapOnEscapedLineFeeds = 160,
effectiveCursorStyle = 161,
editorClassName = 162,
pixelRatio = 163,
tabFocusMode = 164,
layoutInfo = 165,
wrappingInfo = 166,
defaultColorDecorators = 167,
colorDecoratorsActivatedOn = 168,
inlineCompletionsAccessibilityVerbose = 169,
effectiveEditContext = 170,
scrollOnMiddleClick = 171,
effectiveAllowVariableFonts = 172
cursorSurroundingLinesHighlightOnSelection = 112,
renderValidationDecorations = 113,
renderWhitespace = 114,
revealHorizontalRightPadding = 115,
roundedSelection = 116,
rulers = 117,
scrollbar = 118,
scrollBeyondLastColumn = 119,
scrollBeyondLastLine = 120,
scrollPredominantAxis = 121,
selectionClipboard = 122,
selectionHighlight = 123,
selectionHighlightMaxLength = 124,
selectionHighlightMultiline = 125,
selectOnLineNumbers = 126,
showFoldingControls = 127,
showUnused = 128,
snippetSuggestions = 129,
smartSelect = 130,
smoothScrolling = 131,
stickyScroll = 132,
stickyTabStops = 133,
stopRenderingLineAfter = 134,
suggest = 135,
suggestFontSize = 136,
suggestLineHeight = 137,
suggestOnTriggerCharacters = 138,
suggestSelection = 139,
tabCompletion = 140,
tabIndex = 141,
trimWhitespaceOnDelete = 142,
unicodeHighlighting = 143,
unusualLineTerminators = 144,
useShadowDOM = 145,
useTabStops = 146,
wordBreak = 147,
wordSegmenterLocales = 148,
wordSeparators = 149,
wordWrap = 150,
wordWrapBreakAfterCharacters = 151,
wordWrapBreakBeforeCharacters = 152,
wordWrapColumn = 153,
wordWrapOverride1 = 154,
wordWrapOverride2 = 155,
wrappingIndent = 156,
wrappingStrategy = 157,
showDeprecated = 158,
inertialScroll = 159,
inlayHints = 160,
wrapOnEscapedLineFeeds = 161,
effectiveCursorStyle = 162,
editorClassName = 163,
pixelRatio = 164,
tabFocusMode = 165,
layoutInfo = 166,
wrappingInfo = 167,
defaultColorDecorators = 168,
colorDecoratorsActivatedOn = 169,
inlineCompletionsAccessibilityVerbose = 170,
effectiveEditContext = 171,
scrollOnMiddleClick = 172,
effectiveAllowVariableFonts = 173
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/vs/editor/test/browser/config/editorConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,22 @@ suite('Common Editor Config', () => {
);
config.dispose();
});

test('cursorSurroundingLinesHighlightOnSelection option', () => {
// Test default value is false
const config = new TestConfiguration({});
assert.strictEqual(config.options.get(EditorOption.cursorSurroundingLinesHighlightOnSelection), false);

// Test setting to true
config.updateOptions({ cursorSurroundingLinesHighlightOnSelection: true });
assert.strictEqual(config.options.get(EditorOption.cursorSurroundingLinesHighlightOnSelection), true);

// Test setting back to false
config.updateOptions({ cursorSurroundingLinesHighlightOnSelection: false });
assert.strictEqual(config.options.get(EditorOption.cursorSurroundingLinesHighlightOnSelection), false);

config.dispose();
});
});

suite('migrateOptions', () => {
Expand Down
129 changes: 68 additions & 61 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3883,6 +3883,11 @@ declare namespace monaco.editor {
* Defaults to false.
*/
renderLineHighlightOnlyWhenFocus?: boolean;
/**
* Control if the current line highlight should be rendered when there is a selection.
* Defaults to false.
*/
cursorSurroundingLinesHighlightOnSelection?: boolean;
/**
* Inserting and deleting whitespace follows tab stops.
*/
Expand Down Expand Up @@ -5173,67 +5178,68 @@ declare namespace monaco.editor {
renderFinalNewline = 109,
renderLineHighlight = 110,
renderLineHighlightOnlyWhenFocus = 111,
renderValidationDecorations = 112,
renderWhitespace = 113,
revealHorizontalRightPadding = 114,
roundedSelection = 115,
rulers = 116,
scrollbar = 117,
scrollBeyondLastColumn = 118,
scrollBeyondLastLine = 119,
scrollPredominantAxis = 120,
selectionClipboard = 121,
selectionHighlight = 122,
selectionHighlightMaxLength = 123,
selectionHighlightMultiline = 124,
selectOnLineNumbers = 125,
showFoldingControls = 126,
showUnused = 127,
snippetSuggestions = 128,
smartSelect = 129,
smoothScrolling = 130,
stickyScroll = 131,
stickyTabStops = 132,
stopRenderingLineAfter = 133,
suggest = 134,
suggestFontSize = 135,
suggestLineHeight = 136,
suggestOnTriggerCharacters = 137,
suggestSelection = 138,
tabCompletion = 139,
tabIndex = 140,
trimWhitespaceOnDelete = 141,
unicodeHighlighting = 142,
unusualLineTerminators = 143,
useShadowDOM = 144,
useTabStops = 145,
wordBreak = 146,
wordSegmenterLocales = 147,
wordSeparators = 148,
wordWrap = 149,
wordWrapBreakAfterCharacters = 150,
wordWrapBreakBeforeCharacters = 151,
wordWrapColumn = 152,
wordWrapOverride1 = 153,
wordWrapOverride2 = 154,
wrappingIndent = 155,
wrappingStrategy = 156,
showDeprecated = 157,
inertialScroll = 158,
inlayHints = 159,
wrapOnEscapedLineFeeds = 160,
effectiveCursorStyle = 161,
editorClassName = 162,
pixelRatio = 163,
tabFocusMode = 164,
layoutInfo = 165,
wrappingInfo = 166,
defaultColorDecorators = 167,
colorDecoratorsActivatedOn = 168,
inlineCompletionsAccessibilityVerbose = 169,
effectiveEditContext = 170,
scrollOnMiddleClick = 171,
effectiveAllowVariableFonts = 172
cursorSurroundingLinesHighlightOnSelection = 112,
renderValidationDecorations = 113,
renderWhitespace = 114,
revealHorizontalRightPadding = 115,
roundedSelection = 116,
rulers = 117,
scrollbar = 118,
scrollBeyondLastColumn = 119,
scrollBeyondLastLine = 120,
scrollPredominantAxis = 121,
selectionClipboard = 122,
selectionHighlight = 123,
selectionHighlightMaxLength = 124,
selectionHighlightMultiline = 125,
selectOnLineNumbers = 126,
showFoldingControls = 127,
showUnused = 128,
snippetSuggestions = 129,
smartSelect = 130,
smoothScrolling = 131,
stickyScroll = 132,
stickyTabStops = 133,
stopRenderingLineAfter = 134,
suggest = 135,
suggestFontSize = 136,
suggestLineHeight = 137,
suggestOnTriggerCharacters = 138,
suggestSelection = 139,
tabCompletion = 140,
tabIndex = 141,
trimWhitespaceOnDelete = 142,
unicodeHighlighting = 143,
unusualLineTerminators = 144,
useShadowDOM = 145,
useTabStops = 146,
wordBreak = 147,
wordSegmenterLocales = 148,
wordSeparators = 149,
wordWrap = 150,
wordWrapBreakAfterCharacters = 151,
wordWrapBreakBeforeCharacters = 152,
wordWrapColumn = 153,
wordWrapOverride1 = 154,
wordWrapOverride2 = 155,
wrappingIndent = 156,
wrappingStrategy = 157,
showDeprecated = 158,
inertialScroll = 159,
inlayHints = 160,
wrapOnEscapedLineFeeds = 161,
effectiveCursorStyle = 162,
editorClassName = 163,
pixelRatio = 164,
tabFocusMode = 165,
layoutInfo = 166,
wrappingInfo = 167,
defaultColorDecorators = 168,
colorDecoratorsActivatedOn = 169,
inlineCompletionsAccessibilityVerbose = 170,
effectiveEditContext = 171,
scrollOnMiddleClick = 172,
effectiveAllowVariableFonts = 173
}

export const EditorOptions: {
Expand Down Expand Up @@ -5352,6 +5358,7 @@ declare namespace monaco.editor {
renderFinalNewline: IEditorOption<EditorOption.renderFinalNewline, 'on' | 'off' | 'dimmed'>;
renderLineHighlight: IEditorOption<EditorOption.renderLineHighlight, 'all' | 'line' | 'none' | 'gutter'>;
renderLineHighlightOnlyWhenFocus: IEditorOption<EditorOption.renderLineHighlightOnlyWhenFocus, boolean>;
cursorSurroundingLinesHighlightOnSelection: IEditorOption<EditorOption.cursorSurroundingLinesHighlightOnSelection, boolean>;
renderValidationDecorations: IEditorOption<EditorOption.renderValidationDecorations, 'on' | 'off' | 'editable'>;
renderWhitespace: IEditorOption<EditorOption.renderWhitespace, 'all' | 'none' | 'boundary' | 'selection' | 'trailing'>;
revealHorizontalRightPadding: IEditorOption<EditorOption.revealHorizontalRightPadding, number>;
Expand Down