Browse Source

Ensures terminal cmds are run on proper path

main
Eric Amodio 2 years ago
parent
commit
31875d336c
1 changed files with 5 additions and 17 deletions
  1. +5
    -17
      src/terminal.ts

+ 5
- 17
src/terminal.ts View File

@ -3,41 +3,29 @@ import { window } from 'vscode';
import { Container } from './container';
let _terminal: Terminal | undefined;
let _terminalCwd: string | undefined;
let _disposable: Disposable | undefined;
const extensionTerminalName = 'GitLens';
function ensureTerminal(cwd: string): Terminal {
if (_terminal === undefined) {
function ensureTerminal(): Terminal {
if (_terminal == null) {
_terminal = window.createTerminal(extensionTerminalName);
_disposable = window.onDidCloseTerminal((e: Terminal) => {
if (e.name === extensionTerminalName) {
_terminal = undefined;
_disposable!.dispose();
_disposable?.dispose();
_disposable = undefined;
}
});
Container.instance.context.subscriptions.push(_disposable);
_terminalCwd = undefined;
}
if (_terminalCwd !== cwd) {
_terminal.sendText(`cd "${cwd}"`, true);
_terminalCwd = cwd;
}
return _terminal;
}
export function runGitCommandInTerminal(command: string, args: string, cwd: string, execute: boolean = false) {
// let git = Git.getGitPath();
// if (git.includes(' ')) {
// git = `"${git}"`;
// }
const terminal = ensureTerminal(cwd);
const terminal = ensureTerminal();
terminal.show(false);
terminal.sendText(`git ${command} ${args}`, execute);
terminal.sendText(`git -C ${cwd} ${command} ${args}`, execute);
}

Loading…
Cancel
Save