lahmatiy / open-in-editor Goto Github PK
View Code? Open in Web Editor NEWNPM package to open a file in editor
License: MIT License
NPM package to open a file in editor
License: MIT License
Hello, I ran into an issue where the path wouldn't translate properly when using the extension in WSL.
"alt-editor.name": "sublime",
"alt-editor.binary": "/mnt/c/program files/sublime text 3/sublime_text.exe",
had to change the fileLoc as quick fix for my use, as I also couldn't add through the arg settings:
const fileLoc = "\\\\wsl$\\ubuntu\\" +
${fileName}:${line}:${column}.replace(/\//g,"\\");
function openFile(fileName, line = 1, column = 1, config = {}) {
if (!config || Object.keys(config).length === 0) {
config = vscode.workspace.getConfiguration(extension);
}
const options = getEditorOptions(config);
const fileLoc = "\\\\wsl$\\ubuntu\\" + `${fileName}:${line}:${column}`.replace(/\//g,"\\");
const intro = vscode.window.setStatusBarMessage(`Opening ${fileLoc}...`);
const res = createEditor(options)
.then((editor) => editor.open(fileLoc))
.then((openResult) => {
intro.dispose();
vscode.window.setStatusBarMessage(`Opened ${fileLoc}`, 5000);
return openResult;
})
.catch((err) => {
vscode.window.showErrorMessage(`Can't open the file ${fileLoc}: ${err}`)
.then(() => intro.dispose());
});
return res;
}
Please add a case for WSL execution when you have time, it's a really handy extension. Thank you for your making it.
Apart from filename, line, column, could you please add workspace placeholder? This enables me to set pwd for vim on startup.
Hello, is there any way of having the module check the ENV but default to eg Vim if nothing is present? As is, it throws an error of editor not set
.
Thanks!
failCallback – optional function that calls when something goes wrong on editor setup.
Users might want to know when does configure
fail and why?
Recently #6 was merged. It adds basic support for open file in vim
. However we need fix some issues:
//cc @pofigizm
We use vscode and webstorm where I work and I'd like to show a list of options of all supported installed editors so the user can choose.
I know there is some detection going on internally but I'd like to know if this api is exposed. If not, could it be?
cheers
The JetBrains Toolbox desktop app doesn't install to C:\Program Files (x86)\JetBrains
. Instead (at least on Windows), it installs to %LOCALAPPDATA%\JetBrains\Toolbox\apps
. JetBrains editors are not detected if installed with the app.
ubuntu 16.10,
node v7.7.3
open-in-editor 2.0.0
$ env | grep EDITOR
EDITOR=/usr/bin/vim
$ ./node_modules/.bin/oe index.js:1
TypeError: Cannot read property 'patternOnly' of undefined
I have some binary files which only open with another tool. Everytime I "open" them, I'd like the external tool to start. I don't see that you can define which tool to call based on the file extension (or better yet a glob expression).
@lahmatiy I encountered a bug that open-in-editor does't work correctly when editor is emacs.
Background
reference:
aws-amplify/amplify-cli#1246
Bug summary
When aws-amplify/amplify-cli apply an option of add api
, an error occurred as below.
Error: Command failed: osascript -e 'tell application "Terminal" to do script "cd /Users/chris/Projects/training/nab2019-aws-workshop/aws-amplify-unicorntrivia-workshop-master; emacs --no-splash \"+1:1\" \"/Users/chris/Projects/training/nab2019-aws-workshop/amplify/backend/api/adminpanel/schema.graphql"'\"
266:268: syntax error: A “"” can’t go after this “"”. (-2740)
I researched this bug and I found out that open-in-editor's escaping logic is wrong.
My proposal
To fix this bug, change lib/open.js as below.
diff --git a/lib/open.js b/lib/open.js
index 4d08053..50df999 100644
--- a/lib/open.js
+++ b/lib/open.js
@@ -33,7 +33,7 @@ function makeArguments(filename, settings) {
// {filename}:1:2
// => "filename:1:2"
//
- .replace(/\{filename\}(\S*)/, function(m, rest) {
+ .replace(/\{filename\}([^\\'"\s]*)/, function(m, rest) {
return quote(info.filename + rest, settings.escapeQuotes);
});
}
Pull request
#16
Please consider that, I hope my pull request will be help to open-in-editor
.
Thank you and best regard.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.