Skip to content

fix: user's cursor can be offset for autocompletion #161

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

Conversation

juleswritescode
Copy link
Collaborator

@juleswritescode juleswritescode commented Dec 17, 2024

Suppose we have an incomplete query and the user's cursor is too far off:

select * from {}

In that case, we couldn't walk the tree-sitter tree.
When we tried to go to the child node at the cursor position, tree-sitter would stay on the PROGRAM node (every tree's head) which lead to unexpected contexts and infinite recursion.

That's now fixed! We simply "move the cursor" to the previous node:

select * from {} becomes select * from{}.

Note: Treesitter is already able to deal with {} select * from.

Some additional stuff:

  • added a tree-print script to the justfile (that's much cooler than Makefile, btw)
  • adjusted and used some test-helpers, adjusted the tree_print binary to ignore newlines

Copy link
Collaborator

@psteinroe psteinroe left a comment

Choose a reason for hiding this comment

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

great work!!

@psteinroe psteinroe merged commit e3bc0c2 into supabase-community:main Dec 17, 2024
1 check passed
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