Replace lines-and-columns with index-to-position (#17325)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-04-09 08:12:22 +08:00
1 parent f406c9cab9
commit 004e1e0028
4 files changed
+13 -25

No files matched your search

+2 -3
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import fs from "node:fs";
import { LinesAndColumns } from "lines-and-columns";
import indexToPosition from "index-to-position";
import { outdent } from "outdent";
import { CHANGELOG_CATEGORIES } from "./utils/changelog-categories.js";
@@ -142,9 +142,8 @@ for (const category of CHANGELOG_CATEGORIES) {
function getCommentDescription(content, comment) {
const start = content.indexOf(comment);
const end = start + comment.length;
const linesAndColumns = new LinesAndColumns(content);
const [startLine, endLine] = [start, end].map(
(index) => linesAndColumns.locationForIndex(index).line + 1,
(index) => indexToPosition(content, index, { oneBased: true }).line,
);
if (startLine === endLine) {