Skip to content

Commit 460ad15

Browse files
authored
handle ins/del in completion-record typechecks (#610)
1 parent f9f05bf commit 460ad15

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/typechecker.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -347,17 +347,19 @@ function previousText(expr: Expr, path: PathItem[]): string | null {
347347

348348
function textFromPreviousPart(seq: Seq, index: number): string | null {
349349
let prevIndex = index - 1;
350+
let text = null;
350351
let prev;
351352
while (isProsePart((prev = seq.items[prevIndex]))) {
352353
if (prev.name === 'text') {
353-
return prev.contents;
354+
text = prev.contents + (text ?? '');
355+
--prevIndex;
354356
} else if (prev.name === 'tag') {
355357
--prevIndex;
356358
} else {
357359
break;
358360
}
359361
}
360-
return null;
362+
return text;
361363
}
362364

363365
function stripWhitespace(items: NonSeq[]) {

test/typecheck.js

+3
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ describe('typechecking completions', () => {
203203
1. Set _a_ to Completion(<emu-meta suppress-effects="user-code">ExampleAlg()</emu-meta>).
204204
1. Set _a_ to ! ExampleAlg().
205205
1. Return ? ExampleAlg().
206+
1. Return <ins>?</ins> ExampleAlg().
207+
1. Return <del>?</del> <ins>!</ins> ExampleAlg().
206208
1. Let _foo_ be 0.
207209
1. Set _a_ to Completion(ExampleSDO of _foo_).
208210
1. Set _a_ to Completion(ExampleSDO of _foo_ with argument 0).
@@ -284,6 +286,7 @@ describe('typechecking completions', () => {
284286
</dl>
285287
<emu-alg>
286288
1. Return ExampleAlg().
289+
1. Return <del>!</del> ExampleAlg().
287290
</emu-alg>
288291
</emu-clause>
289292
`);

0 commit comments

Comments
 (0)