Skip to content

Commit

Permalink
Resolve #102: Add config entry to set whether to ignore selection to …
Browse files Browse the repository at this point in the history
…always run entire file
  • Loading branch information
formulahendry committed Apr 15, 2017
1 parent c0dd4bd commit e8a4039
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.6.16 (2017-04-15)
* Resolve [GitHub issue#102](https://github.com/formulahendry/vscode-code-runner/issues/102): Add config entry to set whether to ignore selection to always run entire file

### 0.6.15 (2017-03-26)
* Add support for AutoIt

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ To set whether to preserve focus on code editor after code run is triggered (def
}
```

`code-runner.ignoreSelection`: Whether to ignore selection to always run entire file. (Default is **false**)

## About CWD Setting (current working directory)
1. By default, use the `code-runner.cwd` setting
2. If `code-runner.cwd` is not set and `code-runner.fileDirectoryAsCwd` is `true`, use the directory of the file to be executed
Expand Down
13 changes: 9 additions & 4 deletions 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 code snippet/file for C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Objective-C, Rust, Racket, AutoHotkey, AutoIt",
"version": "0.6.15",
"version": "0.6.16",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
Expand Down Expand Up @@ -196,12 +196,17 @@
"code-runner.runInTerminal": {
"type": "boolean",
"default": false,
"description": "Whether to run code in Integrated Terminal"
"description": "Whether to run code in Integrated Terminal."
},
"code-runner.preserveFocus": {
"type": "boolean",
"default": true,
"description": "Whether to preserve focus on code editor after code run is triggered"
"description": "Whether to preserve focus on code editor after code run is triggered."
},
"code-runner.ignoreSelection": {
"type": "boolean",
"default": false,
"description": "Whether to ignore selection to always run entire file."
}
}
},
Expand All @@ -227,7 +232,7 @@
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"applicationinsights": "^0.17.1",
"applicationinsights": "^0.19.0",
"tree-kill": "^1.1.0"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ export class CodeManager {

private getCodeFileAndExecute(editor: vscode.TextEditor, fileExtension: string, executor: string, appendFile: boolean = true): any {
let selection = editor.selection;
let ignoreSelection = this._config.get<boolean>('ignoreSelection');

if (selection.isEmpty && !editor.document.isUntitled) {
if ((selection.isEmpty || ignoreSelection) && !editor.document.isUntitled) {
this._isTmpFile = false;
this._codeFile = editor.document.fileName;

Expand All @@ -124,7 +125,7 @@ export class CodeManager {
});
}
} else {
let text = selection.isEmpty ? editor.document.getText() : editor.document.getText(selection);
let text = (selection.isEmpty || ignoreSelection) ? editor.document.getText() : editor.document.getText(selection);

if (this._languageId === "php") {
text = text.trim();
Expand Down

0 comments on commit e8a4039

Please sign in to comment.