Skip to content

Commit 1906e40

Browse files
author
Aiday Marlen Kyzy
authored
Merge pull request microsoft#158361 from microsoft/aiday/issue157757
Allowing to toggle the sticky scroll from the view and from the command palette
2 parents 6fa43c8 + a525593 commit 1906e40

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55

66
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
77
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
8-
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
8+
import { registerEditorContribution, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
99
import { IEditorContribution } from 'vs/editor/common/editorCommon';
1010
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
1111
import { EditorOption, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
1212
import { StickyScrollWidget, StickyScrollWidgetState } from './stickyScrollWidget';
1313
import { StickyLineCandidateProvider, StickyRange } from './stickyScrollProvider';
1414
import { IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents';
15+
import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
16+
import { localize } from 'vs/nls';
17+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
18+
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1519

1620
class StickyScrollController extends Disposable implements IEditorContribution {
1721

@@ -139,3 +143,30 @@ class StickyScrollController extends Disposable implements IEditorContribution {
139143

140144
registerEditorContribution(StickyScrollController.ID, StickyScrollController);
141145

146+
registerAction2(class ToggleStickyScroll extends Action2 {
147+
148+
constructor() {
149+
super({
150+
id: 'editor.action.toggleStickyScroll',
151+
title: {
152+
value: localize('toggleStickyScroll', "Toggle Sticky Scroll"),
153+
mnemonicTitle: localize('miStickyScroll', "&&Sticky Scroll"),
154+
original: 'Toggle Sticky Scroll',
155+
},
156+
// Hardcoding due to import violation
157+
category: { value: localize('view', "View"), original: 'View' },
158+
toggled: ContextKeyExpr.equals('config.editor.experimental.stickyScroll.enabled', true),
159+
menu: [
160+
{ id: MenuId.CommandPalette },
161+
{ id: MenuId.MenubarViewMenu, group: '5_editor', order: 6 },
162+
]
163+
});
164+
}
165+
166+
override async run(accessor: ServicesAccessor): Promise<void> {
167+
const configurationService = accessor.get(IConfigurationService);
168+
const newValue = !configurationService.getValue('editor.experimental.stickyScroll.enabled');
169+
return configurationService.updateValue('editor.experimental.stickyScroll.enabled', newValue);
170+
}
171+
});
172+

0 commit comments

Comments
 (0)