Skip to content
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

add editor/ide quick edit link to file/line on each error message #1566

Closed
wants to merge 1 commit into from

Conversation

evaisse
Copy link

@evaisse evaisse commented Feb 15, 2017

Hi, I would like to offer the ability to get a quick link to jump to file/line on error screen. by adding in package.json an editor command file pattern like this one : "subl://open?url=%%f&line=%%l&column=%%c" (how can I achieve this ? what's the better solution here package /process.env ??)

demo

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@gaearon
Copy link
Contributor

gaearon commented Feb 15, 2017

Is there a more generic way of setting this up, so that it would work with any compatible editor?

@evaisse
Copy link
Author

evaisse commented Feb 15, 2017 via email

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@viankakrisna
Copy link
Contributor

@evaisse how about reading to .env file? usually this files do not checked out to the repo, so the developers can set TEXT_EDITOR variable there

@evaisse
Copy link
Author

evaisse commented Feb 20, 2017 via email

@viankakrisna
Copy link
Contributor

viankakrisna commented Feb 20, 2017

Do you have any source for text editor uri? I'm not currently familiar with it :). Can't we just use whatever default text editor the user use for default? This feature is really great, but if the user need to know how to configure it before using it i think it doesn't inline with zero config spirit :3

reading more into it, i think its better to use executable path

subl media-views.js:10:5 open media-views.js with sublime on line 10 column 5

atom media-views.js:10:5 open media-views.js with atom on line 10 column 5

and .env just set to whatever executables the user want.
haven't got the idea how to detect defaults though. maybe ask it while running the first time and not see the TEXT_EDITOR env var?

any reason why it needs to be text editor uri?

@evaisse
Copy link
Author

evaisse commented Feb 21, 2017 via email

@viankakrisna
Copy link
Contributor

hmm, rather relying on users to install those handler, I think we can spawn another listener from this https://github.com/facebookincubator/create-react-app/tree/master/packages/react-dev-utils that is being called by scripts/start.js

@evaisse
Copy link
Author

evaisse commented Feb 21, 2017 via email

@viankakrisna
Copy link
Contributor

viankakrisna commented Feb 21, 2017

I don't think so. I'm thinking about spawning another node server, which listen to a specific url, and get the path, numbers, and column from it.

Something like this

<a target="_blank" href="http://localhost:8962?path=/home/Projects/troublefile.js&line=10&column=2"></a>
const express = require('express')  
const app = express()  
const exec = require('child_process').exec
const port = 8962 //should use any available port

app.get('/', (req, res) => {
exec('subl '+ [req.query.path, req.query.line, req.query.column'] , (error, stdout, stderr) => {
  if (error) {
    console.error(`exec error: ${error}`);
    return;
  }
 res.send('<script>window.close();</script>')
});
  
})

app.listen(port, (err) => {  
  if (err) {
    return console.log('something bad happened', err)
  }
  console.log(`server is listening on ${port}`)
})

@evaisse
Copy link
Author

evaisse commented Feb 22, 2017 via email

@viankakrisna
Copy link
Contributor

found a nice package for it! https://www.npmjs.com/package/open-in-editor

Supported editors:

sublime – Sublime Text
atom – Atom Editor
code – Visual Studio Code
webstorm – WebStorm
phpstorm - PhpStorm
idea14ce – IDEA 14 CE

i think we should also update the docs if this is working

@lahmatiy
Copy link

@viankakrisna
Some useful links:

@viankakrisna
Copy link
Contributor

I think this is already implemented by #2141 right now 👍

@gaearon
Copy link
Contributor

gaearon commented Jul 17, 2017

Not quite. It's implemented in #2141 for runtime overlay, but we don't have this for build-time overlay. I think we should figure out a way to do this after #2515 lands.

@gaearon
Copy link
Contributor

gaearon commented Jul 17, 2017

Filed #2805 to discuss this. Closing this PR. Thanks for the effort!

@gaearon gaearon closed this Jul 17, 2017
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants