mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #16215 from atom/mkt-fix-uri-handler-off-by-one-line-error
Translate line and column numbers from URI handlers
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