Skip to content

Fix completion disappear after a property declaration with a private modifier #32726

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 1 commit into from
Aug 13, 2019
Merged

Fix completion disappear after a property declaration with a private modifier #32726

merged 1 commit into from
Aug 13, 2019

Conversation

fuafa
Copy link
Contributor

@fuafa fuafa commented Aug 6, 2019

Fix class member completion disappear after a property declaration with a private modifier.

Fixes #30290

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

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

Yeah, thanks - this looks good to me 👍

@fuafa
Copy link
Contributor Author

fuafa commented Aug 13, 2019

Hi, @orta , Thanks for your review, any update on this?

@@ -1566,7 +1566,7 @@ namespace ts.Completions {
// If you're in an interface you don't want to repeat things from super-interface. So just stop here.
if (!isClassLike(decl)) return GlobalsSearch.Success;

const classElement = contextToken.parent;
const classElement = contextToken.kind === SyntaxKind.SemicolonToken ? contextToken.parent.parent : contextToken.parent;
Copy link
Member

Choose a reason for hiding this comment

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

Is this the right fix? I get the sense that contextToken.parent.parent isn't actually a useful node, since the point of the check is simply to do nothing if you're not in the middle of the current class element.

Copy link
Contributor Author

@fuafa fuafa Aug 13, 2019

Choose a reason for hiding this comment

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

But the contextToken.parent.parent is a ClassDeclaration when context.kind === SyntaxKind.SemicolonToken. What I attempt to do is making the /*1*/ and /*2*/ should be in the same context.

class C {
	/*1*/ // `contextToken.parent` is `ClassDeclaration`
	private a = 1;
	/*2*/ // `contextToken.parent` is `PropertyDeclaration`, `contextToken.parent.parent` is `ClassDeclaration`
}

Do I miss something else?

@DanielRosenwasser DanielRosenwasser merged commit c8d937e into microsoft:master Aug 13, 2019
@fuafa fuafa deleted the completion-after-private branch August 16, 2019 11:25
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.

Autocompletion in Classes when Implementing an Interface after Initial Fields
4 participants