From f7c76c9ad6ff8f9d3c376ebd3100b8d99d033c99 Mon Sep 17 00:00:00 2001 From: Jon Sterling Date: Thu, 30 Jul 2026 10:48:06 +0100 Subject: [PATCH] Fix edge cases in readonly tracking --- Dissertation/Model/NSAttributedString+Block.swift | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Dissertation/Model/NSAttributedString+Block.swift b/Dissertation/Model/NSAttributedString+Block.swift index 3e2ee28..524ffda 100644 --- a/Dissertation/Model/NSAttributedString+Block.swift +++ b/Dissertation/Model/NSAttributedString+Block.swift @@ -36,13 +36,8 @@ extension NSAttributedString { func locationIsReadonly(_ location: Int) -> Bool { var leftReadonly = false var rightReadonly = false - if location > 0 { - leftReadonly = attribute(.readonly, at: location - 1, effectiveRange: nil) != nil - } - - if location < length { - rightReadonly = attribute(.readonly, at: location, effectiveRange: nil) != nil - } + leftReadonly = attribute(.readonly, at: max(0, location - 1), effectiveRange: nil) != nil + rightReadonly = attribute(.readonly, at: min(location, length - 1), effectiveRange: nil) != nil return leftReadonly && rightReadonly } -- knotmirror 0.0.1