From 4722e6d491a29bdb077fc01aa8c5bdc734282c69 Mon Sep 17 00:00:00 2001 From: Aleksei Sidorov Date: Mon, 24 Jun 2019 13:02:20 +0300 Subject: Introduce cargo-watch.check-command --- editors/code/src/commands/cargo_watch.ts | 6 ++++-- editors/code/src/commands/watch_status.ts | 8 +++++--- editors/code/src/config.ts | 13 ++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts index 6ba794bb3..db92e03f4 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts @@ -43,7 +43,7 @@ export class CargoWatchProvider implements vscode.Disposable { this.diagnosticCollection = vscode.languages.createDiagnosticCollection( 'rustc' ); - this.statusDisplay = new StatusDisplay(); + this.statusDisplay = new StatusDisplay(Server.config.cargoWatchOptions.checkCommand); this.outputChannel = vscode.window.createOutputChannel( 'Cargo Watch Trace' ); @@ -57,7 +57,9 @@ export class CargoWatchProvider implements vscode.Disposable { return; } - let args = 'check --all-targets --message-format json'; + let command = Server.config.cargoWatchOptions.checkCommand; + + let args = command + ' --all-targets --message-format json'; if (Server.config.cargoWatchOptions.checkArguments.length > 0) { // Excape the double quote string: args += ' ' + Server.config.cargoWatchOptions.checkArguments; diff --git a/editors/code/src/commands/watch_status.ts b/editors/code/src/commands/watch_status.ts index a3b0178f2..91bc7195b 100644 --- a/editors/code/src/commands/watch_status.ts +++ b/editors/code/src/commands/watch_status.ts @@ -7,13 +7,15 @@ export class StatusDisplay implements vscode.Disposable { private i = 0; private statusBarItem: vscode.StatusBarItem; + private command: string; private timer?: NodeJS.Timeout; - constructor() { + constructor(command: string) { this.statusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Left, 10 ); + this.command = command; this.statusBarItem.hide(); } @@ -24,11 +26,11 @@ export class StatusDisplay implements vscode.Disposable { this.timer || setInterval(() => { if (this.packageName) { - this.statusBarItem!.text = `cargo check [${ + this.statusBarItem!.text = `cargo ${this.command} [${ this.packageName }] ${this.frame()}`; } else { - this.statusBarItem!.text = `cargo check ${this.frame()}`; + this.statusBarItem!.text = `cargo ${this.command} ${this.frame()}`; } }, 300); diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 3024546d2..85366fc34 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import { Server } from './server'; +import { strict } from 'assert'; const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; @@ -10,6 +11,7 @@ export type CargoWatchTraceOptions = 'off' | 'error' | 'verbose'; export interface CargoWatchOptions { enableOnStartup: CargoWatchStartupOptions; checkArguments: string; + checkCommand: string; trace: CargoWatchTraceOptions; } @@ -23,7 +25,8 @@ export class Config { public cargoWatchOptions: CargoWatchOptions = { enableOnStartup: 'ask', trace: 'off', - checkArguments: '' + checkArguments: '', + checkCommand: '' }; private prevEnhancedTyping: null | boolean = null; @@ -110,6 +113,14 @@ export class Config { '' ); } + + if (config.has('cargo-watch.check-command')) { + this.cargoWatchOptions.checkCommand = config.get( + 'cargo-watch.check-command', + '' + ); + } + if (config.has('lruCapacity')) { this.lruCapacity = config.get('lruCapacity') as number; } -- cgit v1.2.3 From b1bc629b83c65c0a3cc0e47a3f55969b9bab950e Mon Sep 17 00:00:00 2001 From: Aleksei Sidorov Date: Mon, 24 Jun 2019 13:33:37 +0300 Subject: Fix tslints --- editors/code/src/commands/cargo_watch.ts | 4 +--- editors/code/src/config.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts index db92e03f4..16aac3758 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts @@ -57,9 +57,7 @@ export class CargoWatchProvider implements vscode.Disposable { return; } - let command = Server.config.cargoWatchOptions.checkCommand; - - let args = command + ' --all-targets --message-format json'; + let args = Server.config.cargoWatchOptions.checkCommand + ' --all-targets --message-format json'; if (Server.config.cargoWatchOptions.checkArguments.length > 0) { // Excape the double quote string: args += ' ' + Server.config.cargoWatchOptions.checkArguments; diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 85366fc34..db46874dc 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode'; -import { Server } from './server'; import { strict } from 'assert'; +import { Server } from './server'; const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; @@ -116,7 +116,7 @@ export class Config { if (config.has('cargo-watch.check-command')) { this.cargoWatchOptions.checkCommand = config.get( - 'cargo-watch.check-command', + 'cargo-watch.check-command', '' ); } -- cgit v1.2.3 From c40ee089f221aa1be74614d7ad875488030e55ff Mon Sep 17 00:00:00 2001 From: Aleksey Sidorov Date: Mon, 24 Jun 2019 13:35:11 +0300 Subject: Apply suggestions from code review Co-Authored-By: Aleksey Kladov --- editors/code/src/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index db46874dc..c1dd2c056 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -10,8 +10,8 @@ export type CargoWatchTraceOptions = 'off' | 'error' | 'verbose'; export interface CargoWatchOptions { enableOnStartup: CargoWatchStartupOptions; - checkArguments: string; - checkCommand: string; + arguments: string; + command: string; trace: CargoWatchTraceOptions; } -- cgit v1.2.3 From 28e9e8d4cfdf2a334cde6db7d10e7acb8f5fe8b1 Mon Sep 17 00:00:00 2001 From: Aleksei Sidorov Date: Mon, 24 Jun 2019 13:50:34 +0300 Subject: Fix code after "apply suggestions" --- editors/code/src/commands/cargo_watch.ts | 12 ++++++++---- editors/code/src/commands/watch_status.ts | 4 +++- editors/code/src/config.ts | 16 ++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts index 16aac3758..13adf4c10 100644 --- a/editors/code/src/commands/cargo_watch.ts +++ b/editors/code/src/commands/cargo_watch.ts @@ -43,7 +43,9 @@ export class CargoWatchProvider implements vscode.Disposable { this.diagnosticCollection = vscode.languages.createDiagnosticCollection( 'rustc' ); - this.statusDisplay = new StatusDisplay(Server.config.cargoWatchOptions.checkCommand); + this.statusDisplay = new StatusDisplay( + Server.config.cargoWatchOptions.command + ); this.outputChannel = vscode.window.createOutputChannel( 'Cargo Watch Trace' ); @@ -57,10 +59,12 @@ export class CargoWatchProvider implements vscode.Disposable { return; } - let args = Server.config.cargoWatchOptions.checkCommand + ' --all-targets --message-format json'; - if (Server.config.cargoWatchOptions.checkArguments.length > 0) { + let args = + Server.config.cargoWatchOptions.command + + ' --all-targets --message-format json'; + if (Server.config.cargoWatchOptions.command.length > 0) { // Excape the double quote string: - args += ' ' + Server.config.cargoWatchOptions.checkArguments; + args += ' ' + Server.config.cargoWatchOptions.arguments; } // Windows handles arguments differently than the unix-likes, so we need to wrap the args in double quotes if (process.platform === 'win32') { diff --git a/editors/code/src/commands/watch_status.ts b/editors/code/src/commands/watch_status.ts index 91bc7195b..6c1f9041b 100644 --- a/editors/code/src/commands/watch_status.ts +++ b/editors/code/src/commands/watch_status.ts @@ -30,7 +30,9 @@ export class StatusDisplay implements vscode.Disposable { this.packageName }] ${this.frame()}`; } else { - this.statusBarItem!.text = `cargo ${this.command} ${this.frame()}`; + this.statusBarItem!.text = `cargo ${ + this.command + } ${this.frame()}`; } }, 300); diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index c1dd2c056..10e98d753 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -25,8 +25,8 @@ export class Config { public cargoWatchOptions: CargoWatchOptions = { enableOnStartup: 'ask', trace: 'off', - checkArguments: '', - checkCommand: '' + arguments: '', + command: '' }; private prevEnhancedTyping: null | boolean = null; @@ -107,16 +107,16 @@ export class Config { ); } - if (config.has('cargo-watch.check-arguments')) { - this.cargoWatchOptions.checkArguments = config.get( - 'cargo-watch.check-arguments', + if (config.has('cargo-watch.arguments')) { + this.cargoWatchOptions.arguments = config.get( + 'cargo-watch.arguments', '' ); } - if (config.has('cargo-watch.check-command')) { - this.cargoWatchOptions.checkCommand = config.get( - 'cargo-watch.check-command', + if (config.has('cargo-watch.command')) { + this.cargoWatchOptions.command = config.get( + 'cargo-watch.command', '' ); } -- cgit v1.2.3