Skip to content

Commit 12e91cf

Browse files
committed
Merge pull request PowerShell#47 from mswietlicki/master
PowerShell.RunSelection improvements
2 parents 814aca9 + 020f755 commit 12e91cf

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/features/Console.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,25 @@ export function registerConsoleCommands(client: LanguageClient): void {
2525

2626
vscode.commands.registerCommand('PowerShell.RunSelection', () => {
2727
var editor = vscode.window.activeTextEditor;
28-
29-
client.sendRequest(EvaluateRequest.type, {
28+
var start = editor.selection.start;
29+
var end = editor.selection.end;
30+
if(editor.selection.isEmpty){
31+
start = new vscode.Position(start.line, 0)
32+
}
33+
client.sendRequest(EvaluateRequest.type, {
3034
expression:
3135
editor.document.getText(
32-
new vscode.Range(
33-
editor.selection.anchor,
34-
editor.selection.active))
36+
new vscode.Range(start, end))
3537
});
3638
});
3739

3840
var consoleChannel = vscode.window.createOutputChannel("PowerShell Output");
3941
client.onNotification(OutputNotification.type, (output) => {
40-
consoleChannel.show(vscode.ViewColumn.Three);
42+
var outputEditorExist = vscode.window.visibleTextEditors.some((editor) => {
43+
return editor.document.languageId == 'Log'
44+
});
45+
if(!outputEditorExist)
46+
consoleChannel.show(vscode.ViewColumn.Three);
4147
consoleChannel.append(output.output);
4248
});
43-
}
49+
}

0 commit comments

Comments
 (0)