diff --git a/appveyor.yml b/appveyor.yml index 59944faefe..7ae3974ee0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: '0.10.1-insiders-{build}' -image: Visual Studio 2017 RC +image: Visual Studio 2017 clone_depth: 10 skip_tags: true @@ -8,6 +8,10 @@ branches: - master - develop +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Don't download unneeded packages + DOTNET_CLI_TELEMETRY_OPTOUT: true # Don't send telemetry + install: - git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices - ps: Install-Product node '6.9.2' diff --git a/package.json b/package.json index 065ff87eaf..196c7f583c 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ }, { "command": "PowerShell.ShowSessionConsole", - "title": "Show Session Interactive Console", + "title": "Show Integrated Console", "category": "PowerShell" }, { @@ -305,6 +305,11 @@ "type": "object", "title": "PowerShell Configuration", "properties": { + "powershell.startAutomatically": { + "type": "boolean", + "default": true, + "description": "If true, causes PowerShell extension features to start automatically when a PowerShell file is opened. If false, the user must initiate startup using the 'PowerShell: Restart Current Session' command. IntelliSense, code navigation, integrated console, code formatting, and other features will not be enabled until the extension has been started." + }, "powershell.useX86Host": { "type": "boolean", "default": false, @@ -393,6 +398,16 @@ "type": "boolean", "default": true, "description": "Ignore blocks of code on one line. For example, if true, the braces in \"if (...) {...} else {...}\", will not be formatted." + }, + "powershell.integratedConsole.showOnStartup": { + "type": "boolean", + "default": true, + "description": "If true, causes the integrated console to be shown automatically when the PowerShell extension is initialized." + }, + "powershell.integratedConsole.focusConsoleOnExecute": { + "type": "boolean", + "default": true, + "description": "If true, causes the integrated console to be focused when a script selection is run or a script file is debugged." } } } diff --git a/src/features/Console.ts b/src/features/Console.ts index b8472b39c6..31f2298901 100644 --- a/src/features/Console.ts +++ b/src/features/Console.ts @@ -217,7 +217,7 @@ export class ConsoleFeature implements IFeature { }); // Show the integrated console if it isn't already visible - vscode.commands.executeCommand("PowerShell.ShowSessionConsole"); + vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true); }) ]; } diff --git a/src/features/DebugSession.ts b/src/features/DebugSession.ts index 25ff001a38..5dd183a254 100644 --- a/src/features/DebugSession.ts +++ b/src/features/DebugSession.ts @@ -63,7 +63,7 @@ export class DebugSessionFeature implements IFeature { // Create or show the interactive console // TODO #367: Check if "newSession" mode is configured - vscode.commands.executeCommand('PowerShell.ShowSessionConsole'); + vscode.commands.executeCommand('PowerShell.ShowSessionConsole', true); vscode.commands.executeCommand('vscode.startDebug', config); } diff --git a/src/logging.ts b/src/logging.ts index fe79c3268a..02806cc4e7 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -49,13 +49,10 @@ export class Logger { public writeAtLevel(logLevel: LogLevel, message: string, ...additionalMessages: string[]) { if (logLevel >= this.MinimumLogLevel) { - // TODO: Add timestamp - this.logChannel.appendLine(message); - fs.appendFile(this.logFilePath, message + os.EOL); + this.writeLine(message) additionalMessages.forEach((line) => { - this.logChannel.appendLine(line); - fs.appendFile(this.logFilePath, line + os.EOL); + this.writeLine(message); }); } } @@ -138,6 +135,14 @@ export class Logger { true); } } + + private writeLine(message: string) { + // TODO: Add timestamp + this.logChannel.appendLine(message); + if (this.logFilePath) { + fs.appendFile(this.logFilePath, message + os.EOL); + } + } } export class LanguageClientLogger implements ILogger { diff --git a/src/main.ts b/src/main.ts index 564dd9c448..46f45cc30d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import vscode = require('vscode'); import utils = require('./utils'); +import Settings = require('./settings'); import { Logger, LogLevel } from './logging'; import { IFeature } from './feature'; import { SessionManager } from './session'; @@ -118,7 +119,10 @@ export function activate(context: vscode.ExtensionContext): void { logger, extensionFeatures); - sessionManager.start(); + var extensionSettings = Settings.load(utils.PowerShellLanguageId); + if (extensionSettings.startAutomatically) { + sessionManager.start(); + } } export function deactivate(): void { diff --git a/src/session.ts b/src/session.ts index f7808914e8..b1be15fc09 100644 --- a/src/session.ts +++ b/src/session.ts @@ -64,6 +64,7 @@ export class SessionManager { private hostVersion: string; private isWindowsOS: boolean; private sessionStatus: SessionStatus; + private focusConsoleOnExecute: boolean; private statusBarItem: vscode.StatusBarItem; private sessionConfiguration: SessionConfiguration; private versionDetails: PowerShellVersionDetails; @@ -99,13 +100,16 @@ export class SessionManager { this.hostVersion = this.hostVersion.split('-')[0]; this.registerCommands(); - this.createStatusBarItem(); } public start(sessionConfig: SessionConfiguration = { type: SessionType.UseDefault }) { this.sessionSettings = Settings.load(utils.PowerShellLanguageId); this.log.startNewLog(this.sessionSettings.developer.editorServicesLogLevel); + this.focusConsoleOnExecute = this.sessionSettings.integratedConsole.focusConsoleOnExecute; + + this.createStatusBarItem(); + this.sessionConfiguration = this.resolveSessionConfiguration(sessionConfig); if (this.sessionConfiguration.type === SessionType.UsePath || @@ -205,6 +209,8 @@ export class SessionManager { private onConfigurationUpdated() { var settings = Settings.load(utils.PowerShellLanguageId); + this.focusConsoleOnExecute = settings.integratedConsole.focusConsoleOnExecute; + // Detect any setting changes that would affect the session if (settings.useX86Host !== this.sessionSettings.useX86Host || settings.developer.powerShellExePath.toLowerCase() !== this.sessionSettings.developer.powerShellExePath.toLowerCase() || @@ -244,7 +250,7 @@ export class SessionManager { vscode.commands.registerCommand('PowerShell.RestartSession', () => { this.restartSession(); }), vscode.commands.registerCommand(this.ShowSessionMenuCommandName, () => { this.showSessionMenu(); }), vscode.workspace.onDidChangeConfiguration(() => this.onConfigurationUpdated()), - vscode.commands.registerCommand('PowerShell.ShowSessionConsole', () => { this.showSessionConsole(); }) + vscode.commands.registerCommand('PowerShell.ShowSessionConsole', (isExecute?: boolean) => { this.showSessionConsole(isExecute); }) ] } @@ -317,7 +323,9 @@ export class SessionManager { powerShellExePath, powerShellArgs); - this.consoleTerminal.show(); + if (this.sessionSettings.integratedConsole.showOnStartup) { + this.consoleTerminal.show(true); + } // Start the language client utils.waitForSessionFile( @@ -490,7 +498,7 @@ export class SessionManager { } private createStatusBarItem() { - if (this.statusBarItem == undefined) { + if (this.statusBarItem === undefined) { // Create the status bar item and place it right next // to the language indicator this.statusBarItem = @@ -626,9 +634,10 @@ export class SessionManager { return resolvedPath; } - private showSessionConsole() { + private showSessionConsole(isExecute?: boolean) { if (this.consoleTerminal) { - this.consoleTerminal.show(true); + this.consoleTerminal.show( + isExecute && !this.focusConsoleOnExecute); } } diff --git a/src/settings.ts b/src/settings.ts index c18e60af22..68501c5317 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -32,11 +32,18 @@ export interface IDeveloperSettings { } export interface ISettings { + startAutomatically?: boolean; useX86Host?: boolean; enableProfileLoading?: boolean; scriptAnalysis?: IScriptAnalysisSettings; developer?: IDeveloperSettings; codeFormatting?: ICodeFormattingSettings; + integratedConsole?: IIntegratedConsoleSettings; +} + +export interface IIntegratedConsoleSettings { + showOnStartup?: boolean; + focusConsoleOnExecute?: boolean; } export function load(myPluginId: string): ISettings { @@ -67,11 +74,18 @@ export function load(myPluginId: string): ISettings { ignoreOneLineBlock: true }; + let defaultIntegratedConsoleSettings: IIntegratedConsoleSettings = { + showOnStartup: true, + focusConsoleOnExecute: true + }; + return { + startAutomatically: configuration.get("startAutomatically", true), useX86Host: configuration.get("useX86Host", false), enableProfileLoading: configuration.get("enableProfileLoading", false), scriptAnalysis: configuration.get("scriptAnalysis", defaultScriptAnalysisSettings), developer: configuration.get("developer", defaultDeveloperSettings), - codeFormatting: configuration.get("codeFormatting", defaultCodeFormattingSettings) + codeFormatting: configuration.get("codeFormatting", defaultCodeFormattingSettings), + integratedConsole: configuration.get("integratedConsole", defaultIntegratedConsoleSettings) }; }