Skip to content

Commit a65f571

Browse files
committed
Closes #1542: Adds alternate shortcuts to rebase
1 parent af06550 commit a65f571

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1212
- Adds a new section for associated pull requests (when connected to GitHub) and auto-linked issues to the _Details_ hover
1313
- Adds the ability to filter comparisons to show only either the left-side or right-side file differences
1414
- Adds the _Open Folder History_ command to root folders — closes [#1505](https://github.com/eamodio/vscode-gitlens/issues/1505)
15+
- Adds alternate `j`/`k` and `shift+j`/`shift+k` keyboard shortcuts to the Interactive Rebase Editor — closes [#1538](https://github.com/eamodio/vscode-gitlens/issues/1538)
1516
- Adds the ability to show contributor statistics, files changed as well as lines added and deleted (can take a while to compute depending on the repository) — closes [#1489](https://github.com/eamodio/vscode-gitlens/issues/1489)
1617
- Adds a _Show Statistics_ / _Hide Statistics_ toggle to the `...` menu of the _Contributors_ view
1718
- Adds a `gitlens.views.contributors.showStatistics` setting to specify whether to show contributor statistics in the _Contributors_ view

src/webviews/apps/rebase/rebase.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,34 @@ class RebaseEditor extends App<RebaseState> {
174174
document.querySelectorAll<HTMLLIElement>(`li[data-ref="${ref}"]`)[0]?.focus();
175175
}
176176
}
177+
} else if (e.key === 'j' || e.key === 'k') {
178+
if (!e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey) {
179+
if (me.state == null) return;
180+
181+
let ref = (this as HTMLLIElement).dataset.ref;
182+
if (ref == null) return;
183+
184+
e.preventDefault();
185+
186+
let index = me.getEntryIndex(ref) + (e.key === 'k' ? 1 : -1);
187+
if (index < 0) {
188+
index = me.state.entries.length - 1;
189+
} else if (index === me.state.entries.length) {
190+
index = 0;
191+
}
192+
193+
ref = me.state.entries[index].ref;
194+
document.querySelectorAll<HTMLLIElement>(`li[data-ref="${ref}"]`)[0]?.focus();
195+
}
196+
} else if (e.key === 'J' || e.key === 'K') {
197+
if (!e.metaKey && !e.ctrlKey && !e.altKey && e.shiftKey) {
198+
const ref = (this as HTMLLIElement).dataset.ref;
199+
if (ref) {
200+
e.stopPropagation();
201+
202+
me.moveEntry(ref, e.key === 'K' ? 1 : -1, true);
203+
}
204+
}
177205
} else if (!e.metaKey && !e.altKey && !e.ctrlKey) {
178206
const action = rebaseActionsMap.get(e.key);
179207
if (action !== undefined) {

0 commit comments

Comments
 (0)