Skip to content

Fix(52604): Provide Object member completions without comma; insert a comma #52899

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

Merged
merged 18 commits into from
Jun 27, 2023
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7c72784
Add condition to fix without adding comma
navya9singh Feb 16, 2023
fa517aa
Fix for adding comma
navya9singh Feb 20, 2023
6613dca
fixing test and adding checks for other tests
navya9singh Feb 21, 2023
4f88134
removing commented code
navya9singh Feb 21, 2023
586a2e5
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
navya9singh Feb 21, 2023
3ab385f
Adressing pr comments
navya9singh Feb 23, 2023
abb5c07
fixing auto-imports
navya9singh Feb 23, 2023
c8c1362
fixing lint error
navya9singh Feb 23, 2023
463a435
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
navya9singh Jun 14, 2023
54456cc
Adressing pr comments and adding test cases
navya9singh Jun 20, 2023
87b09f8
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
navya9singh Jun 20, 2023
2fff618
adding test cases
navya9singh Jun 23, 2023
b33aef8
Minor changes and adding a test case
navya9singh Jun 24, 2023
731222c
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
navya9singh Jun 26, 2023
89d178b
Apply suggestions from code review
DanielRosenwasser Jun 26, 2023
790b30c
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
navya9singh Jun 26, 2023
c477b17
Merge branch 'fix(52604)' of https://github.com/microsoft/TypeScript …
navya9singh Jun 26, 2023
7e861b6
Adding test for spread assignment
navya9singh Jun 27, 2023
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
  • Loading branch information
DanielRosenwasser authored Jun 26, 2023
commit 89d178b6ded5b6ca2a5e1c885d5e2578ebe1d34e
10 changes: 6 additions & 4 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ function createCompletionEntry(
isGetAccessorDeclaration(contextToken.parent.parent) ||
isSetAccessorDeclaration(contextToken.parent.parent) ||
isSpreadAssignment(contextToken.parent) ||
findAncestor(contextToken.parent, isPropertyAssignment)?.getLastToken() === contextToken ||
findAncestor(contextToken.parent, isPropertyAssignment)?.getLastToken(sourceFile) === contextToken ||
isShorthandPropertyAssignment(contextToken.parent) && getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {

source = CompletionSource.ObjectLiteralMemberWithComma;
Expand Down Expand Up @@ -2893,7 +2893,9 @@ function getCompletionEntryCodeActionsAndSourceDisplay(
if (source === CompletionSource.ObjectLiteralMemberWithComma && contextToken) {
const changes = textChanges.ChangeTracker.with(
{ host, formatContext, preferences },
tracker => tracker.insertText(sourceFile, contextToken.end, ","));
tracker => tracker.insertText(sourceFile, contextToken.end, ",")
);

if (changes) {
return {
sourceDisplay: undefined,
Expand Down Expand Up @@ -4954,7 +4956,7 @@ function tryGetObjectLikeCompletionContainer(contextToken: Node | undefined, pos
return contextToken.parent.parent;
}
const ancestorNode = findAncestor(parent, isPropertyAssignment);
if (ancestorNode?.getLastToken() === contextToken && isObjectLiteralExpression(ancestorNode.parent)) {
if (ancestorNode?.getLastToken(sourceFile) === contextToken && isObjectLiteralExpression(ancestorNode.parent)) {
return ancestorNode.parent;
}
}
Expand All @@ -4964,7 +4966,7 @@ function tryGetObjectLikeCompletionContainer(contextToken: Node | undefined, pos
return parent.parent.parent;
}
const ancestorNode = findAncestor(parent, isPropertyAssignment);
if (contextToken.kind !== SyntaxKind.ColonToken && ancestorNode?.getLastToken() === contextToken &&
if (contextToken.kind !== SyntaxKind.ColonToken && ancestorNode?.getLastToken(sourceFile) === contextToken &&
isObjectLiteralExpression(ancestorNode.parent)) {
return ancestorNode.parent;
}
Expand Down