|
1 | 1 | 'use strict'; |
| 2 | +import { env } from 'vscode'; |
2 | 3 | import { Container } from '../../container'; |
3 | 4 | import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git'; |
4 | 5 | import { |
@@ -71,8 +72,38 @@ export class RebaseGitCommand extends QuickCommand<State> { |
71 | 72 | return false; |
72 | 73 | } |
73 | 74 |
|
74 | | - execute(state: RebaseStepState) { |
75 | | - return state.repo.rebase(...state.flags, state.reference.ref); |
| 75 | + async execute(state: RebaseStepState) { |
| 76 | + let configs: string[] | undefined; |
| 77 | + if (state.flags.includes('--interactive')) { |
| 78 | + await Container.rebaseEditor.enableForNextUse(); |
| 79 | + |
| 80 | + let editor; |
| 81 | + if (env.remoteName) { |
| 82 | + switch (env.appName) { |
| 83 | + case 'Visual Studio Code - Insiders': |
| 84 | + editor = 'code-insiders --wait --reuse-window'; |
| 85 | + break; |
| 86 | + case 'Visual Studio Code - Exploration': |
| 87 | + editor = 'code-exploration --wait --reuse-window'; |
| 88 | + break; |
| 89 | + default: |
| 90 | + editor = 'code --wait --reuse-window'; |
| 91 | + break; |
| 92 | + } |
| 93 | + } else { |
| 94 | + let execPath = process.execPath.replace(/\\/g, '/'); |
| 95 | + if (process.platform === 'darwin') { |
| 96 | + const index = execPath.indexOf('.app/Contents/'); |
| 97 | + if (index !== -1) { |
| 98 | + execPath = `${execPath.substring(0, index)}.app/Contents/MacOS/Electron`; |
| 99 | + } |
| 100 | + } |
| 101 | + editor = `'${execPath}' --wait --reuse-window`; |
| 102 | + } |
| 103 | + |
| 104 | + configs = ['-c', `sequence.editor="${editor}"`]; |
| 105 | + } |
| 106 | + return state.repo.rebase(configs, ...state.flags, state.reference.ref); |
76 | 107 | } |
77 | 108 |
|
78 | 109 | protected async *steps(state: PartialStepState<State>): StepGenerator { |
@@ -189,7 +220,7 @@ export class RebaseGitCommand extends QuickCommand<State> { |
189 | 220 | state.flags = result; |
190 | 221 |
|
191 | 222 | QuickCommand.endSteps(state); |
192 | | - this.execute(state as RebaseStepState); |
| 223 | + void this.execute(state as RebaseStepState); |
193 | 224 | } |
194 | 225 |
|
195 | 226 | return state.counter < 0 ? StepResult.Break : undefined; |
|
0 commit comments