Trigger Completion Generation On Cell Execution #1775
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trigger Completion Generation On Cell Execution
This PR hooks into the runner code execution path to trigger completion generation when a cell finishes execution.
This works for both interactive and non-interactive cells.
This reverts the approach taken in #1744 of intercepting the OnDocumentChangeEvent and goes with the alternative approach of triggering events from _doExecuteCell. We use the event reporter which is already reporting executions to Foyle to also trigger completions.
The problem with relying on vscode DocumentChangeEvents is that it only works for non-interactive cells. For interactive cells, Runme uses a custom renderer to show an xterm.js widget for the terminal. As a result, we don't trigger vscode DocumentChangeEvents when the outputs get updated.
The approach of using doExecuteCell to trigger completions works for both interactive and non-interactive cells. Previously, the outputs for interactive cells wasn't included was due to a bug fixed in #1756.
In the current PR, completions are only generated when a cell completes execution. This means for long running commands (e.g.
kubectl get pods -w
) we wouldn't periodically generate completions as the output changes. I think that's a bit of an edge case that we don't need to support yet. The current approach should extend well to that use case because we are using the event reporter to trigger completions and @sourishkrout recently added an RXJS queue inside event reporter. So we are well setup to enqueuing updates on the client and debouncing them.Other Fixes
Include the CELL_TRIGGER enum in Foyle completion requests. I think I dropped when resolving some of the merge conflicts.
Fix jlewi/foyle#309