Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
found a way to get the scm path, thanks to @joaomoreno
LastActive terminal option disabled, since `onDidChangeActiveTerminal` is still in "proposed api" status (also fix where that call should be) - now the default option is `AlwaysCreate`
fixed configuration searching for `cd` instead of `cd-repo`
showing an error message if user chooses an unknown terminal option
removed some useless comments
  • Loading branch information
Logerfo committed Sep 13, 2018
1 parent ec4ad62 commit 2be61ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
"enum": [
"AlwaysCreate",
"First",
"Last",
"LastActive"
"Last"
],
"default": "LastActive",
"default": "AlwaysCreate",
"description": "Choose which terminal will be used to execute the cd command."
}
}
Expand Down
23 changes: 10 additions & 13 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
//proposed API
//(<any>vscode.window).onDidChangeActiveTerminal(e => lastActiveTerminal = e);
context.subscriptions.push(vscode.commands.registerCommand('extension.cd', cd));
}

var lastActiveTerminal: vscode.Terminal;
//var lastActiveTerminal: vscode.Terminal;
async function cd(args) {
//https://github.com/Microsoft/vscode-extension-samples/blob/master/terminal-sample/src/extension.ts
//(<any>vscode.window).onDidChangeActiveTerminal(e => lastActiveTerminal = e);
const configuration: string = vscode.workspace.getConfiguration("cd", args._fsPath).get('terminal', "LastActive");
const configuration: string = vscode.workspace.getConfiguration("cd-repo", args._fsPath).get('terminal', "AlwaysCreate");
let terminal: vscode.Terminal;
switch (configuration) {
case "AlwaysCreate":
Expand All @@ -27,14 +23,15 @@ async function cd(args) {
terminal = vscode.window.terminals.length > 0 ? vscode.window.terminals[vscode.window.terminals.length - 1] : vscode.window.createTerminal();
break;

case "LastActive":
terminal = lastActiveTerminal ? lastActiveTerminal : vscode.window.createTerminal();
break;
//case "LastActive":
// terminal = lastActiveTerminal ? lastActiveTerminal : vscode.window.createTerminal();
// break;

default: vscode.window.showErrorMessage(`${configuration} is not a valid terminal option.`);
}
terminal.show();
terminal.sendText("cd ");
terminal.sendText("cd \"" + (<any>args).rootUri.fsPath + "\"");

This comment has been minimized.

Copy link
@joaomoreno

joaomoreno Sep 13, 2018

👍

}

// this method is called when your extension is deactivated
export function deactivate() {
}

0 comments on commit 2be61ff

Please sign in to comment.