mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Translate line and column numbers from URI handlers
The URI query string should specify line and column numbers as a user would, starting at 1, while the Atom API starts at 0.
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
// Converts a query string parameter for a line or column number
|
||||
// to a zero-based line or column number for the Atom API.
|
||||
function getLineColNumber (numStr) {
|
||||
const num = parseInt(numStr || 0, 10)
|
||||
return Math.max(num - 1, 0)
|
||||
}
|
||||
|
||||
function openFile (atom, {query}) {
|
||||
const {filename, line, column} = query
|
||||
|
||||
atom.workspace.open(filename, {
|
||||
initialLine: parseInt(line || 0, 10),
|
||||
initialColumn: parseInt(column || 0, 10),
|
||||
initialLine: getLineColNumber(line),
|
||||
initialColumn: getLineColNumber(column),
|
||||
searchAllPanes: true
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user