Add global shortcut to paste the 2nd most recent history item - #716
Open
nj-io wants to merge 1 commit into
Open
Conversation
Adds a "Paste 2nd Item" recorder to the Shortcuts preference pane. The hotkey pastes the second entry of the history list directly, without opening the menu. Ordering follows the history menu, so it respects the "reorder clips after pasting" setting. PasteService gains pasteHistoryItem(at:), which is index-based so further positions can be wired up later. Modifier actions (plain text, delete) are skipped on this path because the hotkey's own modifiers are still held when it fires. HotKeyService registration is extracted into a shared helper now that a second non-menu hotkey uses the same shape.
This was referenced Sep 7, 2026
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.
Summary
Adds a global shortcut that pastes the 2nd most recent history item directly, without opening the menu. It appears as a new "Paste 2nd Item" recorder in the Shortcuts preference pane, alongside Clear History. Unset by default, so nothing is registered until a combo is recorded.
Motivation: the common multi-clip workflow is "copy A, copy B, paste B, paste A". Today that needs the History hotkey plus a digit, with numeric key equivalents enabled. This makes it one keystroke. Related discussion in #295, where a commenter noted that most of the time the item they want is the 2nd one.
Behaviour
createdAtorupdateAtdepending on "Reorder clips after pasting".Known limitation
Pressing the shortcut twice within about 500ms pastes the same item twice instead of alternating.
ClipServicepollsNSPasteboard.changeCounton a 500ms timer, so the history order has not been updated yet when the second press reads it. Making the reorder synchronous, or tracking a cursor in memory, would fix it. Both felt out of scope here, and I am happy to follow up if you have a preference on the approach.Implementation
PasteService.pasteHistoryItem(at:)is index-based, so further positions can be added without new plumbing.HotKeyServiceregistration is extracted into a sharedregister(identifier:keyCombo:handler:)helper, now that Clear History and this shortcut have the same shape.AppStorageKeys.pasteSecondHistoryItemKeyCombo, defaulting to nil.paste_second_history_item, logged only when a paste actually happens.HotKeyServiceTestsandAppStorageValuesTests.Localised
.stringsfor the new label are not included, so it falls back to the Base English until translators pick it up.Testing