🌐 AI搜索 & 代理 主页
Skip to content

Commit b6351d5

Browse files
authored
Merge pull request #1466 from postcss/vfile-location
Replace line-column with vfile-location
2 parents 6d2d1fb + 3ef06ec commit b6351d5

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

lib/input.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
let { fileURLToPath, pathToFileURL } = require('url')
44
let { resolve, isAbsolute } = require('path')
55
let { nanoid } = require('nanoid/non-secure')
6-
let lineColumn = require('line-column')
6+
let vfileLocation = require('vfile-location')
77

88
let terminalHighlight = require('./terminal-highlight')
99
let CssSyntaxError = require('./css-syntax-error')
@@ -50,8 +50,14 @@ class Input {
5050
}
5151

5252
fromOffset (offset) {
53-
let finder = lineColumn(this.css)
54-
this.fromOffset = i => finder.fromIndex(i)
53+
let finder = vfileLocation(this.css)
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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
"repository": "postcss/postcss",
4040
"dependencies": {
4141
"colorette": "^1.2.1",
42-
"line-column": "^1.0.2",
4342
"nanoid": "^3.1.16",
44-
"source-map": "^0.6.1"
43+
"source-map": "^0.6.1",
44+
"vfile-location": "^3.2.0"
4545
},
4646
"devDependencies": {
4747
"@logux/eslint-config": "^42.2.2",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11037,6 +11037,11 @@ vfile-location@^2.0.0:
1103711037
resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-2.0.6.tgz#8a274f39411b8719ea5728802e10d9e0dff1519e"
1103811038
integrity sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA==
1103911039

11040+
vfile-location@^3.2.0:
11041+
version "3.2.0"
11042+
resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-3.2.0.tgz#d8e41fbcbd406063669ebf6c33d56ae8721d0f3c"
11043+
integrity sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA==
11044+
1104011045
vfile-message@^1.0.0:
1104111046
version "1.1.1"
1104211047
resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-1.1.1.tgz#5833ae078a1dfa2d96e9647886cd32993ab313e1"

0 commit comments

Comments
 (0)