Skip to content

Add completion helpers and port more completion fourslash tests#1290

Merged
gabritto merged 17 commits into
mainfrom
gabritto/convertmore
Jun 27, 2025
Merged

Add completion helpers and port more completion fourslash tests#1290
gabritto merged 17 commits into
mainfrom
gabritto/convertmore

Conversation

@gabritto
Copy link
Copy Markdown
Member

@gabritto gabritto commented Jun 25, 2025

This PR mainly adds completion helpers like completionGlobals and completionGlobalsPlus to Corsa. Those helpers are in internalfourslash/tests/util_test.go (and copied to internalfourslash/tests/gen/util_test.go).
It also ports Strada tests that use those helpers.

Another main change is that, to make the completionGlobals helper work, this PR also makes a change to completion such that whenever the old code would set an optionalReplacementSpan, we set the editRange in CompletionList.ItemDefaults. Before, we were using the optional replacement span to set a TextEdit on each completion item, so we couldn't reliably use completionGlobals because depending on the completion position, each global completion item would have a TextEdit (or not).

There are, like always, a number of bug fixes needed to get the tests to at least not crash. This PR ports 68 new completion tests, 38 of which are failing tests added to the failing test list, and removes 13 tests from the failing list. A lot of the new failing tests are JS/JSDoc stuff that I think isn't properly implemented yet.

@@ -4025,22 +4087,6 @@ func (l *LanguageService) createLSPCompletionItem(
Range: *replacementSpan,
},
}
} else {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moved to setItemDefaults.

@gabritto gabritto changed the title Gabritto/convertmore Add completion helpers and port more completion fourslash tests Jun 25, 2025
@gabritto gabritto marked this pull request as ready for review June 26, 2025 00:02
Comment thread internal/parser/parser.go
@@ -6452,7 +6452,7 @@ func extractPragmas(commentRange ast.CommentRange, text string) []ast.Pragma {
}
}
if commentRange.Kind == ast.KindMultiLineCommentTrivia {
text = text[:len(text)-2]
text = strings.TrimSuffix(text, "*/")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would the old code have failed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have an unclosed multiline comment, like /* ..., then it is wrong to unconditionally drop the last two characters, because they won't be */, and if the comment is empty, e.g. /*, this later causes an out of bounds panic in the call to skipTo, since we start at pos := 2.

@gabritto gabritto added this pull request to the merge queue Jun 27, 2025
Merged via the queue into main with commit 05c0e2b Jun 27, 2025
22 checks passed
@gabritto gabritto deleted the gabritto/convertmore branch June 27, 2025 22:08
Copilot AI added a commit that referenced this pull request May 18, 2026
Add a `packageInfo.Exists()` guard before accessing `packageInfo.Contents`
at line 1132 in `loadModuleFromSpecificNodeModulesDirectory`. Without this
check, a nil `Contents` field (possible under concurrent resolution races
where `LoadOrStore` returns a stale cache entry) causes a fatal nil-pointer
dereference.

This matches the defensive pattern already used at other `Contents` access
sites in the same function (lines 1078, 1101, 1124).

Fixes #1290

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI added a commit that referenced this pull request May 18, 2026
Change isJSDocLikeText in the printer to use >= 5 instead of > 5 for
the length check, matching TypeScript's behavior of preserving empty
JSDoc comments like /***/ in declaration output.

Fixes #1290

Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/814ee36f-78e4-4428-a2eb-b12e40bd2a45

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants