-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Improved autocompletion #135
base: main
Are you sure you want to change the base?
feat: Improved autocompletion #135
Conversation
Hey @uptickmetachu! thanks for your contribution! Let me review it and get back to you. |
@@ -41,6 +40,12 @@ export function LuceneQueryEditor(props: LuceneQueryEditorProps){ | |||
if (!word){ return null } | |||
suggestions = await autocompleter(word?.text); | |||
if (suggestions && suggestions.options.length > 0 ) { | |||
// Fixes autocompletion inserting an extra quote when the cursor is before a quote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to only check that last character?
I don't understand the slice with context.pos
. Can you explain exactly what we want to check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to only check that last character?
I've modified it to check for all characters following the cursor for a double quote instead of just the immediate character.
"quickwit-indexing/src/actors/indexing_pipeline.rs"
Some examples of autocompletion where ↑ is the current cursor position.:
- Example of completing immediately behind a double quote:
events.event_attributes.code.filepath:"quickwit-indexing/src/actors/↑"
- The returned completion would omit the final quote
"quickwit-indexing/src/actors/indexing_pipeline.rs
. - Applying the completion would give us:
events.event_attributes.code.filepath:"quickwit-indexing/src/actors/indexing_pipeline.rs"
- The current behaviour would instead give us:
events.event_attributes.code.filepath:"quickwit-indexing/src/actors/indexing_pipeline.rs""
- Example of completing without quotes:
events.event_attributes.code.filepath:↑
- The returned completion would be surrounded by quotes
"quickwit-indexing/src/actors/indexing_pipeline.rs"
. - Applying the completion would give us:
events.event_attributes.code.filepath:"quickwit-indexing/src/actors/indexing_pipeline.rs"
- Example of completing with whitespace before double quotes:
events.event_attributes.code.filepath:"quickwit-indexing/src/actors/↑ "
- The returned completion would omit the final quote
"quickwit-indexing/src/actors/indexing_pipeline.rs
. - Applying the completion would give us:
events.event_attributes.code.filepath:"quickwit-indexing/src/actors/indexing_pipeline.rs "
which isn't ideal but is better than an extra double quote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check the comments? Thanks!
6db8dc5
to
2cb273f
Compare
2cb273f
to
9a3eea6
Compare
Happy to add a Loom/video recording of the changes in action as well if that helps with the review. |
Not needed, will review it today! thanks! |
Hi first time contribution here :)
My typescript is also bad so please be gentle and suggest feedback where neccessary!
Love quickwit but wanted to try a small PR to see how easy it was to make changes to the plugin and hopefully contribute some more changes in the future.
Motivation
Autocompletion is great but two things bugged me:
span_attributes.filename:"CURSOR_IS_HERE"
the suggestions will be surrounded by quotes. When accepting the suggestion, the final quote is inserted before the ending quote and as such we end up with incorrect syntax ofspan_attributes.filename:"SUGGESTION"" <--extra quote