Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle ins/del in completion-record typechecks #610

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/typechecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,19 @@ function previousText(expr: Expr, path: PathItem[]): string | null {

function textFromPreviousPart(seq: Seq, index: number): string | null {
let prevIndex = index - 1;
let text = null;
let prev;
while (isProsePart((prev = seq.items[prevIndex]))) {
if (prev.name === 'text') {
return prev.contents;
text = prev.contents + (text ?? '');
--prevIndex;
} else if (prev.name === 'tag') {
--prevIndex;
} else {
break;
}
}
return null;
return text;
}

function stripWhitespace(items: NonSeq[]) {
Expand Down
3 changes: 3 additions & 0 deletions test/typecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ describe('typechecking completions', () => {
1. Set _a_ to Completion(<emu-meta suppress-effects="user-code">ExampleAlg()</emu-meta>).
1. Set _a_ to ! ExampleAlg().
1. Return ? ExampleAlg().
1. Return <ins>?</ins> ExampleAlg().
1. Return <del>?</del> <ins>!</ins> ExampleAlg().
1. Let _foo_ be 0.
1. Set _a_ to Completion(ExampleSDO of _foo_).
1. Set _a_ to Completion(ExampleSDO of _foo_ with argument 0).
Expand Down Expand Up @@ -284,6 +286,7 @@ describe('typechecking completions', () => {
</dl>
<emu-alg>
1. Return ExampleAlg().
1. Return <del>!</del> ExampleAlg().
</emu-alg>
</emu-clause>
`);
Expand Down
Loading