Fix prettier error

This commit is contained in:
Edwin Cheng 2019-03-31 21:21:14 +08:00
parent 6971c7f118
commit c894a3e19b
4 changed files with 31 additions and 22 deletions

View File

@ -2,7 +2,7 @@ import * as child_process from 'child_process';
import * as path from 'path';
import * as timers from 'timers';
import * as vscode from 'vscode';
import {StatusDisplay} from './watch_status';
import { StatusDisplay } from './watch_status';
export class CargoWatchProvider {
private diagnosticCollection?: vscode.DiagnosticCollection;
@ -12,19 +12,22 @@ export class CargoWatchProvider {
public activate(subscriptions: vscode.Disposable[]) {
subscriptions.push(this);
this.diagnosticCollection = vscode.languages.createDiagnosticCollection('rustc');
this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
'rustc'
);
this.statusDisplay = new StatusDisplay(subscriptions);
// Start the cargo watch with json message
this.cargoProcess = child_process.spawn('cargo',
['watch', '-x', '\"check --message-format json\"'],
// Start the cargo watch with json message
this.cargoProcess = child_process.spawn(
'cargo',
['watch', '-x', '"check --message-format json"'],
{
// stdio: ['ignore', 'pipe', 'ignore'],
// stdio: ['ignore', 'pipe', 'ignore'],
shell: true,
cwd: vscode.workspace.rootPath,
});
cwd: vscode.workspace.rootPath
}
);
this.cargoProcess.stdout.on('data', (s: string) => {
this.processOutput(s);
@ -109,7 +112,9 @@ export class CargoWatchProvider {
const fileUrl = vscode.Uri.file(fileName!);
const diagnostics: vscode.Diagnostic[] = [...(this.diagnosticCollection!.get(fileUrl) || [])];
const diagnostics: vscode.Diagnostic[] = [
...(this.diagnosticCollection!.get(fileUrl) || [])
];
diagnostics.push(diagnostic);
this.diagnosticCollection!.set(fileUrl, diagnostics);
@ -129,5 +134,4 @@ export class CargoWatchProvider {
eolIndex = this.outBuffer.indexOf('\n');
}
}
}

View File

@ -134,8 +134,9 @@ export async function handleSingle(runnable: Runnable) {
* provide inline diagnostics; the user is met with a series of dialog boxes
* that, when accepted, allow us to `cargo install cargo-watch` and then run it.
*/
export async function interactivelyStartCargoWatch(context: vscode.ExtensionContext) {
export async function interactivelyStartCargoWatch(
context: vscode.ExtensionContext
) {
if (Server.config.enableCargoWatchOnStartup === 'disabled') {
return;
}
@ -195,7 +196,6 @@ export async function interactivelyStartCargoWatch(context: vscode.ExtensionCont
}
}
const validater = new CargoWatchProvider();
validater.activate(context.subscriptions);
validater.activate(context.subscriptions);
}

View File

@ -9,15 +9,20 @@ export class StatusDisplay {
private timer?: NodeJS.Timeout;
constructor(subscriptions: vscode.Disposable[]) {
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
this.statusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left,
10
);
subscriptions.push(this.statusBarItem);
this.statusBarItem.hide();
}
public show() {
this.timer = this.timer || setInterval(() => {
this.statusBarItem!.text = 'cargo check ' + this.frame();
}, 300);
this.timer =
this.timer ||
setInterval(() => {
this.statusBarItem!.text = 'cargo check ' + this.frame();
}, 300);
this.statusBarItem!.show();
}
@ -32,6 +37,6 @@ export class StatusDisplay {
}
private frame() {
return spinnerFrames[this.i = ++this.i % spinnerFrames.length];
return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
}
}
}

View File

@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient';
import * as commands from './commands';
import { interactivelyStartCargoWatch} from './commands/runnables';
import { interactivelyStartCargoWatch } from './commands/runnables';
import { SyntaxTreeContentProvider } from './commands/syntaxTree';
import * as events from './events';
import * as notifications from './notifications';