Browse Source

Closes #2134 uses VS Code as git core.editor

main
Nafiur Rahman Khadem 2 years ago
committed by Eric Amodio
parent
commit
8ca8befd66
4 changed files with 27 additions and 20 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +3
    -18
      src/commands/git/rebase.ts
  3. +20
    -1
      src/system/utils.ts
  4. +3
    -1
      src/terminal.ts

+ 1
- 0
CHANGELOG.md View File

@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Changes the _Home_ view to always be available
- Changes SHA terminal links to use the _Commit Details_ view — closes [#2320](https://github.com/gitkraken/vscode-gitlens/issues/2320)
- Adds a `gitlens.terminalLinks.showDetailsView` setting to specify whether to show the _Commit Details_ view when clicking on a commit link
- Changes to uses VS Code as Git's `core.editor` for terminal run commands — closes [#2134](https://github.com/gitkraken/vscode-gitlens/pull/2134) thanks to [PR #2135](https://github.com/gitkraken/vscode-gitlens/pull/2135) by Nafiur Rahman Khadem ([@ShafinKhadem](https://github.com/ShafinKhadem))
### Fixed

+ 3
- 18
src/commands/git/rebase.ts View File

@ -1,4 +1,3 @@
import { env } from 'vscode';
import type { Container } from '../../container';
import type { GitBranch } from '../../git/models/branch';
import type { GitLog } from '../../git/models/log';
@ -7,6 +6,7 @@ import type { Repository } from '../../git/models/repository';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import { getEditorCommand } from '../../system/utils';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
AsyncStepResultGenerator,
@ -85,23 +85,8 @@ export class RebaseGitCommand extends QuickCommand {
if (state.flags.includes('--interactive')) {
await this.container.rebaseEditor.enableForNextUse();
let editor;
switch (env.appName) {
case 'Visual Studio Code - Insiders':
editor = 'code-insiders --wait --reuse-window';
break;
case 'Visual Studio Code - Exploration':
editor = 'code-exploration --wait --reuse-window';
break;
case 'VSCodium':
editor = 'codium --wait --reuse-window';
break;
default:
editor = 'code --wait --reuse-window';
break;
}
configs = ['-c', `"sequence.editor=${editor}"`, '-c', `"core.editor=${editor}"`];
const editor = getEditorCommand();
configs = ['-c', `"sequence.editor=${editor}"`];
}
return state.repo.rebase(configs, ...state.flags, state.reference.ref);
}

+ 20
- 1
src/system/utils.ts View File

@ -1,5 +1,5 @@
import type { ColorTheme, TextDocument, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { ColorThemeKind, ViewColumn, window, workspace } from 'vscode';
import { ColorThemeKind, env, ViewColumn, window, workspace } from 'vscode';
import { configuration } from '../configuration';
import { CoreCommands, ImageMimetypes, Schemes } from '../constants';
import { isGitUri } from '../git/gitUri';
@ -179,3 +179,22 @@ export function openWorkspace(
forceNewWindow: options?.location === OpenWorkspaceLocation.NewWindow,
});
}
export function getEditorCommand() {
let editor;
switch (env.appName) {
case 'Visual Studio Code - Insiders':
editor = 'code-insiders --wait --reuse-window';
break;
case 'Visual Studio Code - Exploration':
editor = 'code-exploration --wait --reuse-window';
break;
case 'VSCodium':
editor = 'codium --wait --reuse-window';
break;
default:
editor = 'code --wait --reuse-window';
break;
}
return editor;
}

+ 3
- 1
src/terminal.ts View File

@ -1,6 +1,7 @@
import type { Disposable, Terminal } from 'vscode';
import { window } from 'vscode';
import { Container } from './container';
import { getEditorCommand } from './system/utils';
let _terminal: Terminal | undefined;
let _disposable: Disposable | undefined;
@ -27,5 +28,6 @@ function ensureTerminal(): Terminal {
export function runGitCommandInTerminal(command: string, args: string, cwd: string, execute: boolean = false) {
const terminal = ensureTerminal();
terminal.show(false);
terminal.sendText(`git -C ${cwd.includes(' ') ? `"${cwd}"` : cwd} ${command} ${args}`, execute);
const editor = getEditorCommand();
terminal.sendText(`git -C "${cwd}" -c "core.editor=${editor}" ${command} ${args}`, execute);
}

Loading…
Cancel
Save