Skip to content

Revise Copilot triggers. Request completion on demand#1

Open
verte-zerg wants to merge 19 commits intoAlexanderDickie:copilotfrom
verte-zerg:copilot
Open

Revise Copilot triggers. Request completion on demand#1
verte-zerg wants to merge 19 commits intoAlexanderDickie:copilotfrom
verte-zerg:copilot

Conversation

@verte-zerg
Copy link
Copy Markdown

  • request completion on demand after pressing copilot_show_completion
  • enable iteration over completions by pressing copilot_show_completion again
  • trigger copilot completion request after inserting a new line

pascalkuthe and others added 19 commits March 23, 2024 20:14
being able to add/subtract positions is very handy when writing rendering code
The line annotation as implemented in helix-editor#5420 had two shortcomings:
* It required the height of virtual text lines to be known ahead time
* It checked for line anchors at every grapheme

The first problem made the API impractical to use in practice because
almost all virtual text needs to be softwrapped. For example inline
diagnostics should be softwrapped to avoid cutting off the diagnostic
message (as no scrolling is possible). While more complex virtual text
like side by side diffs must dynamically calculate the number of empty
lines two align two documents (which requires taking account both
softwrap and virtual text). To address this, the API has been
refactored to use a trait.

The second issue caused some performance overhead and unnecessarily
complicated the `DocumentFormatter`. It was addressed by only calling
the trait mentioned above at line breaks (instead of always). This
allows offers additional flexibility to annotations as it offers
the flexibility to align lines (needed for side by side diffs).
This commit brings the text decoration API inline with the
LineAnnotation API (so they are consistent) resulting in a single
streamlined API instead of multiple ADHOK callbacks.
@AlexanderDickie
Copy link
Copy Markdown
Owner

Hi, thanks for the pr!
Ive made some refactors to my branch so that completions are now requested when the user enters insert mode, and when the document changes while in insert mode. So this new condition means a completion will now be triggered when inserting a new line and some more instances where completions weren’t previously requested (eg deleting a character, applying a regular completion).

Given this do you think it’s still necessary that copilot_show_completion will trigger a completion? Since because you’ll be in insert mode when calling this command, my refactor above will have now mean that a completion will already have been requested for the same doc state.

The completion iteration function should be added, I would also like the ability to hide a completion too, eg either have copilot_show_completion show no completion after cycling past the final completion, or include a second function which cycles backwards eg copilot_decrement_or_hide_completion?

Please feel free to make other suggestions/prs for improvements, I havent been using this branch much (I mainly use c# atm which I cant use with helix as there is no good lsp) so Im interested how you find this

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.

3 participants