diff --git a/src/commands/clearFileAnnotations.ts b/src/commands/clearFileAnnotations.ts index 3d4b266..6142415 100644 --- a/src/commands/clearFileAnnotations.ts +++ b/src/commands/clearFileAnnotations.ts @@ -1,6 +1,7 @@ 'use strict'; import { TextEditor, TextEditorEdit, Uri, window } from 'vscode'; import { UriComparer } from '../comparers'; +import { isTextEditor } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { Messages } from '../messages'; @@ -12,13 +13,13 @@ export class ClearFileAnnotationsCommand extends EditorCommand { } async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri): Promise { - if (editor == null) return undefined; - // Handle the case where we are focused on a non-editor editor (output, debug console) - if (uri != null && !UriComparer.equals(uri, editor.document.uri)) { - const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri)); - if (e !== undefined) { - editor = e; + if (editor != null && !isTextEditor(editor)) { + if (uri != null && !UriComparer.equals(uri, editor.document.uri)) { + const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri)); + if (e !== undefined) { + editor = e; + } } } diff --git a/src/commands/toggleFileBlame.ts b/src/commands/toggleFileBlame.ts index 1d37615..bdd51aa 100644 --- a/src/commands/toggleFileBlame.ts +++ b/src/commands/toggleFileBlame.ts @@ -2,6 +2,7 @@ import { TextEditor, Uri, window } from 'vscode'; import { UriComparer } from '../comparers'; import { FileAnnotationType } from '../configuration'; +import { isTextEditor } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { ActiveEditorCommand, Commands } from './common'; @@ -17,10 +18,8 @@ export class ToggleFileBlameCommand extends ActiveEditorCommand { } async execute(editor: TextEditor, uri?: Uri, args: ToggleFileBlameCommandArgs = {}): Promise { - // if (editor == null) return undefined; - - if (editor != null) { - // Handle the case where we are focused on a non-editor editor (output, debug console) + // Handle the case where we are focused on a non-editor editor (output, debug console) + if (editor != null && !isTextEditor(editor)) { if (uri != null && !UriComparer.equals(uri, editor.document.uri)) { const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri)); if (e !== undefined) {