fix: every_keystroke completion mode should fallback to automatic when active

This prevents `every_keystroke` mode from re-triggering on every keystroke if a completion
suggestions are already available. Instead it will now filter the returned suggestions
normally. This dramatically reduces load on the LSP.

closes #479
This commit is contained in:
CJ van den Berg 2026-02-01 18:12:51 +01:00
parent f35e522260
commit 01cbdf8545
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -6552,7 +6552,15 @@ pub const Editor = struct {
}
pub fn run_triggers(self: *Self, cursel: *const CurSel, char: u8, event: TriggerEvent) void {
switch (tui.config().completion_trigger) {
var mode = tui.config().completion_trigger;
if (mode == .every_keystroke) {
const update_completion = "update_completion";
const in_completion = command.get_id(update_completion) != null;
mode = if (in_completion) .automatic else .every_keystroke;
}
switch (mode) {
.manual => return,
.every_keystroke => return self.run_triggers_every_keystroke(cursel, char, event),
.automatic => {},