|
11 | 11 | var fs = require('fs');
|
12 | 12 | var path = require('path');
|
13 | 13 | var child_process = require('child_process');
|
| 14 | +var os = require('os'); |
14 | 15 | var chalk = require('chalk');
|
15 | 16 | var shellQuote = require('shell-quote');
|
16 | 17 |
|
@@ -43,7 +44,8 @@ function addWorkspaceToArgumentsIfExists(args, workspace) {
|
43 | 44 | }
|
44 | 45 |
|
45 | 46 | function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) {
|
46 |
| - switch (path.basename(editor)) { |
| 47 | + var editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, ''); |
| 48 | + switch (editorBasename) { |
47 | 49 | case 'vim':
|
48 | 50 | case 'mvim':
|
49 | 51 | return [fileName, '+' + lineNumber];
|
@@ -154,6 +156,20 @@ function launchEditor(fileName, lineNumber) {
|
154 | 156 | return;
|
155 | 157 | }
|
156 | 158 |
|
| 159 | + if ( |
| 160 | + process.platform === 'linux' && |
| 161 | + fileName.startsWith('/mnt/') && |
| 162 | + /Microsoft/i.test(os.release()) |
| 163 | + ) { |
| 164 | + // Assume WSL / "Bash on Ubuntu on Windows" is being used, and |
| 165 | + // that the file exists on the Windows file system. |
| 166 | + // `os.release()` is "4.4.0-43-Microsoft" in the current release |
| 167 | + // build of WSL, see: https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364 |
| 168 | + // When a Windows editor is specified, interop functionality can |
| 169 | + // handle the path translation, but only if a relative path is used. |
| 170 | + fileName = path.relative('', fileName); |
| 171 | + } |
| 172 | + |
157 | 173 | var workspace = null;
|
158 | 174 | if (lineNumber) {
|
159 | 175 | args = args.concat(
|
|
0 commit comments