Skip to content

Commit

Permalink
Add delay for exec in terminal (#592)
Browse files Browse the repository at this point in the history
Fixes #174
Fixes #60
Fixes #593
  • Loading branch information
DonJayamanne committed Jan 19, 2018
1 parent aa43646 commit ad806fa
Show file tree
Hide file tree
Showing 55 changed files with 2,264 additions and 562 deletions.
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const hygiene = (options) => {
* @param {any[]} failures
*/
function reportLinterFailures(failures) {
failures
return failures
.map(failure => {
const name = failure.name || failure.fileName;
const position = failure.startPosition;
Expand Down Expand Up @@ -235,7 +235,7 @@ const hygiene = (options) => {
const files = options.mode === 'compile' ? tsProject.src() : getFilesToProcess(options);
const dest = options.mode === 'compile' ? './out' : '.';
let result = files
.pipe(filter(f => !f.stat.isDirectory()));
.pipe(filter(f => f && f.stat && !f.stat.isDirectory()));

if (!options.skipIndentationCheck) {
result = result.pipe(filter(indentationFilter))
Expand All @@ -261,7 +261,7 @@ const hygiene = (options) => {
.js.pipe(gulp.dest(dest))
.pipe(es.through(null, function () {
if (errorCount > 0) {
const errorMessage = `Hygiene failed with ${colors.yellow(errorCount)} errors 👎 . Check 'gulpfile.js'.`;
const errorMessage = `Hygiene failed with errors 👎 . Check 'gulpfile.js'.`;
console.error(colors.red(errorMessage));
exitHandler(options);
} else {
Expand Down
75 changes: 75 additions & 0 deletions src/client/common/application/commandManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable:no-any

import { injectable } from 'inversify';
import { commands, Disposable, TextEditor, TextEditorEdit } from 'vscode';
import { ICommandManager } from './types';

@injectable()
export class CommandManager implements ICommandManager {

/**
* Registers a command that can be invoked via a keyboard shortcut,
* a menu item, an action, or directly.
*
* Registering a command with an existing command identifier twice
* will cause an error.
*
* @param command A unique identifier for the command.
* @param callback A command handler function.
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
public registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable {
return commands.registerCommand(command, callback, thisArg);
}

/**
* Registers a text editor command that can be invoked via a keyboard shortcut,
* a menu item, an action, or directly.
*
* Text editor commands are different from ordinary [commands](#commands.registerCommand) as
* they only execute when there is an active editor when the command is called. Also, the
* command handler of an editor command has access to the active editor and to an
* [edit](#TextEditorEdit)-builder.
*
* @param command A unique identifier for the command.
* @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit).
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
public registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable {
return commands.registerTextEditorCommand(command, callback, thisArg);
}

/**
* Executes the command denoted by the given command identifier.
*
* * *Note 1:* When executing an editor command not all types are allowed to
* be passed as arguments. Allowed are the primitive types `string`, `boolean`,
* `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location).
* * *Note 2:* There are no restrictions when executing commands that have been contributed
* by extensions.
*
* @param command Identifier of the command to execute.
* @param rest Parameters passed to the command function.
* @return A thenable that resolves to the returned value of the given command. `undefined` when
* the command handler function doesn't return anything.
*/
public executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined> {
return commands.executeCommand<T>(command, ...rest);
}

/**
* Retrieve the list of all available commands. Commands starting an underscore are
* treated as internal commands.
*
* @param filterInternal Set `true` to not see internal commands (starting with an underscore)
* @return Thenable that resolves to a list of command ids.
*/
public getCommands(filterInternal?: boolean): Thenable<string[]> {
return commands.getCommands(filterInternal);
}
}
39 changes: 39 additions & 0 deletions src/client/common/application/documentManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// tslint:disable:no-any

import { injectable } from 'inversify';
import { Event, TextDocument, TextDocumentShowOptions, TextEditor, TextEditorOptionsChangeEvent, TextEditorSelectionChangeEvent, TextEditorViewColumnChangeEvent, Uri, ViewColumn, window } from 'vscode';
import { IDocumentManager } from './types';

@injectable()
export class DocumentManager implements IDocumentManager {
public get activeTextEditor(): TextEditor | undefined {
return window.activeTextEditor;
}
public get visibleTextEditors(): TextEditor[] {
return window.visibleTextEditors;
}
public get onDidChangeActiveTextEditor(): Event<TextEditor> {
return window.onDidChangeActiveTextEditor;
}
public get onDidChangeVisibleTextEditors(): Event<TextEditor[]> {
return window.onDidChangeVisibleTextEditors;
}
public get onDidChangeTextEditorSelection(): Event<TextEditorSelectionChangeEvent> {
return window.onDidChangeTextEditorSelection;
}
public get onDidChangeTextEditorOptions(): Event<TextEditorOptionsChangeEvent> {
return window.onDidChangeTextEditorOptions;
}
public get onDidChangeTextEditorViewColumn(): Event<TextEditorViewColumnChangeEvent> {
return window.onDidChangeTextEditorViewColumn;
}
public showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
public showTextDocument(document: TextDocument | Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
public showTextDocument(uri: any, options?: any, preserveFocus?: any): Thenable<TextEditor> {
return window.showTextDocument(uri, options, preserveFocus);
}

}
16 changes: 16 additions & 0 deletions src/client/common/application/terminalManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { injectable } from 'inversify';
import { Event, Terminal, TerminalOptions, window } from 'vscode';
import { ITerminalManager } from './types';

@injectable()
export class TerminalManager implements ITerminalManager {
public get onDidCloseTerminal(): Event<Terminal> {
return window.onDidCloseTerminal;
}
public createTerminal(options: TerminalOptions): Terminal {
return window.createTerminal(options);
}
}
Loading

0 comments on commit ad806fa

Please sign in to comment.