-
-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Auto-detect running editor on Linux for error overlay #3077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
64a6ed7
992104c
9456669
9197752
e023800
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Basic support of auto detecting running editor for #2636. Tested on Ubuntu 16.04. It detects few editors. JetBrains products should start by wrapper like /usr/local/bin/webstorm. Otherwise it takes a lot of time to open editor.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ const COMMON_EDITORS_OSX = { | |
| '/Applications/CLion.app/Contents/MacOS/clion': | ||
| '/Applications/CLion.app/Contents/MacOS/clion', | ||
| '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea': | ||
| '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', | ||
| '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', | ||
| '/Applications/PhpStorm.app/Contents/MacOS/phpstorm': | ||
| '/Applications/PhpStorm.app/Contents/MacOS/phpstorm', | ||
| '/Applications/PyCharm.app/Contents/MacOS/pycharm': | ||
|
|
@@ -53,7 +53,19 @@ const COMMON_EDITORS_OSX = { | |
| '/Applications/RubyMine.app/Contents/MacOS/rubymine': | ||
| '/Applications/RubyMine.app/Contents/MacOS/rubymine', | ||
| '/Applications/WebStorm.app/Contents/MacOS/webstorm': | ||
| '/Applications/WebStorm.app/Contents/MacOS/webstorm', | ||
| '/Applications/WebStorm.app/Contents/MacOS/webstorm', | ||
| }; | ||
|
|
||
| const COMMON_EDITORS_LINUX = { | ||
| atom: 'atom', | ||
| Brackets: 'brackets', | ||
| code: 'code', | ||
| 'idea.sh': 'idea', | ||
| 'phpstorm.sh': 'phpstorm', | ||
| 'pycharm.sh': 'pycharm', | ||
| 'rubymine.sh': 'rubymine', | ||
| sublime_text: 'sublime_text', | ||
| 'webstorm.sh': 'webstorm', | ||
| }; | ||
|
|
||
| const COMMON_EDITORS_WIN = [ | ||
|
|
@@ -145,7 +157,6 @@ function guessEditor() { | |
| } | ||
|
|
||
| // Using `ps x` on OSX or `Get-Process` on Windows we can find out which editor is currently running. | ||
| // Potentially we could use similar technique for Linux | ||
| try { | ||
| if (process.platform === 'darwin') { | ||
| const output = child_process.execSync('ps x').toString(); | ||
|
|
@@ -176,6 +187,17 @@ function guessEditor() { | |
| return [fullProcessPath]; | ||
| } | ||
| } | ||
| } else if (process.platform === 'linux') { | ||
| const output = child_process | ||
| .execSync('ps --no-heading -e -o comm --sort=comm') | ||
|
||
| .toString(); | ||
| const processNames = Object.keys(COMMON_EDITORS_LINUX); | ||
| for (let i = 0; i < processNames.length; i++) { | ||
| const processName = processNames[i]; | ||
| if (output.indexOf(processName) !== -1) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we worry about a process which is named like,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd probably want to apply this logic to macOS, too.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure.
in list like:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can worry about it later. 😄 |
||
| return [COMMON_EDITORS_LINUX[processName]]; | ||
| } | ||
| } | ||
| } | ||
| } catch (error) { | ||
| // Ignore... | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can update this now, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reworded it