Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const launch = require('launch-editor')
launch(
// filename:line:column
// both line and column are optional
// `file://` URIs are also supported
'foo.js:12:34',
// try specific editor bin first (optional)
'code',
Expand Down
5 changes: 5 additions & 0 deletions packages/launch-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ function isTerminalEditor (editor) {

const positionRE = /:(\d+)(:(\d+))?$/
function parseFile (file) {
// support `file://` protocol
if (file.startsWith('file://')) {
file = require('url').fileURLToPath(file)
}

const fileName = file.replace(positionRE, '')
const match = file.match(positionRE)
const lineNumber = match && match[1]
Expand Down