未验证 提交 9c77fb32 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #69049 from Microsoft/tyriar/terminalPanel_snc

Fix strict null checks in terminalPanel
......@@ -283,6 +283,7 @@
"./vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalPanel.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalProcessManager.ts",
"./vs/workbench/contrib/terminal/node/terminal.ts",
"./vs/workbench/contrib/terminal/node/terminalCommandTracker.ts",
......
......@@ -26,7 +26,7 @@ const NLS_CLOSE_BTN_LABEL = nls.localize('label.closeButton', "Close");
export abstract class SimpleFindWidget extends Widget {
private _findInput: FindInput;
private _domNode?: HTMLElement;
private _domNode: HTMLElement;
private _innerDomNode: HTMLElement;
private _isVisible: boolean = false;
private _focusTracker: dom.IFocusTracker;
......@@ -182,7 +182,6 @@ export abstract class SimpleFindWidget extends Widget {
if (this._domNode && this._domNode.parentElement) {
this._domNode.parentElement.removeChild(this._domNode);
this._domNode = undefined;
}
}
......
......@@ -165,7 +165,7 @@ export class TerminalPanel extends Panel {
return this._contextMenuActions;
}
public getActionItem(action: Action): IActionItem {
public getActionItem(action: Action): IActionItem | null {
if (action.id === SwitchTerminalAction.ID) {
return this._instantiationService.createInstance(SwitchTerminalActionItem, action);
}
......@@ -182,7 +182,7 @@ export class TerminalPanel extends Panel {
public focusFindWidget() {
const activeInstance = this._terminalService.getActiveInstance();
if (activeInstance && activeInstance.hasSelection() && (activeInstance.selection.indexOf('\n') === -1)) {
if (activeInstance && activeInstance.hasSelection() && activeInstance.selection!.indexOf('\n') === -1) {
this._findWidget.reveal(activeInstance.selection);
} else {
this._findWidget.reveal();
......@@ -195,7 +195,7 @@ export class TerminalPanel extends Panel {
public showFindWidget() {
const activeInstance = this._terminalService.getActiveInstance();
if (activeInstance && activeInstance.hasSelection() && (activeInstance.selection.indexOf('\n') === -1)) {
if (activeInstance && activeInstance.hasSelection() && activeInstance.selection!.indexOf('\n') === -1) {
this._findWidget.show(activeInstance.selection);
} else {
this._findWidget.show();
......@@ -215,10 +215,16 @@ export class TerminalPanel extends Panel {
if (event.which === 2 && platform.isLinux) {
// Drop selection and focus terminal on Linux to enable middle button paste when click
// occurs on the selection itself.
this._terminalService.getActiveInstance().focus();
const terminal = this._terminalService.getActiveInstance();
if (terminal) {
terminal.focus();
}
} else if (event.which === 3) {
if (this._terminalService.configHelper.config.rightClickBehavior === 'copyPaste') {
const terminal = this._terminalService.getActiveInstance();
if (!terminal) {
return;
}
if (terminal.hasSelection()) {
terminal.copySelection();
terminal.clearSelection();
......@@ -246,7 +252,7 @@ export class TerminalPanel extends Panel {
if (event.which === 1) {
const terminal = this._terminalService.getActiveInstance();
if (terminal.hasSelection()) {
if (terminal && terminal.hasSelection()) {
terminal.copySelection();
}
}
......@@ -299,7 +305,9 @@ export class TerminalPanel extends Panel {
}
const terminal = this._terminalService.getActiveInstance();
terminal.sendText(terminalEnvironment.preparePathForTerminal(path), false);
if (terminal) {
terminal.sendText(terminalEnvironment.preparePathForTerminal(path), false);
}
}
}));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册