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 js completions #15521

Merged
merged 37 commits into from
Feb 13, 2025
Merged

Fix js completions #15521

merged 37 commits into from
Feb 13, 2025

Conversation

adrinr
Copy link
Collaborator

@adrinr adrinr commented Feb 11, 2025

Description

Fixing the way we handle autocomplete for javascript. The current behaviour works fine for fields, but it does not for helpers and snippers. Also, updating the autocomplete package to make use of displayLabel, that will simplify the filter selection.

Helpers

Before, they were displaying as autocomplete options with $(""). This generates outputs such as $("random"), that are not valid. The result should be helpers.random().
image

Screen.Recording.2025-02-11.at.16.33.41.mov

There is no autocomplete for the right helpers.whatever()

After:

  1. there is an autocomplete for helpers.whatever()
  2. helpers will not appear in $("")

Snippets

The same issues we got for autocomplete will occur here. After the changes, we the snippets will be formatted and it will behave as the helpers

Screen.Recording.2025-02-12.at.16.07.57.mov

Final result

Screen.Recording.2025-02-12.at.16.14.00.mov

Helpers

image

It will filter any part of the helper name
image

Snippets

They will be formatted to be aligned with the helpers formats
image

Launchcontrol

Improve javascript bindings autocomplete

Copy link

linear bot commented Feb 11, 2025

Copy link

qa-wolf bot commented Feb 11, 2025

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@github-actions github-actions bot added firestorm Data/Infra/Revenue Team size/m labels Feb 11, 2025
@adrinr adrinr force-pushed the BUDI-9038/fix-js-completions branch from 2205223 to eb1e591 Compare February 11, 2025 09:35
@@ -53,7 +53,7 @@
"@budibase/shared-core": "*",
"@budibase/string-templates": "*",
"@budibase/types": "*",
"@codemirror/autocomplete": "^6.7.1",
"@codemirror/autocomplete": "6.9.0",
Copy link
Collaborator Author

@adrinr adrinr Feb 11, 2025

Choose a reason for hiding this comment

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

Fixing the version, as while trying to get newer ones I got conflicts with the other packages

@adrinr adrinr force-pushed the BUDI-9038/fix-js-completions branch 2 times, most recently from 83f42c8 to 4d56783 Compare February 11, 2025 15:54
@adrinr adrinr force-pushed the BUDI-9038/fix-js-completions branch from 9ded385 to 7c91ce8 Compare February 12, 2025 15:08
@@ -0,0 +1,8 @@
import { CompletionContext, Completion } from "@codemirror/autocomplete"

export type BindingCompletion = (context: CompletionContext) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These types are only used in the builder, and they have dependencies that are not used anywhere else. It makes more sense to live in here that in the types package

@adrinr adrinr marked this pull request as ready for review February 12, 2025 15:22
Copy link
Member

@aptkingston aptkingston left a comment

Choose a reason for hiding this comment

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

Huge value for a reasonably small change! Feels much better to use now. 🚀

I couldn't find any issues other than 1 small one - when you're writing snippets you now get suggestions for helpers, but you can't actually use helpers inside snippets. So we just need to remove those suggestions.

@adrinr
Copy link
Collaborator Author

adrinr commented Feb 13, 2025

Huge value for a reasonably small change! Feels much better to use now. 🚀

I couldn't find any issues other than 1 small one - when you're writing snippets you now get suggestions for helpers, but you can't actually use helpers inside snippets. So we just need to remove those suggestions.

I did try to get it working, as they are not half supported, they need some extra work on the client. To be clear, helpers in snippets currently work for backend bindings (such as formula columns) but don't work for bindings on the design section.
This will just disable the autocomplete, if a snippet is currently using a helpers it will still work.

@adrinr adrinr requested a review from aptkingston February 13, 2025 10:57
Copy link
Member

@aptkingston aptkingston left a comment

Choose a reason for hiding this comment

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

LGTM

@adrinr adrinr enabled auto-merge February 13, 2025 11:09
@adrinr adrinr merged commit 31d375c into master Feb 13, 2025
20 checks passed
@adrinr adrinr deleted the BUDI-9038/fix-js-completions branch February 13, 2025 11:13
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
firestorm Data/Infra/Revenue Team size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants