Wire up completion keyboard navigation and add AGENTS.md
- Tab/Enter confirms the selected completion item - Up/Down arrows navigate the completion menu - Escape dismisses the menu (via existing dismiss_lsp_overlays) - Editor intercepts keys via completion_intercept_keys flag when menu is showing - Add AGENTS.md with LLM-powered predictive autocomplete idea Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
a75bc99852
commit
d421b9583f
@@ -153,6 +153,12 @@ pub enum CodeEditorEvent {
|
||||
VimGotoDefinition,
|
||||
VimFindReferences,
|
||||
VimShowHover,
|
||||
/// Emitted when Up is pressed and completion_intercept_keys is active.
|
||||
CompletionNavigateUp,
|
||||
/// Emitted when Down is pressed and completion_intercept_keys is active.
|
||||
CompletionNavigateDown,
|
||||
/// Emitted when Tab/Enter is pressed and completion_intercept_keys is active.
|
||||
CompletionConfirm,
|
||||
}
|
||||
|
||||
/// Store all states related to displaying the editor content.
|
||||
@@ -284,6 +290,9 @@ pub struct CodeEditorView {
|
||||
/// The offset where find references card is anchored (if showing).
|
||||
find_references_anchor_offset: Option<CharOffset>,
|
||||
window_id: WindowId,
|
||||
/// When true, Up/Down/Tab/Enter are redirected to completion events instead of
|
||||
/// normal editor behavior. Set by the parent when a completion menu is visible.
|
||||
pub completion_intercept_keys: bool,
|
||||
}
|
||||
|
||||
impl CodeEditorView {
|
||||
@@ -427,6 +436,7 @@ impl CodeEditorView {
|
||||
show_find_references_provider: render_options.show_find_references_provider,
|
||||
find_references_anchor_offset: None,
|
||||
window_id: ctx.window_id(),
|
||||
completion_intercept_keys: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -805,6 +805,28 @@ impl TypedActionView for CodeEditorView {
|
||||
return;
|
||||
}
|
||||
|
||||
// When completion menu is active, redirect navigation/confirm keys to the parent.
|
||||
if self.completion_intercept_keys {
|
||||
match action {
|
||||
MoveUp => {
|
||||
ctx.emit(super::CodeEditorEvent::CompletionNavigateUp);
|
||||
return;
|
||||
}
|
||||
MoveDown => {
|
||||
ctx.emit(super::CodeEditorEvent::CompletionNavigateDown);
|
||||
return;
|
||||
}
|
||||
Tab | Enter => {
|
||||
ctx.emit(super::CodeEditorEvent::CompletionConfirm);
|
||||
return;
|
||||
}
|
||||
Escape => {
|
||||
// Let escape fall through to normal handling (which emits EscapePressed)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
match action {
|
||||
UserTyped(content) => self.user_insert(content, ctx),
|
||||
VimUserTyped(content) => {
|
||||
|
||||
Reference in New Issue
Block a user