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

Fix autocomplete suggestion #3554

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rrousselGit
Copy link

fixes #3553

I'll add tests later, assuming that those changes are the correct way to go. I'm not familiar enough with the codebase to know for sure :)

Copy link

changeset-bot bot commented Mar 6, 2024

🦋 Changeset detected

Latest commit: 23d9616

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
graphql-language-service Minor
cm6-graphql Patch
codemirror-graphql Patch
@graphiql/react Patch
graphiql Patch
graphql-language-service-cli Patch
graphql-language-service-server Patch
monaco-graphql Patch
@graphiql/plugin-code-exporter Patch
@graphiql/plugin-explorer Patch
vscode-graphql Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

linux-foundation-easycla bot commented Mar 6, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@acao
Copy link
Member

acao commented Mar 6, 2024

awesome, thank you @rrousselGit! can you add some unit tests for the failing cases?

@rrousselGit
Copy link
Author

Sure! But I'd like to know whether this is the right approach first.

There are a few failing tests, and I'm not necessarily sure why. Do you have any clue on what could possibly be going wrong with this approach?

Copy link
Contributor

@TallTed TallTed left a comment

Choose a reason for hiding this comment

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

human-facing punctuation tweaks, for clarity of comments

) {
return;

/** Returns whether a token is before, at or after the cursor */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/** Returns whether a token is before, at or after the cursor */
/** Returns whether a token is before, at, or after the cursor */

);

if (compare === 'before') {
// The token is before the cursor, keep track of it
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The token is before the cursor, keep track of it
// The token is before the cursor; keep track of it

return;
}

// The token is at or after the cursor, we return the last token before the cursor
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The token is at or after the cursor, we return the last token before the cursor
// The token is at or after the cursor; we return the last token before the cursor

@acao
Copy link
Member

acao commented Mar 7, 2024

@rrousselGit I will have to get back to you on that once I have time to build up a bit more context. Going into the parser takes great delicacy as you can see haha!

I would suggest a TDD approach at first to learn how the parser works, and reading the tests, you can use yarn test --watch at the workspace root and it will run only the impacted/changed unit tests. in general, the tests for the language service are a TDD dream and relatively pure, though I plan to add integration tests to test broader spec expectations than are in the scope of unit tests, mostly to test integration with graphql library itself. So beware that the autocomplete tests are still relatively spec and context/edge case incomplete. Sometimes with unit tests i will test completion/etc at slightly different positions to try to catch edge cases but as you've found there are many!

@acao
Copy link
Member

acao commented Mar 16, 2024

this is causing a lot of undesired regressions it seems. perhaps you can find another place to fix this issue?

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.

[lsp-server] 🐞 Adding whitespaces\newlines causes autocompletion to move up a level
3 participants