|
5 | 5 |
|
6 | 6 | import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
7 | 7 | import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
8 |
| -import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; |
| 8 | +import { registerEditorContribution, ServicesAccessor } from 'vs/editor/browser/editorExtensions'; |
9 | 9 | import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
10 | 10 | import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
11 | 11 | import { EditorOption, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
12 | 12 | import { StickyScrollWidget, StickyScrollWidgetState } from './stickyScrollWidget';
|
13 | 13 | import { StickyLineCandidateProvider, StickyRange } from './stickyScrollProvider';
|
14 | 14 | 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'; |
15 | 19 |
|
16 | 20 | class StickyScrollController extends Disposable implements IEditorContribution {
|
17 | 21 |
|
@@ -139,3 +143,30 @@ class StickyScrollController extends Disposable implements IEditorContribution {
|
139 | 143 |
|
140 | 144 | registerEditorContribution(StickyScrollController.ID, StickyScrollController);
|
141 | 145 |
|
| 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