Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion server/proof-span-strip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,16 @@ export function expandRangeToIncludeFullyWrappedAuthoredSpan(
let nextEnd = end;

for (const span of listAuthoredProofSpanBounds(markdown)) {
if (nextStart === span.contentStart && nextEnd === span.contentEnd) {
// Expand when the resolved range covers the span's entire inner content and
// sits within the span's outer tag bounds. Anchor resolution that strips
// authored spans can return a range that reaches the opening tag on one
// side but stops at the content edge on the other (e.g. [openStart,
// contentEnd]); requiring exact content-bound equality left the unmatched
// tag behind as an orphaned </span>. A partial-content edit does not cover
// the full content, so it is left untouched and keeps its wrapper.
const coversFullContent = nextStart <= span.contentStart && nextEnd >= span.contentEnd;
const withinSpanBounds = nextStart >= span.openStart && nextEnd <= span.closeEnd;
if (coversFullContent && withinSpanBounds) {
nextStart = span.openStart;
nextEnd = span.closeEnd;
break;
Expand Down