feat: add configuration option dropdown_limit to limit completion dropdown size
This commit is contained in:
parent
35563822ba
commit
d2081e8d68
3 changed files with 17 additions and 6 deletions
|
|
@ -86,6 +86,7 @@ lsp_output: enum { quiet, verbose } = .quiet,
|
||||||
|
|
||||||
keybind_mode: KeybindMode = .normal,
|
keybind_mode: KeybindMode = .normal,
|
||||||
dropdown_keybinds: DropdownKeybindMode = .standard,
|
dropdown_keybinds: DropdownKeybindMode = .standard,
|
||||||
|
dropdown_limit: usize = 12,
|
||||||
|
|
||||||
include_files: []const u8 = "",
|
include_files: []const u8 = "",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6424,7 +6424,7 @@ pub const Editor = struct {
|
||||||
} else {
|
} else {
|
||||||
self.completions_request = .pending(cursor.row, cursor.col);
|
self.completions_request = .pending(cursor.row, cursor.col);
|
||||||
}
|
}
|
||||||
if (!mv.is_any_panel_view_showing())
|
if (tui.config().completion_info_mode == .panel) if (!mv.is_any_panel_view_showing())
|
||||||
self.clamp_offset(mv.get_panel_height());
|
self.clamp_offset(mv.get_panel_height());
|
||||||
return self.pm_with_primary_cursor_pos(project_manager.completion);
|
return self.pm_with_primary_cursor_pos(project_manager.completion);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,10 @@ pub fn Create(options: type) type {
|
||||||
}),
|
}),
|
||||||
.logger = log.logger(@typeName(Self)),
|
.logger = log.logger(@typeName(Self)),
|
||||||
.query = .empty,
|
.query = .empty,
|
||||||
.view_rows = get_view_rows(tui.screen()),
|
.view_rows = @min(
|
||||||
|
get_view_rows(tui.screen()),
|
||||||
|
tui.config().dropdown_limit + self.menu.header_count,
|
||||||
|
),
|
||||||
.entries = .empty,
|
.entries = .empty,
|
||||||
.mode = try keybind.mode(switch (tui.config().dropdown_keybinds) {
|
.mode = try keybind.mode(switch (tui.config().dropdown_keybinds) {
|
||||||
.standard => "overlay/dropdown",
|
.standard => "overlay/dropdown",
|
||||||
|
|
@ -163,7 +166,10 @@ pub fn Create(options: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_resize_at_y_x(self: *Self, screen: Widget.Box, w: usize, y: usize, x: usize) Widget.Box {
|
fn prepare_resize_at_y_x(self: *Self, screen: Widget.Box, w: usize, y: usize, x: usize) Widget.Box {
|
||||||
self.view_rows = get_view_rows(screen) -| y;
|
self.view_rows = @min(
|
||||||
|
get_view_rows(screen) -| y,
|
||||||
|
tui.config().dropdown_limit + self.menu.header_count,
|
||||||
|
);
|
||||||
const h = @min(self.items + self.menu.header_count, self.view_rows + self.menu.header_count);
|
const h = @min(self.items + self.menu.header_count, self.view_rows + self.menu.header_count);
|
||||||
return .{ .y = y, .x = x, .w = w, .h = h };
|
return .{ .y = y, .x = x, .w = w, .h = h };
|
||||||
}
|
}
|
||||||
|
|
@ -193,9 +199,13 @@ pub fn Create(options: type) type {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_view_rows(screen: Widget.Box) usize {
|
fn get_view_rows(screen: Widget.Box) usize {
|
||||||
var h = screen.h;
|
if (tui.config().completion_info_mode == .panel) {
|
||||||
if (h > 0) h = h / 5 * 4;
|
var h = screen.h;
|
||||||
return h;
|
if (h > 0) h = h / 5 * 4;
|
||||||
|
return h;
|
||||||
|
} else {
|
||||||
|
return screen.h;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_scroll(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!void {
|
fn on_scroll(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue