提交 4a79412f 编写于 作者: M Matt Bierner

Fix null exception on runSelectedText Terminal Action for Webview

Fixes #16421

Adds a nullcheck before attempting to grab text from the active editor.
上级 4add1695
......@@ -198,15 +198,17 @@ export class RunSelectedTextInTerminalAction extends Action {
terminalInstance = this.terminalService.createInstance();
}
let editor = this.codeEditorService.getFocusedCodeEditor();
let selection = editor.getSelection();
let text: string;
if (selection.isEmpty()) {
text = editor.getValue();
} else {
let endOfLinePreference = os.EOL === '\n' ? EndOfLinePreference.LF : EndOfLinePreference.CRLF;
text = editor.getModel().getValueInRange(selection, endOfLinePreference);
if (editor) {
let selection = editor.getSelection();
let text: string;
if (selection.isEmpty()) {
text = editor.getValue();
} else {
let endOfLinePreference = os.EOL === '\n' ? EndOfLinePreference.LF : EndOfLinePreference.CRLF;
text = editor.getModel().getValueInRange(selection, endOfLinePreference);
}
terminalInstance.sendText(text, true);
}
terminalInstance.sendText(text, true);
return TPromise.as(void 0);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册