Skip to content

fix: Hover docs were offset one position - #3149

Merged
acao merged 2 commits into
graphql:mainfrom
mskelton:fix-off-by-one
Jun 11, 2023
Merged

acao merged 2 commits into
graphql:mainfrom
mskelton:fix-off-by-one

Conversation

@mskelton

Copy link
Copy Markdown
Contributor

Fixes #2874

The hover docs were off by one position. This was due to autocomplete suggestions and hover docs using the same getTokenAtPosition function. For autocomplete, the behavior of the function was expected since your cursor is after the token you want to get when requesting autocomplete results, but with hover docs you want the cursor at the cursor position.

@changeset-bot

changeset-bot Bot commented Apr 21, 2023 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d4ea78

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

This PR includes changesets to release 10 packages
Name Type
graphql-language-service Patch
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-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

@linux-foundation-easycla

linux-foundation-easycla Bot commented Apr 21, 2023 •

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: mskelton / name: Mark Skelton (8441b79)

@acao

acao commented May 10, 2023

Copy link
Copy Markdown
Contributor

@mskelton thanks for this! can you check that the hover positions for codemirror-graphql and monaco-graphql are still correct after this change? I know in monaco-graphql we re-use this method for certain, and the way that monaco and LSP server offsets work are slightly different, the former being base 1 and the latter base 0 if I recall offhand. you could test with the examples/monaco-graphql-webpack example

@acao
acao force-pushed the fix-off-by-one branch from 0aaee79 to 3a9463a Compare May 11, 2023 09:44
@mskelton

Copy link
Copy Markdown
Contributor Author

@acao I tried running the monoco-graphql-webpack example, but hovering didn't display any sort of information, so I'm not exactly sure how to validate it worked/didn't. I noticed the same behavior on main as well, so I'm a little confused.

@acao

acao commented Jun 11, 2023

Copy link
Copy Markdown
Contributor

ohhh it's off by one character not by one line. sorry it took me so long to look closely at this. ok, we don't need to worry as much about the other implementations

@acao
acao merged commit d9e5089 into graphql:main Jun 11, 2023
@acao acao mentioned this pull request Jun 11, 2023
@acao

acao commented Jun 16, 2023

Copy link
Copy Markdown
Contributor

@mskelton in case you're wondering, this will be released in an alpha first, before we return to stable state, because graphiql@3 is coming!

#3219

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] Off by one error in hover information location

3 participants