mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 17:01:02 +00:00
feat: add autocompleteMaxVisible setting for configurable dropdown height
This commit is contained in:
parent
06a7fedda5
commit
b212314f45
8 changed files with 63 additions and 4 deletions
|
|
@ -146,6 +146,7 @@ export interface EditorTheme {
|
|||
|
||||
export interface EditorOptions {
|
||||
paddingX?: number;
|
||||
autocompleteMaxVisible?: number;
|
||||
}
|
||||
|
||||
export class Editor implements Component, Focusable {
|
||||
|
|
@ -176,6 +177,7 @@ export class Editor implements Component, Focusable {
|
|||
private autocompleteList?: SelectList;
|
||||
private autocompleteState: "regular" | "force" | null = null;
|
||||
private autocompletePrefix: string = "";
|
||||
private autocompleteMaxVisible: number = 5;
|
||||
|
||||
// Paste tracking for large pastes
|
||||
private pastes: Map<number, string> = new Map();
|
||||
|
|
@ -207,6 +209,8 @@ export class Editor implements Component, Focusable {
|
|||
this.borderColor = theme.borderColor;
|
||||
const paddingX = options.paddingX ?? 0;
|
||||
this.paddingX = Number.isFinite(paddingX) ? Math.max(0, Math.floor(paddingX)) : 0;
|
||||
const maxVisible = options.autocompleteMaxVisible ?? 5;
|
||||
this.autocompleteMaxVisible = Number.isFinite(maxVisible) ? Math.max(3, Math.min(20, Math.floor(maxVisible))) : 5;
|
||||
}
|
||||
|
||||
getPaddingX(): number {
|
||||
|
|
@ -221,6 +225,18 @@ export class Editor implements Component, Focusable {
|
|||
}
|
||||
}
|
||||
|
||||
getAutocompleteMaxVisible(): number {
|
||||
return this.autocompleteMaxVisible;
|
||||
}
|
||||
|
||||
setAutocompleteMaxVisible(maxVisible: number): void {
|
||||
const newMaxVisible = Number.isFinite(maxVisible) ? Math.max(3, Math.min(20, Math.floor(maxVisible))) : 5;
|
||||
if (this.autocompleteMaxVisible !== newMaxVisible) {
|
||||
this.autocompleteMaxVisible = newMaxVisible;
|
||||
this.tui.requestRender();
|
||||
}
|
||||
}
|
||||
|
||||
setAutocompleteProvider(provider: AutocompleteProvider): void {
|
||||
this.autocompleteProvider = provider;
|
||||
}
|
||||
|
|
@ -1734,7 +1750,7 @@ export class Editor implements Component, Focusable {
|
|||
|
||||
if (suggestions && suggestions.items.length > 0) {
|
||||
this.autocompletePrefix = suggestions.prefix;
|
||||
this.autocompleteList = new SelectList(suggestions.items, 5, this.theme.selectList);
|
||||
this.autocompleteList = new SelectList(suggestions.items, this.autocompleteMaxVisible, this.theme.selectList);
|
||||
this.autocompleteState = "regular";
|
||||
} else {
|
||||
this.cancelAutocomplete();
|
||||
|
|
@ -1803,7 +1819,7 @@ https://github.com/EsotericSoftware/spine-runtimes/actions/runs/19536643416/job/
|
|||
}
|
||||
|
||||
this.autocompletePrefix = suggestions.prefix;
|
||||
this.autocompleteList = new SelectList(suggestions.items, 5, this.theme.selectList);
|
||||
this.autocompleteList = new SelectList(suggestions.items, this.autocompleteMaxVisible, this.theme.selectList);
|
||||
this.autocompleteState = "force";
|
||||
} else {
|
||||
this.cancelAutocomplete();
|
||||
|
|
@ -1836,7 +1852,7 @@ https://github.com/EsotericSoftware/spine-runtimes/actions/runs/19536643416/job/
|
|||
if (suggestions && suggestions.items.length > 0) {
|
||||
this.autocompletePrefix = suggestions.prefix;
|
||||
// Always create new SelectList to ensure update
|
||||
this.autocompleteList = new SelectList(suggestions.items, 5, this.theme.selectList);
|
||||
this.autocompleteList = new SelectList(suggestions.items, this.autocompleteMaxVisible, this.theme.selectList);
|
||||
} else {
|
||||
this.cancelAutocomplete();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue