Skip to content

Commit

Permalink
fix: prevent edit when uneditable range and selected range intersect …
Browse files Browse the repository at this point in the history
…or touch
  • Loading branch information
KaiSaba committed Dec 3, 2024
1 parent 221a01d commit 9c006e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function lockCodeUsingDecoration (
return true
}
return withDecoration
? ranges.every((uneditableRange) => !uneditableRange.containsRange(range))
? ranges.every((uneditableRange) => !monaco.Range.areIntersectingOrTouching(uneditableRange, range))
: ranges.some((editableRange) => editableRange.containsRange(range))
}

Expand All @@ -139,6 +139,7 @@ function lockCodeUsingDecoration (
const selection = selections[0]!
const fullModelRange = model.getFullModelRange()
const wholeFileSelected = fullModelRange.equalsRange(selection)
console.log('selections', selections, selection, wholeFileSelected, lastEditableRange)

Check warning on line 142 in src/tools.ts

View workflow job for this annotation

GitHub Actions / Check build

Unexpected console statement
if (wholeFileSelected) {
const currentEditorValue = editor.getValue()
const before = model.getOffsetAt(lastEditableRange.getStartPosition())
Expand Down

0 comments on commit 9c006e5

Please sign in to comment.