Skip to content

Commit

Permalink
Use line offset for all ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Jan 21, 2024
1 parent f8522c1 commit ce1020b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions extension/server/src/providers/linter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,16 @@ export function getExtractProcedureAction(document: TextDocument, docs: Cache, r

const nameDiffSize = 1; // Always once since we only add 'p' at the start
const newParamNames = validRefs.map(ref => `p${ref.dec.name}`);
let procedureBody = document.getText(range);
let procedureBody = document.getText(linesRange);

const rangeStartOffset = document.offsetAt(linesRange.start);

// Fix the found offset lengths to be relative to the new procedure
for (let i = validRefs.length - 1; i >= 0; i--) {
for (let y = validRefs[i].refs.length - 1; y >= 0; y--) {
validRefs[i].refs[y] = {
position: validRefs[i].refs[y].position - document.offsetAt(range.start),
end: validRefs[i].refs[y].end - document.offsetAt(range.start)
position: validRefs[i].refs[y].position - rangeStartOffset,
end: validRefs[i].refs[y].end - rangeStartOffset
};
}
}
Expand Down

0 comments on commit ce1020b

Please sign in to comment.