From 78dcfe10d8ecf5c1580bd6f37d957ad127bc6d2a Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 6 Apr 2016 17:42:59 +0200 Subject: [PATCH] make sure that the falsy value for the activeTextEditor is `undefined`, #5022 --- extensions/vscode-api-tests/src/window.test.ts | 13 +++++++++---- src/vs/workbench/api/node/extHostEditors.ts | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/vscode-api-tests/src/window.test.ts b/extensions/vscode-api-tests/src/window.test.ts index 13a18b0eece..c52ed3333eb 100644 --- a/extensions/vscode-api-tests/src/window.test.ts +++ b/extensions/vscode-api-tests/src/window.test.ts @@ -6,11 +6,11 @@ 'use strict'; import * as assert from 'assert'; -import {workspace, window, commands, ViewColumn, TextEditor, TextEditorViewColumnChangeEvent, Uri} from 'vscode'; +import {workspace, window, ViewColumn, TextEditorViewColumnChangeEvent, Uri} from 'vscode'; import {join} from 'path'; import {cleanUp, pathEquals} from './utils'; -suite("window namespace tests", () => { +suite('window namespace tests', () => { teardown(cleanUp); @@ -24,6 +24,11 @@ suite("window namespace tests", () => { }); }); + test('editor, UN-active text editor', () => { + assert.equal(window.visibleTextEditors.length, 0); + assert.ok(window.activeTextEditor === undefined); + }); + test('editor, assign and check view columns', () => { return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => { @@ -48,7 +53,7 @@ suite("window namespace tests", () => { provideTextDocumentContent() { return 'mountainbiking,roadcycling'; } - }) + }); return Promise.all([ workspace.openTextDocument(Uri.parse('bikes://testing/one')).then(doc => window.showTextDocument(doc, ViewColumn.One)), @@ -74,7 +79,7 @@ suite("window namespace tests", () => { assert.ok(actualEvent.viewColumn === two.viewColumn); registration1.dispose(); - }) + }); }); }); }); \ No newline at end of file diff --git a/src/vs/workbench/api/node/extHostEditors.ts b/src/vs/workbench/api/node/extHostEditors.ts index ac5b598606d..19a4ede1dc7 100644 --- a/src/vs/workbench/api/node/extHostEditors.ts +++ b/src/vs/workbench/api/node/extHostEditors.ts @@ -77,7 +77,7 @@ export class ExtHostEditors { } getActiveTextEditor(): vscode.TextEditor { - return this._activeEditorId && this._editors[this._activeEditorId]; + return this._editors[this._activeEditorId]; } getVisibleTextEditors(): vscode.TextEditor[] {