Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making sticky scroll not experimental setting #158728

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/vs/editor/browser/viewParts/lines/viewLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
this._horizontalRevealRequest = null;

// sticky scroll widget
this._stickyScrollEnabled = options.get(EditorOption.experimental).stickyScroll.enabled;
this._maxNumberStickyLines = options.get(EditorOption.experimental).stickyScroll.maxLineCount;
this._stickyScrollEnabled = options.get(EditorOption.stickyScroll).enabled;
this._maxNumberStickyLines = options.get(EditorOption.stickyScroll).maxLineCount;
}

public override dispose(): void {
Expand Down Expand Up @@ -206,8 +206,8 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
this._canUseLayerHinting = !options.get(EditorOption.disableLayerHinting);

// sticky scroll
this._stickyScrollEnabled = options.get(EditorOption.experimental).stickyScroll.enabled;
this._maxNumberStickyLines = options.get(EditorOption.experimental).stickyScroll.maxLineCount;
this._stickyScrollEnabled = options.get(EditorOption.stickyScroll).enabled;
this._maxNumberStickyLines = options.get(EditorOption.stickyScroll).maxLineCount;

applyFontInfo(this.domNode, fontInfo);

Expand Down
65 changes: 30 additions & 35 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ export interface IEditorOptions {
*/
scrollbar?: IEditorScrollbarOptions;
/**
* Control the behavior of experimental options
* Control the behavior of sticky scroll options
*/
experimental?: IEditorExperimentalOptions;
stickyScroll?: IEditorStickyScrollOptions;
/**
* Control the behavior and rendering of the minimap.
*/
Expand Down Expand Up @@ -2512,61 +2512,56 @@ class EditorLightbulb extends BaseEditorOption<EditorOption.lightbulb, IEditorLi

//#endregion

//#region experimental
//#region stickyScroll

export interface IEditorExperimentalOptions {
export interface IEditorStickyScrollOptions {
/**
* Configuration options for editor sticky scroll
* Enable the sticky scroll
*/
stickyScroll?: {
/**
* Enable the sticky scroll
*/
enabled?: boolean;
maxLineCount?: number;
};
}
enabled?: boolean;
/**
* Maximum number of sticky lines to show
*/
maxLineCount?: number;

export interface EditorExperimentalOptions {
stickyScroll: {
enabled: boolean;
maxLineCount: number;
};
}

class EditorExperimental extends BaseEditorOption<EditorOption.experimental, IEditorExperimentalOptions, EditorExperimentalOptions> {
/**
* @internal
*/
export type EditorStickyScrollOptions = Readonly<Required<IEditorStickyScrollOptions>>;

class EditorStickyScroll extends BaseEditorOption<EditorOption.stickyScroll, IEditorStickyScrollOptions, EditorStickyScrollOptions> {

constructor() {
const defaults: EditorExperimentalOptions = { stickyScroll: { enabled: false, maxLineCount: 5 } };
const defaults: EditorStickyScrollOptions = { enabled: false, maxLineCount: 5 };
super(
EditorOption.experimental, 'experimental', defaults,
EditorOption.stickyScroll, 'stickyScroll', defaults,
{
'editor.experimental.stickyScroll.enabled': {
'editor.stickyScroll.enabled': {
type: 'boolean',
default: defaults.stickyScroll.enabled,
description: nls.localize('editor.experimental.stickyScroll', "Shows the nested current scopes during the scroll at the top of the editor.")
default: defaults.enabled,
description: nls.localize('editor.stickyScroll', "Shows the nested current scopes during the scroll at the top of the editor.")
},
'editor.experimental.stickyScroll.maxLineCount': {
'editor.stickyScroll.maxLineCount': {
type: 'number',
default: defaults.stickyScroll.maxLineCount,
default: defaults.maxLineCount,
minimum: 1,
maximum: 10,
description: nls.localize('editor.experimental.stickyScroll.', "Defines the maximum number of sticky lines to show.")
description: nls.localize('editor.stickyScroll.', "Defines the maximum number of sticky lines to show.")
},
}
);
}

public validate(_input: any): EditorExperimentalOptions {
public validate(_input: any): EditorStickyScrollOptions {
if (!_input || typeof _input !== 'object') {
return this.defaultValue;
}
const input = _input as IEditorExperimentalOptions;
const input = _input as IEditorStickyScrollOptions;
return {
stickyScroll: {
enabled: boolean(input.stickyScroll?.enabled, this.defaultValue.stickyScroll.enabled),
maxLineCount: EditorIntOption.clampedInt(input.stickyScroll?.maxLineCount, this.defaultValue.stickyScroll.maxLineCount, 1, 10),
}
enabled: boolean(input.enabled, this.defaultValue.enabled),
maxLineCount: EditorIntOption.clampedInt(input.maxLineCount, this.defaultValue.maxLineCount, 1, 10),
};
}
}
Expand Down Expand Up @@ -4567,7 +4562,6 @@ export const enum EditorOption {
dragAndDrop,
dropIntoEditor,
emptySelectionClipboard,
experimental,
extraEditorClassName,
fastScrollSensitivity,
find,
Expand Down Expand Up @@ -4639,6 +4633,7 @@ export const enum EditorOption {
snippetSuggestions,
smartSelect,
smoothScrolling,
stickyScroll,
stickyTabStops,
stopRenderingLineAfter,
suggest,
Expand Down Expand Up @@ -4876,7 +4871,7 @@ export const EditorOptions = {
)),
emptySelectionClipboard: register(new EditorEmptySelectionClipboard()),
dropIntoEditor: register(new EditorDropIntoEditor()),
experimental: register(new EditorExperimental()),
stickyScroll: register(new EditorStickyScroll()),
extraEditorClassName: register(new EditorStringOption(
EditorOption.extraEditorClassName, 'extraEditorClassName', '',
)),
Expand Down
144 changes: 72 additions & 72 deletions src/vs/editor/common/standalone/standaloneEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,78 +206,78 @@ export enum EditorOption {
dragAndDrop = 31,
dropIntoEditor = 32,
emptySelectionClipboard = 33,
experimental = 34,
extraEditorClassName = 35,
fastScrollSensitivity = 36,
find = 37,
fixedOverflowWidgets = 38,
folding = 39,
foldingStrategy = 40,
foldingHighlight = 41,
foldingImportsByDefault = 42,
foldingMaximumRegions = 43,
unfoldOnClickAfterEndOfLine = 44,
fontFamily = 45,
fontInfo = 46,
fontLigatures = 47,
fontSize = 48,
fontWeight = 49,
formatOnPaste = 50,
formatOnType = 51,
glyphMargin = 52,
gotoLocation = 53,
hideCursorInOverviewRuler = 54,
hover = 55,
inDiffEditor = 56,
inlineSuggest = 57,
letterSpacing = 58,
lightbulb = 59,
lineDecorationsWidth = 60,
lineHeight = 61,
lineNumbers = 62,
lineNumbersMinChars = 63,
linkedEditing = 64,
links = 65,
matchBrackets = 66,
minimap = 67,
mouseStyle = 68,
mouseWheelScrollSensitivity = 69,
mouseWheelZoom = 70,
multiCursorMergeOverlapping = 71,
multiCursorModifier = 72,
multiCursorPaste = 73,
occurrencesHighlight = 74,
overviewRulerBorder = 75,
overviewRulerLanes = 76,
padding = 77,
parameterHints = 78,
peekWidgetDefaultFocus = 79,
definitionLinkOpensInPeek = 80,
quickSuggestions = 81,
quickSuggestionsDelay = 82,
readOnly = 83,
renameOnType = 84,
renderControlCharacters = 85,
renderFinalNewline = 86,
renderLineHighlight = 87,
renderLineHighlightOnlyWhenFocus = 88,
renderValidationDecorations = 89,
renderWhitespace = 90,
revealHorizontalRightPadding = 91,
roundedSelection = 92,
rulers = 93,
scrollbar = 94,
scrollBeyondLastColumn = 95,
scrollBeyondLastLine = 96,
scrollPredominantAxis = 97,
selectionClipboard = 98,
selectionHighlight = 99,
selectOnLineNumbers = 100,
showFoldingControls = 101,
showUnused = 102,
snippetSuggestions = 103,
smartSelect = 104,
smoothScrolling = 105,
extraEditorClassName = 34,
fastScrollSensitivity = 35,
find = 36,
fixedOverflowWidgets = 37,
folding = 38,
foldingStrategy = 39,
foldingHighlight = 40,
foldingImportsByDefault = 41,
foldingMaximumRegions = 42,
unfoldOnClickAfterEndOfLine = 43,
fontFamily = 44,
fontInfo = 45,
fontLigatures = 46,
fontSize = 47,
fontWeight = 48,
formatOnPaste = 49,
formatOnType = 50,
glyphMargin = 51,
gotoLocation = 52,
hideCursorInOverviewRuler = 53,
hover = 54,
inDiffEditor = 55,
inlineSuggest = 56,
letterSpacing = 57,
lightbulb = 58,
lineDecorationsWidth = 59,
lineHeight = 60,
lineNumbers = 61,
lineNumbersMinChars = 62,
linkedEditing = 63,
links = 64,
matchBrackets = 65,
minimap = 66,
mouseStyle = 67,
mouseWheelScrollSensitivity = 68,
mouseWheelZoom = 69,
multiCursorMergeOverlapping = 70,
multiCursorModifier = 71,
multiCursorPaste = 72,
occurrencesHighlight = 73,
overviewRulerBorder = 74,
overviewRulerLanes = 75,
padding = 76,
parameterHints = 77,
peekWidgetDefaultFocus = 78,
definitionLinkOpensInPeek = 79,
quickSuggestions = 80,
quickSuggestionsDelay = 81,
readOnly = 82,
renameOnType = 83,
renderControlCharacters = 84,
renderFinalNewline = 85,
renderLineHighlight = 86,
renderLineHighlightOnlyWhenFocus = 87,
renderValidationDecorations = 88,
renderWhitespace = 89,
revealHorizontalRightPadding = 90,
roundedSelection = 91,
rulers = 92,
scrollbar = 93,
scrollBeyondLastColumn = 94,
scrollBeyondLastLine = 95,
scrollPredominantAxis = 96,
selectionClipboard = 97,
selectionHighlight = 98,
selectOnLineNumbers = 99,
showFoldingControls = 100,
showUnused = 101,
snippetSuggestions = 102,
smartSelect = 103,
smoothScrolling = 104,
stickyScroll = 105,
stickyTabStops = 106,
stopRenderingLineAfter = 107,
suggest = 108,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ToggleStickyScroll extends Action2 {
},
// Hardcoding due to import violation
category: { value: localize('view', "View"), original: 'View' },
toggled: ContextKeyExpr.equals('config.editor.experimental.stickyScroll.enabled', true),
toggled: ContextKeyExpr.equals('config.editor.stickyScroll.enabled', true),
menu: [
{ id: MenuId.CommandPalette },
{ id: MenuId.MenubarViewMenu, group: '5_editor', order: 6 },
Expand All @@ -31,7 +31,7 @@ export class ToggleStickyScroll extends Action2 {

override async run(accessor: ServicesAccessor): Promise<void> {
const configurationService = accessor.get(IConfigurationService);
const newValue = !configurationService.getValue('editor.experimental.stickyScroll.enabled');
return configurationService.updateValue('editor.experimental.stickyScroll.enabled', newValue);
const newValue = !configurationService.getValue('editor.stickyScroll.enabled');
return configurationService.updateValue('editor.stickyScroll.enabled', newValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class StickyScrollController extends Disposable implements IEditorContrib
this._widgetState = new StickyScrollWidgetState([], 0);

this._register(this._editor.onDidChangeConfiguration(e => {
if (e.hasChanged(EditorOption.experimental)) {
if (e.hasChanged(EditorOption.stickyScroll)) {
this.readConfiguration();
}
}));
Expand All @@ -48,8 +48,8 @@ export class StickyScrollController extends Disposable implements IEditorContrib
}

private readConfiguration() {
const options = this._editor.getOption(EditorOption.experimental);
if (options.stickyScroll.enabled === false) {
const options = this._editor.getOption(EditorOption.stickyScroll);
if (options.enabled === false) {
this._editor.removeOverlayWidget(this._stickyScrollWidget);
this._sessionStore.clear();
return;
Expand Down Expand Up @@ -104,7 +104,7 @@ export class StickyScrollController extends Disposable implements IEditorContrib

public getScrollWidgetState(): StickyScrollWidgetState {
const lineHeight: number = this._editor.getOption(EditorOption.lineHeight);
const maxNumberStickyLines = this._editor.getOption(EditorOption.experimental).stickyScroll.maxLineCount;
const maxNumberStickyLines = this._editor.getOption(EditorOption.stickyScroll).maxLineCount;
const scrollTop: number = this._editor.getScrollTop();
let lastLineRelativePosition: number = 0;
const lineNumbers: number[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ export class StickyLineCandidateProvider extends Disposable {
this._languageFeaturesService = languageFeaturesService;
this._updateSoon = this._register(new RunOnceScheduler(() => this.update(), 50));
this._register(this._editor.onDidChangeConfiguration(e => {
if (e.hasChanged(EditorOption.experimental)) {
if (e.hasChanged(EditorOption.stickyScroll)) {
this.readConfiguration();
}
}));
this.readConfiguration();
}

private readConfiguration() {
const options = this._editor.getOption(EditorOption.experimental);
if (options.stickyScroll.enabled === false) {
const options = this._editor.getOption(EditorOption.stickyScroll);
if (options.enabled === false) {
this._sessionStore.clear();
return;
} else {
Expand Down