Skip to content

Commit

Permalink
Fix #191: Stop running code when VS Code is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
formulahendry committed Oct 20, 2017
1 parent 8cce294 commit 3571b9d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.7.4 (2017-10-20)
* [#191](https://github.com/formulahendry/vscode-code-runner/issues/191): Stop running code when VS Code is closed

### 0.7.3 (2017-10-14)
* Add support for Multi Root Workspaces

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "code-runner",
"displayName": "Code Runner",
"description": "Run C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Objective-C, Rust, Racket, AutoHotkey, AutoIt, Kotlin, Dart, Pascal, Haskell, Nim, D",
"version": "0.7.3",
"version": "0.7.4",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
Expand Down
10 changes: 9 additions & 1 deletion src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AppInsightsClient } from "./appInsightsClient";

const TmpDir = os.tmpdir();

export class CodeManager {
export class CodeManager implements vscode.Disposable {
private _outputChannel: vscode.OutputChannel;
private _terminal: vscode.Terminal;
private _isRunning: boolean;
Expand Down Expand Up @@ -87,6 +87,14 @@ export class CodeManager {

public stop(): void {
this._appInsightsClient.sendEvent("stop");
this.stopRunning();
}

public dispose() {
this.stopRunning();
}

private stopRunning() {
if (this._isRunning) {
this._isRunning = false;
const kill = require("tree-kill");
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(runCustomCommand);
context.subscriptions.push(runByLanguage);
context.subscriptions.push(stop);
context.subscriptions.push(codeManager);
}

export function deactivate() {
Expand Down

0 comments on commit 3571b9d

Please sign in to comment.