feat: add autocompleteMaxVisible setting for configurable dropdown height

This commit is contained in:
Colin Mason 2026-01-26 20:02:24 -05:00 committed by Mario Zechner
parent 06a7fedda5
commit b212314f45
8 changed files with 63 additions and 4 deletions

View file

@ -38,6 +38,7 @@ export interface SettingsConfig {
doubleEscapeAction: "fork" | "tree";
showHardwareCursor: boolean;
editorPaddingX: number;
autocompleteMaxVisible: number;
quietStartup: boolean;
}
@ -57,6 +58,7 @@ export interface SettingsCallbacks {
onDoubleEscapeActionChange: (action: "fork" | "tree") => void;
onShowHardwareCursorChange: (enabled: boolean) => void;
onEditorPaddingXChange: (padding: number) => void;
onAutocompleteMaxVisibleChange: (maxVisible: number) => void;
onQuietStartupChange: (enabled: boolean) => void;
onCancel: () => void;
}
@ -300,6 +302,16 @@ export class SettingsSelectorComponent extends Container {
values: ["0", "1", "2", "3"],
});
// Autocomplete max visible toggle (insert after editor-padding)
const editorPaddingIndex = items.findIndex((item) => item.id === "editor-padding");
items.splice(editorPaddingIndex + 1, 0, {
id: "autocomplete-max-visible",
label: "Autocomplete max items",
description: "Max visible items in autocomplete dropdown (3-20)",
currentValue: String(config.autocompleteMaxVisible),
values: ["3", "5", "7", "10", "15", "20"],
});
// Add borders
this.addChild(new DynamicBorder());
@ -348,6 +360,9 @@ export class SettingsSelectorComponent extends Container {
case "editor-padding":
callbacks.onEditorPaddingXChange(parseInt(newValue, 10));
break;
case "autocomplete-max-visible":
callbacks.onAutocompleteMaxVisibleChange(parseInt(newValue, 10));
break;
}
},
callbacks.onCancel,

View file

@ -265,7 +265,11 @@ export class InteractiveMode {
this.widgetContainerBelow = new Container();
this.keybindings = KeybindingsManager.create();
const editorPaddingX = this.settingsManager.getEditorPaddingX();
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, { paddingX: editorPaddingX });
const autocompleteMaxVisible = this.settingsManager.getAutocompleteMaxVisible();
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, {
paddingX: editorPaddingX,
autocompleteMaxVisible,
});
this.editor = this.defaultEditor;
this.editorContainer = new Container();
this.editorContainer.addChild(this.editor as Component);
@ -2978,6 +2982,7 @@ export class InteractiveMode {
doubleEscapeAction: this.settingsManager.getDoubleEscapeAction(),
showHardwareCursor: this.settingsManager.getShowHardwareCursor(),
editorPaddingX: this.settingsManager.getEditorPaddingX(),
autocompleteMaxVisible: this.settingsManager.getAutocompleteMaxVisible(),
quietStartup: this.settingsManager.getQuietStartup(),
},
{
@ -3060,6 +3065,13 @@ export class InteractiveMode {
this.editor.setPaddingX(padding);
}
},
onAutocompleteMaxVisibleChange: (maxVisible) => {
this.settingsManager.setAutocompleteMaxVisible(maxVisible);
this.defaultEditor.setAutocompleteMaxVisible(maxVisible);
if (this.editor !== this.defaultEditor && this.editor.setAutocompleteMaxVisible !== undefined) {
this.editor.setAutocompleteMaxVisible(maxVisible);
}
},
onCancel: () => {
done();
this.ui.requestRender();