Skip to content

Commit 3ef06ec

Browse files
committed
Convert object
1 parent 96d7e76 commit 3ef06ec

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

lib/input.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,5 @@ export default class Input {
126126
*
127127
* @param offset Source offset.
128128
*/
129-
fromOffset (
130-
offset: number
131-
): { offset?: number; line?: number; column?: number }
129+
fromOffset (offset: number): { line: number; col: number } | null
132130
}

lib/input.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ class Input {
5151

5252
fromOffset (offset) {
5353
let finder = vfileLocation(this.css)
54-
this.fromOffset = i => finder.toPoint(i)
54+
this.fromOffset = i => {
55+
let position = finder.toPoint(i)
56+
return {
57+
line: position.line,
58+
col: position.column
59+
}
60+
}
5561
return this.fromOffset(offset)
5662
}
5763

@@ -60,7 +66,7 @@ class Input {
6066
if (!column) {
6167
let pos = this.fromOffset(line)
6268
line = pos.line
63-
column = pos.column
69+
column = pos.col
6470
}
6571
let origin = this.origin(line, column)
6672
if (origin) {

lib/parser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,12 @@ class Parser {
376376
// Helpers
377377

378378
getPosition (offset) {
379-
return this.input.fromOffset(offset)
379+
let pos = this.input.fromOffset(offset)
380+
return {
381+
offset,
382+
line: pos.line,
383+
column: pos.col
384+
}
380385
}
381386

382387
init (node, offset) {

0 commit comments

Comments
 (0)