-
Notifications
You must be signed in to change notification settings - Fork 2k
Add swipe gesture recognizer and onDidReceiveSwipeGesture
extension API.
#879
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
base: main
Are you sure you want to change the base?
Conversation
… API. Defaults to disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds swipe gesture recognition functionality to VS Code with an extension API. This implementation allows extensions to respond to left, right, up, and down swipe gestures on macOS trackpads.
- Introduces a new configuration option
workbench.editor.swipeGestureRecognizer
(disabled by default) - Adds
onDidReceiveSwipeGesture
event to the extension API for handling swipe gestures - Implements gesture detection at the Electron window level for macOS
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
workbench.contribution.ts | Adds configuration setting for enabling swipe gesture recognition |
extHostWindow.ts | Adds swipe gesture event emitter and handler in extension host |
extHost.protocol.ts | Defines protocol interface for swipe gesture communication |
extHost.api.impl.ts | Exposes swipe gesture event in the public extension API |
mainThreadWindow.ts | Registers command to bridge swipe gestures from Electron to extension host |
windowImpl.ts | Implements native swipe gesture detection using Electron's swipe events |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
private _onDidReceiveSwipeGesture = new Emitter<'left' | 'right' | 'up' | 'down'>(); | ||
|
||
readonly onDidReceiveSwipeGesture: Event<'left' | 'right' | 'up' | 'down'> = this._onDidReceiveSwipeGesture.event; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The swipe direction type 'left' | 'right' | 'up' | 'down'
is repeated multiple times. Consider defining this as a type alias to improve maintainability and consistency across the codebase.
private _onDidReceiveSwipeGesture = new Emitter<'left' | 'right' | 'up' | 'down'>(); | |
readonly onDidReceiveSwipeGesture: Event<'left' | 'right' | 'up' | 'down'> = this._onDidReceiveSwipeGesture.event; | |
private _onDidReceiveSwipeGesture = new Emitter<SwipeDirection>(); | |
readonly onDidReceiveSwipeGesture: Event<SwipeDirection> = this._onDidReceiveSwipeGesture.event; |
Copilot uses AI. Check for mistakes.
private registerSwipeGesture(): void { | ||
|
||
const configurationKey = 'workbench.editor.swipeGestureRecognizer'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration key string 'workbench.editor.swipeGestureRecognizer'
is duplicated from workbench.contribution.ts. Consider defining this as a constant to avoid potential inconsistencies if the key name changes.
Copilot uses AI. Check for mistakes.
const disposable = this._register( | ||
Event.fromNodeEventEmitter(electronWindow, 'swipe', | ||
(event: Electron.Event, direction: 'left' | 'right' | 'up' | 'down') => ({ event, direction }))((e) => { | ||
this.sendWhenReady('vscode:runAction', CancellationToken.None, { id: '_workbench.triggerSwipeGesture', args: [e.direction] }); | ||
|
||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command ID '_workbench.triggerSwipeGesture'
is duplicated from mainThreadWindow.ts. Consider defining this as a constant to maintain consistency and prevent typos.
Copilot uses AI. Check for mistakes.
Defaults to disabled.
Not necessary if #875 is merged, so this is an alternative solution that would use an extension to handle the actual actions.