Skip to content

Commit 913c060

Browse files
committed
Refines rebase editor
Adds button to rebase editor to toggle it on/off Adds commands to toggle rebase editor on/off Adds settings UI to toggle rebase editor on/off
1 parent 6f05dcb commit 913c060

File tree

19 files changed

+407
-36
lines changed

19 files changed

+407
-36
lines changed

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
"onCommand:gitlens.diffWithWorkingInDiffLeft",
105105
"onCommand:gitlens.diffWithWorkingInDiffRight",
106106
"onCommand:gitlens.diffLineWithWorking",
107+
"onCommand:gitlens.disableRebaseEditor",
108+
"onCommand:gitlens.enableRebaseEditor",
107109
"onCommand:gitlens.toggleFileBlame",
108110
"onCommand:gitlens.toggleFileBlameInDiffLeft",
109111
"onCommand:gitlens.toggleFileBlameInDiffRight",
@@ -2758,6 +2760,16 @@
27582760
"title": "Open Line Changes with Working File",
27592761
"category": "GitLens"
27602762
},
2763+
{
2764+
"command": "gitlens.disableRebaseEditor",
2765+
"title": "Disable Interactive Rebase Editor",
2766+
"category": "GitLens"
2767+
},
2768+
{
2769+
"command": "gitlens.enableRebaseEditor",
2770+
"title": "Enable Interactive Rebase Editor",
2771+
"category": "GitLens"
2772+
},
27612773
{
27622774
"command": "gitlens.toggleFileBlame",
27632775
"title": "Toggle File Blame",
@@ -4526,6 +4538,14 @@
45264538
"command": "gitlens.diffLineWithWorking",
45274539
"when": "gitlens:activeFileStatus =~ /blameable/"
45284540
},
4541+
{
4542+
"command": "gitlens.disableRebaseEditor",
4543+
"when": "gitlens:enabled"
4544+
},
4545+
{
4546+
"command": "gitlens.enableRebaseEditor",
4547+
"when": "gitlens:enabled"
4548+
},
45294549
{
45304550
"command": "gitlens.externalDiff",
45314551
"when": "gitlens:activeFileStatus =~ /tracked/"
@@ -7919,7 +7939,7 @@
79197939
"customEditors": [
79207940
{
79217941
"viewType": "gitlens.rebase",
7922-
"displayName": "Interactive Rebase Editor",
7942+
"displayName": "GitLens Interactive Rebase Editor",
79237943
"selector": [
79247944
{
79257945
"filenamePattern": "git-rebase-todo"

src/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export * from './commands/openPullRequestOnRemote';
3434
export * from './commands/openRepoOnRemote';
3535
export * from './commands/openRevisionFile';
3636
export * from './commands/openWorkingFile';
37+
export * from './commands/rebaseEditor';
3738
export * from './commands/refreshHover';
3839
export * from './commands/remoteProviders';
3940
export * from './commands/repositories';

src/commands/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export enum Commands {
6363
DiffWithWorkingInDiffRight = 'gitlens.diffWithWorkingInDiffRight',
6464
DiffLineWithWorking = 'gitlens.diffLineWithWorking',
6565
DisconnectRemoteProvider = 'gitlens.disconnectRemoteProvider',
66+
DisableRebaseEditor = 'gitlens.disableRebaseEditor',
67+
EnableRebaseEditor = 'gitlens.enableRebaseEditor',
6668
ExternalDiff = 'gitlens.externalDiff',
6769
ExternalDiffAll = 'gitlens.externalDiffAll',
6870
FetchRepositories = 'gitlens.fetchRepositories',

src/commands/rebaseEditor.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
import { command, Command, Commands } from './common';
3+
import { Container } from '../container';
4+
5+
@command()
6+
export class DisableRebaseEditorCommand extends Command {
7+
constructor() {
8+
super(Commands.DisableRebaseEditor);
9+
}
10+
11+
execute() {
12+
return Container.rebaseEditor.setEnabled(false);
13+
}
14+
}
15+
16+
@command()
17+
export class EnableRebaseEditorCommand extends Command {
18+
constructor() {
19+
super(Commands.EnableRebaseEditor);
20+
}
21+
22+
execute() {
23+
return Container.rebaseEditor.setEnabled(true);
24+
}
25+
}

src/configuration.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ export class Configuration {
137137
.get<T>(section === undefined ? extensionId : section, defaultValue)!;
138138
}
139139

140+
getAny<T>(section: string, scope?: ConfigurationScope | null): T | undefined;
141+
getAny<T>(section: string, scope: ConfigurationScope | null | undefined, defaultValue: T): T;
140142
getAny<T>(section: string, scope?: ConfigurationScope | null, defaultValue?: T) {
141143
return defaultValue === undefined
142-
? workspace.getConfiguration(undefined, scope).get<T>(section)!
143-
: workspace.getConfiguration(undefined, scope).get<T>(section, defaultValue)!;
144+
? workspace.getConfiguration(undefined, scope).get<T>(section)
145+
: workspace.getConfiguration(undefined, scope).get<T>(section, defaultValue);
144146
}
145147

146148
changed<S1 extends keyof Config>(e: ConfigurationChangeEvent, s1: S1, scope?: ConfigurationScope | null): boolean;
@@ -242,8 +244,8 @@ export class Configuration {
242244
.inspect(section === undefined ? extensionId : section);
243245
}
244246

245-
inspectAny(section: string, scope?: ConfigurationScope | null) {
246-
return workspace.getConfiguration(undefined, scope).inspect(section);
247+
inspectAny<T>(section: string, scope?: ConfigurationScope | null) {
248+
return workspace.getConfiguration(undefined, scope).inspect<T>(section);
247249
}
248250

249251
migrate<S1 extends keyof Config>(

src/container.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class Container {
9191
});
9292
}
9393

94-
context.subscriptions.push(new RebaseEditorProvider());
94+
context.subscriptions.push((this._rebaseEditor = new RebaseEditorProvider()));
9595
context.subscriptions.push(new GitTerminalLinkProvider());
9696
context.subscriptions.push(new GitFileSystemProvider());
9797

@@ -237,6 +237,15 @@ export class Container {
237237
return this._lineTracker;
238238
}
239239

240+
private static _rebaseEditor: RebaseEditorProvider | undefined;
241+
static get rebaseEditor() {
242+
if (this._rebaseEditor === undefined) {
243+
this._context.subscriptions.push((this._rebaseEditor = new RebaseEditorProvider()));
244+
}
245+
246+
return this._rebaseEditor;
247+
}
248+
240249
private static _remotesView: RemotesView | undefined;
241250
static get remotesView() {
242251
if (this._remotesView === undefined) {
44.9 KB
Loading

src/webviews/apps/rebase/rebase.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ <h4 id="subhead"></h4>
2727
<span class="shortcut"><kbd>alt ↓</kbd><span>Move Down</span></span>
2828
</div>
2929
<div class="actions">
30-
<button name="start" class="button button--flat-primary" data-action="start">
30+
<button name="disable" class="button button--flat-subtle" data-action="disable" tabindex="-1">
31+
Disable Rebase Editor<span class="shortcut">Will Abort Rebase</span>
32+
</button>
33+
<button name="start" class="button button--flat-primary button--right" data-action="start">
3134
Start Rebase <span class="shortcut">Ctrl+Enter</span>
3235
</button>
33-
<button name="abort" class="button button--flat" data-action="abort">
36+
<button name="abort" class="button button--flat-secondary" data-action="abort">
3437
Abort <span class="shortcut">Ctrl+A</span>
3538
</button>
3639
</div>

src/webviews/apps/rebase/rebase.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
RebaseDidAbortCommandType,
88
RebaseDidChangeEntryCommandType,
99
RebaseDidChangeNotificationType,
10+
RebaseDidDisableCommandType,
1011
RebaseDidMoveEntryCommandType,
1112
RebaseDidStartCommandType,
1213
RebaseEntry,
@@ -124,6 +125,7 @@ class RebaseEditor extends App<RebaseState> {
124125
}),
125126
DOM.on('[data-action="start"]', 'click', () => this.onStartClicked()),
126127
DOM.on('[data-action="abort"]', 'click', () => this.onAbortClicked()),
128+
DOM.on('[data-action="disable"]', 'click', () => this.onDisableClicked()),
127129
DOM.on('li[data-ref]', 'keydown', function (this: Element, e: KeyboardEvent) {
128130
if ((e.target as HTMLElement).matches('select[data-ref]')) {
129131
if (e.key === 'Escape') {
@@ -134,6 +136,10 @@ class RebaseEditor extends App<RebaseState> {
134136
}
135137

136138
if (e.key === 'Enter' || e.key === ' ') {
139+
if (e.key === 'Enter' && (e.target as HTMLElement).matches('a.entry-ref')) {
140+
return;
141+
}
142+
137143
const $select = (this as HTMLLIElement).querySelectorAll<HTMLSelectElement>('select[data-ref]')[0];
138144
if ($select != null) {
139145
$select.focus();
@@ -224,6 +230,10 @@ class RebaseEditor extends App<RebaseState> {
224230
this.sendCommand(RebaseDidAbortCommandType, {});
225231
}
226232

233+
private onDisableClicked() {
234+
this.sendCommand(RebaseDidDisableCommandType, {});
235+
}
236+
227237
private onSelectChanged($el: HTMLSelectElement) {
228238
const ref = $el.dataset.ref;
229239
if (ref) {
@@ -367,6 +377,8 @@ class RebaseEditor extends App<RebaseState> {
367377
$select.appendChild(option);
368378
}
369379
$selectContainer.appendChild($select);
380+
} else {
381+
$entry.tabIndex = -1;
370382
}
371383

372384
const $message = document.createElement('span');

src/webviews/apps/scss/buttons.scss

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,64 @@
116116
transition-duration: 0s !important;
117117
}
118118
}
119+
120+
.button--flat-secondary {
121+
background-color: var(--color-button-secondary-background);
122+
border: 1px solid var(--color-button-secondary-background);
123+
color: var(--color-button-foreground);
124+
font-weight: 600;
125+
transition: background-color 250ms, border-color 250ms, color 250ms;
126+
127+
&:not([disabled]):hover,
128+
&:not([disabled]):focus {
129+
.vscode-dark & {
130+
background-color: white;
131+
border-color: white;
132+
color: black;
133+
}
134+
135+
.vscode-light & {
136+
background-color: var(--color-button-secondary-background--darken-30);
137+
border-color: var(--color-button-secondary-background--darken-30);
138+
color: white;
139+
}
140+
}
141+
142+
.preload & {
143+
transition-duration: 0s !important;
144+
}
145+
}
146+
147+
.button--flat-subtle {
148+
.vscode-light & {
149+
border: 1px solid rgba(0, 0, 0, 0.2);
150+
color: rgba(0, 0, 0, 0.6);
151+
}
152+
.vscode-dark & {
153+
border: 1px solid rgba(255, 255, 255, 0.2);
154+
color: rgba(255, 255, 255, 0.6);
155+
}
156+
transition: background-color 250ms, border-color 250ms, color 250ms;
157+
158+
&:not([disabled]):hover,
159+
&:not([disabled]):focus {
160+
.vscode-light & {
161+
background-color: var(--color-button-secondary-background--darken-30);
162+
border-color: var(--color-button-secondary-background--darken-30);
163+
color: white;
164+
}
165+
.vscode-dark & {
166+
background-color: white;
167+
border-color: white;
168+
color: black;
169+
}
170+
}
171+
172+
.preload & {
173+
transition-duration: 0s !important;
174+
}
175+
}
176+
177+
.button--right {
178+
margin-left: auto;
179+
}

0 commit comments

Comments
 (0)