-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Feat/keybind teacher #285713
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
Open
JohnABardo
wants to merge
9
commits into
microsoft:main
Choose a base branch
from
JohnABardo:feat/keybind-teacher
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/keybind teacher #285713
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
92c6ce4
feat: adding keybind teacher to workbench
JohnABardo 7e59df9
feat: adding features to reset stats and allow popups for commands af…
JohnABardo 0344b9a
removing showDismissOption and fixing user facing strings style
JohnABardo e7d9594
Merge branch 'main' into feat/keybind-teacher
JohnABardo eb1dff5
remove setEnabled
JohnABardo 2945095
removing unused stats fields
JohnABardo 7c9750d
addressing PR comments
JohnABardo 6547623
adjusting getCommandLable implementation
JohnABardo a03150b
Merge branch 'main' into feat/keybind-teacher
JohnABardo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
src/vs/workbench/contrib/keybindingTeacher/browser/keybindingTeacher.contribution.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { Disposable } from '../../../../base/common/lifecycle.js'; | ||
| import { registerSingleton, InstantiationType } from '../../../../platform/instantiation/common/extensions.js'; | ||
| import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js'; | ||
| import { IKeybindingTeacherService } from '../common/keybindingTeacher.js'; | ||
| import { KeybindingTeacherService } from './keybindingTeacherService.js'; | ||
| import { registerAction2, Action2 } from '../../../../platform/actions/common/actions.js'; | ||
| import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js'; | ||
| import { IQuickPickItem, IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js'; | ||
| import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js'; | ||
| import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js'; | ||
| import { localize } from '../../../../nls.js'; | ||
| import '../common/keybindingTeacherConfiguration.js'; | ||
|
|
||
| /** | ||
| * Workbench contribution that ensures the keybinding teacher service is instantiated. | ||
| * Even though the service is registered as InstantiationType.Eager, it still needs | ||
| * to be requested by something to actually instantiate. This contribution serves | ||
| * that purpose by injecting the service in its constructor, causing it to be | ||
| * instantiated during workbench initialization. | ||
| */ | ||
| class KeybindingTeacherContribution extends Disposable implements IWorkbenchContribution { | ||
|
|
||
| static readonly ID = 'workbench.contrib.keybindingTeacher'; | ||
|
|
||
| constructor( | ||
| @IKeybindingTeacherService _keybindingTeacherService: IKeybindingTeacherService | ||
| ) { | ||
| super(); | ||
| } | ||
| } | ||
|
|
||
| registerSingleton(IKeybindingTeacherService, KeybindingTeacherService, InstantiationType.Eager); | ||
|
|
||
| registerWorkbenchContribution2(KeybindingTeacherContribution.ID, KeybindingTeacherContribution, WorkbenchPhase.BlockRestore); | ||
|
|
||
| registerAction2(class ManageDismissedCommandsAction extends Action2 { | ||
| constructor() { | ||
| super({ | ||
| id: 'keybindingTeacher.manageDismissedCommands', | ||
| title: { value: localize('manageDismissedCommands', "Manage Dismissed Suggestions"), original: 'Manage Dismissed Suggestions' }, | ||
| category: { value: localize('manageDismissedCommandsCategory', "Keybinding Teacher"), original: 'Keybinding Teacher' }, | ||
| f1: true | ||
| }); | ||
| } | ||
|
|
||
| async run(accessor: ServicesAccessor): Promise<void> { | ||
| const keybindingTeacherService = accessor.get(IKeybindingTeacherService); | ||
| const quickInputService = accessor.get(IQuickInputService); | ||
| const keybindingService = accessor.get(IKeybindingService); | ||
|
|
||
| const dismissedCommands = keybindingTeacherService.getDismissedCommands(); | ||
|
|
||
| if (dismissedCommands.length === 0) { | ||
| await quickInputService.pick([{ | ||
| label: localize('noDismissedCommands', "No dismissed commands"), | ||
| description: localize('noDismissedCommandsDesc', "You have not dismissed any keybinding suggestions") | ||
| }], { | ||
| placeHolder: localize('dismissedCommandsPlaceholder', "Dismissed Commands") | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| const picks: (IQuickPickItem & { commandId: string })[] = dismissedCommands.map(commandId => { | ||
| const keybinding = keybindingService.lookupKeybinding(commandId); | ||
| const keybindingLabel = keybinding?.getLabel() || localize('noKeybinding', "No keybinding"); | ||
|
|
||
| return { | ||
| label: commandId, | ||
| description: keybindingLabel, | ||
| commandId | ||
| }; | ||
| }); | ||
|
|
||
| const selected = await quickInputService.pick(picks, { | ||
| placeHolder: localize('selectCommandToReEnable', "Select a command to re-enable suggestions"), | ||
| canPickMany: true | ||
| }); | ||
|
|
||
| if (selected && selected.length > 0) { | ||
| for (const item of selected) { | ||
| keybindingTeacherService.undismissCommand(item.commandId); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| registerAction2(class ClearAllDataAction extends Action2 { | ||
| constructor() { | ||
| super({ | ||
| id: 'keybindingTeacher.clearAllData', | ||
| title: { value: localize('clearAllData', "Clear All Data"), original: 'Clear All Data' }, | ||
| category: { value: localize('clearAllDataCategory', "Keybinding Teacher"), original: 'Keybinding Teacher' }, | ||
| f1: true | ||
| }); | ||
| } | ||
|
|
||
| async run(accessor: ServicesAccessor): Promise<void> { | ||
| const keybindingTeacherService = accessor.get(IKeybindingTeacherService); | ||
| const dialogService = accessor.get(IDialogService); | ||
|
|
||
| const { confirmed } = await dialogService.confirm({ | ||
| message: localize('confirmClearMessage', "Clear all keybinding teacher data?"), | ||
| detail: localize('confirmClearDetail', "This will clear all dismissed commands and usage counts."), | ||
| primaryButton: localize('clearButton', "Clear") | ||
| }); | ||
|
|
||
| if (confirmed) { | ||
| keybindingTeacherService.resetAllStats(); | ||
| } | ||
| } | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.