Initial checkin of Blueprint-MCP plugin
This commit is contained in:
32
tools/blueprint-mcp/node_modules/@vitest/utils/dist/offset.js
generated
vendored
Normal file
32
tools/blueprint-mcp/node_modules/@vitest/utils/dist/offset.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
const lineSplitRE = /\r?\n/;
|
||||
function positionToOffset(source, lineNumber, columnNumber) {
|
||||
const lines = source.split(lineSplitRE);
|
||||
const nl = /\r\n/.test(source) ? 2 : 1;
|
||||
let start = 0;
|
||||
if (lineNumber > lines.length) {
|
||||
return source.length;
|
||||
}
|
||||
for (let i = 0; i < lineNumber - 1; i++) {
|
||||
start += lines[i].length + nl;
|
||||
}
|
||||
return start + columnNumber;
|
||||
}
|
||||
function offsetToLineNumber(source, offset) {
|
||||
if (offset > source.length) {
|
||||
throw new Error(`offset is longer than source length! offset ${offset} > length ${source.length}`);
|
||||
}
|
||||
const lines = source.split(lineSplitRE);
|
||||
const nl = /\r\n/.test(source) ? 2 : 1;
|
||||
let counted = 0;
|
||||
let line = 0;
|
||||
for (; line < lines.length; line++) {
|
||||
const lineLength = lines[line].length + nl;
|
||||
if (counted + lineLength >= offset) {
|
||||
break;
|
||||
}
|
||||
counted += lineLength;
|
||||
}
|
||||
return line + 1;
|
||||
}
|
||||
|
||||
export { lineSplitRE, offsetToLineNumber, positionToOffset };
|
||||
Reference in New Issue
Block a user