diff --git a/lib/input.js b/lib/input.js index 4c754d14c..0bbfd69b1 100644 --- a/lib/input.js +++ b/lib/input.js @@ -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') @@ -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) } diff --git a/package.json b/package.json index 4bea315b4..3c1f1a4d1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 46f48175e..c0c65f6a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"