From 4fe03edb939a7f4debc4c9c1b024b332e77af878 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 28 Aug 2022 03:55:09 -0400 Subject: [PATCH] Adds '/' key to rebase editor to open find --- CHANGELOG.md | 2 +- src/constants.ts | 1 + src/webviews/apps/rebase/rebase.html | 1 + src/webviews/apps/rebase/rebase.ts | 10 ++++++++++ src/webviews/rebase/protocol.ts | 4 +--- src/webviews/rebase/rebaseEditor.ts | 5 +++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efb860..dc8bcf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds new stash behaviors to use the Source Control (commit message) input box — closes [#2081](https://github.com/gitkraken/vscode-gitlens/issues/2081) - When a stash is applied or popped and the Source Control input is empty, we will now update the Source Control input to the stash message - When stashing changes and the Source Control input is not empty, we will now default the stash message input to the Source Control input value -- Adds the ability to search (Ctrl+F) for text on the Interactive Rebase Editor — closes [#2050](https://github.com/gitkraken/vscode-gitlens/issues/2050) +- Adds the ability to search (/ or Ctrl+F) for text on the Interactive Rebase Editor — closes [#2050](https://github.com/gitkraken/vscode-gitlens/issues/2050) - Adds stats (additions & deletions) to files nodes in comparisons — closes [#2078](https://github.com/gitkraken/vscode-gitlens/issues/2078) thanks to help via [PR #2079](https://github.com/gitkraken/vscode-gitlens/pull/2079) by Nafiur Rahman Khadem ([@ShafinKhadem](https://github.com/ShafinKhadem)) - Adds the ability to uniquely format uncommitted changes for the current line blame annotations — closes [#1987](https://github.com/gitkraken/vscode-gitlens/issues/1987) - Adds a `gitlens.currentLine.uncommittedChangesFormat` setting to specify the uncommitted changes format of the current line blame annotation. **NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes diff --git a/src/constants.ts b/src/constants.ts index 16a8bf5f..acd5794 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -277,6 +277,7 @@ export const enum CoreCommands { CloseActiveEditor = 'workbench.action.closeActiveEditor', CloseAllEditors = 'workbench.action.closeAllEditors', CursorMove = 'cursorMove', + CustomEditorShowFindWidget = 'editor.action.webvieweditor.showFind', Diff = 'vscode.diff', EditorScroll = 'editorScroll', EditorShowHover = 'editor.action.showHover', diff --git a/src/webviews/apps/rebase/rebase.html b/src/webviews/apps/rebase/rebase.html index 37d6c55..335dfbd 100644 --- a/src/webviews/apps/rebase/rebase.html +++ b/src/webviews/apps/rebase/rebase.html @@ -34,6 +34,7 @@ dDrop alt ↑Move Up alt ↓Move Down + /Search
diff --git a/src/webviews/apps/rebase/rebase.ts b/src/webviews/apps/rebase/rebase.ts index db553b1..d2a70b1 100644 --- a/src/webviews/apps/rebase/rebase.ts +++ b/src/webviews/apps/rebase/rebase.ts @@ -10,6 +10,7 @@ import { DisableCommandType, MoveEntryCommandType, ReorderCommandType, + SearchCommandType, StartCommandType, SwitchCommandType, } from '../../rebase/protocol'; @@ -122,6 +123,11 @@ class RebaseEditor extends App { this.onAbortClicked(); } + } else if (e.key === '/') { + e.preventDefault(); + e.stopPropagation(); + + this.onSearch(); } }), DOM.on('[data-action="start"]', 'click', () => this.onStartClicked()), @@ -268,6 +274,10 @@ class RebaseEditor extends App { this.sendCommand(DisableCommandType, undefined); } + private onSearch() { + this.sendCommand(SearchCommandType, undefined); + } + private onSelectChanged($el: HTMLSelectElement) { const ref = $el.dataset.ref; if (ref) { diff --git a/src/webviews/rebase/protocol.ts b/src/webviews/rebase/protocol.ts index 4e2f4e2..489b965 100644 --- a/src/webviews/rebase/protocol.ts +++ b/src/webviews/rebase/protocol.ts @@ -43,11 +43,9 @@ export interface Commit { // COMMANDS export const AbortCommandType = new IpcCommandType('rebase/abort'); - export const DisableCommandType = new IpcCommandType('rebase/disable'); - +export const SearchCommandType = new IpcCommandType('rebase/search'); export const StartCommandType = new IpcCommandType('rebase/start'); - export const SwitchCommandType = new IpcCommandType('rebase/switch'); export interface ReorderParams { diff --git a/src/webviews/rebase/rebaseEditor.ts b/src/webviews/rebase/rebaseEditor.ts index 51c2cc3..f1fb122 100644 --- a/src/webviews/rebase/rebaseEditor.ts +++ b/src/webviews/rebase/rebaseEditor.ts @@ -23,6 +23,7 @@ import { DisableCommandType, MoveEntryCommandType, ReorderCommandType, + SearchCommandType, StartCommandType, SwitchCommandType, } from './protocol'; @@ -275,6 +276,10 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl onIpc(DisableCommandType, e, () => this.disable(context)); break; + case SearchCommandType.method: + onIpc(SearchCommandType, e, () => executeCoreCommand(CoreCommands.CustomEditorShowFindWidget)); + break; + case StartCommandType.method: onIpc(StartCommandType, e, () => this.rebase(context)); break;