mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Add proper process teminate method
This commit is contained in:
parent
c894a3e19b
commit
b84d0fc1a3
6 changed files with 116 additions and 10 deletions
|
@ -1,9 +1,10 @@
|
|||
import * as child_process from 'child_process';
|
||||
import * as path from 'path';
|
||||
import * as timers from 'timers';
|
||||
import * as vscode from 'vscode';
|
||||
import { terminate } from '../utils/processes';
|
||||
import { StatusDisplay } from './watch_status';
|
||||
|
||||
|
||||
export class CargoWatchProvider {
|
||||
private diagnosticCollection?: vscode.DiagnosticCollection;
|
||||
private cargoProcess?: child_process.ChildProcess;
|
||||
|
@ -21,24 +22,25 @@ export class CargoWatchProvider {
|
|||
// Start the cargo watch with json message
|
||||
this.cargoProcess = child_process.spawn(
|
||||
'cargo',
|
||||
['watch', '-x', '"check --message-format json"'],
|
||||
['watch', '-x', '\"check --message-format json\"'],
|
||||
{
|
||||
// stdio: ['ignore', 'pipe', 'ignore'],
|
||||
shell: true,
|
||||
cwd: vscode.workspace.rootPath
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
cwd: vscode.workspace.rootPath,
|
||||
windowsVerbatimArguments: true,
|
||||
}
|
||||
);
|
||||
|
||||
this.cargoProcess.stdout.on('data', (s: string) => {
|
||||
this.processOutput(s);
|
||||
console.log(s);
|
||||
});
|
||||
|
||||
this.cargoProcess.stderr.on('data', (s: string) => {
|
||||
// console.error('Error on cargo watch : ' + s);
|
||||
console.error('Error on cargo watch : ' + s);
|
||||
});
|
||||
|
||||
this.cargoProcess.on('error', (err: Error) => {
|
||||
// console.error('Error on spawn cargo process : ' + err);
|
||||
console.error('Error on spawn cargo process : ' + err);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,6 +52,7 @@ export class CargoWatchProvider {
|
|||
|
||||
if (this.cargoProcess) {
|
||||
this.cargoProcess.kill();
|
||||
terminate(this.cargoProcess);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import * as timers from 'timers';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue