Skip to content

Commit

Permalink
Merge pull request #1466 from postcss/vfile-location
Browse files Browse the repository at this point in the history
Replace line-column with vfile-location
  • Loading branch information
ai committed Nov 21, 2020
2 parents 6d2d1fb + 3ef06ec commit b6351d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/input.js
Expand Up @@ -3,7 +3,7 @@
let { fileURLToPath, pathToFileURL } = require('url')
let { resolve, isAbsolute } = require('path')
let { nanoid } = require('nanoid/non-secure')
let lineColumn = require('line-column')
let vfileLocation = require('vfile-location')

let terminalHighlight = require('./terminal-highlight')
let CssSyntaxError = require('./css-syntax-error')
Expand Down Expand Up @@ -50,8 +50,14 @@ class Input {
}

fromOffset (offset) {
let finder = lineColumn(this.css)
this.fromOffset = i => finder.fromIndex(i)
let finder = vfileLocation(this.css)
this.fromOffset = i => {
let position = finder.toPoint(i)
return {
line: position.line,
col: position.column
}
}
return this.fromOffset(offset)
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -39,9 +39,9 @@
"repository": "postcss/postcss",
"dependencies": {
"colorette": "^1.2.1",
"line-column": "^1.0.2",
"nanoid": "^3.1.16",
"source-map": "^0.6.1"
"source-map": "^0.6.1",
"vfile-location": "^3.2.0"
},
"devDependencies": {
"@logux/eslint-config": "^42.2.2",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -11037,6 +11037,11 @@ vfile-location@^2.0.0:
resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-2.0.6.tgz#8a274f39411b8719ea5728802e10d9e0dff1519e"
integrity sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA==

vfile-location@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-3.2.0.tgz#d8e41fbcbd406063669ebf6c33d56ae8721d0f3c"
integrity sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA==

vfile-message@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-1.1.1.tgz#5833ae078a1dfa2d96e9647886cd32993ab313e1"
Expand Down

0 comments on commit b6351d5

Please sign in to comment.