Skip to content

Commit

Permalink
refactor: use position in minUsRange instead of lines and columns
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSaba committed Dec 6, 2024
1 parent c40f3c1 commit 7ee4792
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ function getRangesFromDecorations (

function minusRanges (uniqueRange: monaco.Range, ranges: monaco.Range[]): monaco.Range[] {
const newRanges: monaco.Range[] = []
let lastEndLineNumber = uniqueRange.startLineNumber
let lastEndColumn = uniqueRange.startColumn
let lastEndPosition = uniqueRange.getStartPosition()

for (const range of ranges) {
const newRange = new monaco.Range(lastEndLineNumber, lastEndColumn, range.startLineNumber, range.startColumn)
lastEndLineNumber = range.endLineNumber
lastEndColumn = range.endColumn
const newRange = monaco.Range.fromPositions(lastEndPosition, range.getStartPosition())
lastEndPosition = range.getEndPosition()
newRanges.push(newRange)
}

if (lastEndLineNumber < uniqueRange.endLineNumber || lastEndColumn < uniqueRange.endColumn) {
newRanges.push(new monaco.Range(lastEndLineNumber, lastEndColumn, uniqueRange.endLineNumber, uniqueRange.endColumn))
if (lastEndPosition.isBefore(uniqueRange.getEndPosition())) {
newRanges.push(monaco.Range.fromPositions(lastEndPosition, uniqueRange.getEndPosition()))
}

return newRanges
Expand Down

0 comments on commit 7ee4792

Please sign in to comment.