Conversation
… instead of only executing one command
…`CommandService` and `ShortcutService`
list-related commands to the editor
Contributor
Reviewer's Guide by SourceryThis pull request refactors the editor commands registration to support shortcut options, improves command execution, fixes a typo in Sequence diagram for command execution with shortcutsequenceDiagram
participant KeyboardService
participant ShortcutService
participant ShortcutRegistrant
participant CommandService
participant Command
KeyboardService->>ShortcutService: onKeydown(event)
ShortcutService->>ShortcutRegistrant: findShortcut(pressed)
ShortcutRegistrant-->>ShortcutService: candidates
loop For each candidate
ShortcutService->>ContextService: contextMatchExpr(candidate.when)
alt context matches
ShortcutService->>CommandService: executeCommand(candidate.commandID, ...args)
CommandService->>Command: run(...args)
Command-->>CommandService: return true/false
alt ret === true
CommandService-->>ShortcutService: break
end
end
end
Updated class diagram for EditorCommandExtensionclassDiagram
class EditorCommandExtension {
- _commandSet: Set<string>
- _commandKeybinding: Map<number, string>
+ registerCommand(command: Command): void
+ registerBasicEditorCommands(extension: IEditorCommandExtension, logService: ILogService, getArguments: () => EditorCommandArguments): void
}
class Command {
+ id: string
}
EditorCommandExtension -- Command : uses
note for EditorCommandExtension "Deprecated, FIX"
Updated class diagram for ShortcutRegistrantclassDiagram
class ShortcutRegistrant {
- _shortcuts: Map<number, ShortcutRegistration[]>
+ register2<ID extends string>(commandID: ID, registration: IShortcutRegistration<ID>): void
}
class ShortcutRegistration {
+ commandArgs: any[] | IO<any[]>
+ when: ContextKeyExpression
+ weight: ShortcutWeight
+ shortcut: Shortcut | Shortcut[]
}
ShortcutRegistrant -- ShortcutRegistration : uses
note for ShortcutRegistration "commandArgs can be a function (IO<any[]>)"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey @Bistard - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider renaming
__registerOtherCommandstoregisterBasicCommandsfor clarity and consistency. - The removal of the
shortcutsparameter fromregisterCommandinEditorCommandExtensionrequires careful review to ensure all commands are still accessible via keyboard shortcuts. - The addition of
commandArgs: getArgumentstoshortcutOptionsis a good way to provide context to commands, but ensuregetArgumentsis performant.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Deprecates `EditorCommandExtension`
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Template
Environment Changes
Breaking Changes
Features
Fixes
Checklist
Summary by Sourcery
Refactor the command registration process to improve flexibility and add list manipulation commands. The changes involve using
shortcutOptionsfor command shortcuts and introducing new commands for splitting, sinking, and lifting list items.New Features:
splitListItem,sinkListItem, andliftListItemto enhance list manipulation within the editor.Enhancements:
shortcutOptionsfor defining shortcuts, weights, and conditions, instead of passing shortcuts as separate arguments.