Skip to content

Conversation

@gannonh
Copy link

@gannonh gannonh commented Apr 13, 2025

Add keybinding support for Pinit extension

This PR adds keyboard shortcut support to the Pinit extension, allowing users to pin files and folders with a keystroke.

Key Changes:

  • Implemented robust file path detection that works with keyboard shortcuts
  • Added error handling and user feedback when path detection fails
  • Updated command implementation to work seamlessly from both context menu and keyboard
  • Added default keybinding (Ctrl+P Ctrl+I for Windows/Linux, Shift+Cmd+I for Mac)
  • Fixed TypeScript errors related to error handling
  • Added build script for easier development

Details:

The main issue was that the original implementation only worked when triggered from the context menu, as it expected a file to be directly passed to the command. This implementation adds multiple fallback mechanisms to detect the current file:

  1. First checks if triggered from context menu
  2. Then checks if there's an active text editor
  3. Then uses explorer selection API
  4. As a last resort, tries to use the clipboard

This makes the extension much more flexible and user-friendly by enabling keyboard-driven workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant