Compare commits

..

No commits in common. "fdda6ba1a492859425fe5577d3b159bfd4c845b0" and "f077c87dfcc814f0716c1f32a07f005f3d136c89" have entirely different histories.

View file

@ -59,10 +59,6 @@ pub const AutoCompleteState = struct {
@memcpy(self.buffer[0..copy_len], new_text[0..copy_len]);
self.len = copy_len;
self.cursor = copy_len;
// Sync filter to avoid spurious text_changed events
@memcpy(self.last_filter[0..copy_len], new_text[0..copy_len]);
self.last_filter_len = copy_len;
}
/// Clear the input
@ -72,7 +68,6 @@ pub const AutoCompleteState = struct {
self.selected = -1;
self.highlighted = -1;
self.open = false;
self.last_filter_len = 0;
}
/// Insert a single character at cursor
@ -375,28 +370,12 @@ pub fn autocompleteRect(
ctx.pushCommand(Command.text(inner.x, text_y, config.placeholder, Style.Color.rgb(100, 100, 100)));
}
// Draw cursor if focused (same style as TextInput)
// Draw cursor if focused
if (is_focused and !config.disabled) {
// Cursor blink logic (identical to TextInput)
const cursor_visible = blk: {
if (ctx.current_time_ms == 0) break :blk true;
const idle_time = ctx.current_time_ms -| ctx.last_input_time_ms;
if (idle_time >= Context.CURSOR_IDLE_TIMEOUT_MS) {
// Idle: cursor always visible (solid, no blink)
break :blk true;
} else {
// Active: cursor blinks
break :blk (ctx.current_time_ms / Context.CURSOR_BLINK_PERIOD_MS) % 2 == 0;
}
};
if (cursor_visible) {
// Use ctx.measureTextToCursor for accurate cursor positioning with variable-width fonts
const cursor_offset = ctx.measureTextToCursor(filter_text, state.cursor);
const cursor_x = inner.x + @as(i32, @intCast(cursor_offset));
// Full height cursor (inner.h), same as TextInput
ctx.pushCommand(Command.rect(cursor_x, inner.y, 2, inner.h, Style.Color.rgb(200, 200, 200)));
}
// Use ctx.measureTextToCursor for accurate cursor positioning with variable-width fonts
const cursor_offset = ctx.measureTextToCursor(filter_text, state.cursor);
const cursor_x = inner.x + @as(i32, @intCast(cursor_offset));
ctx.pushCommand(Command.rect(cursor_x, text_y, 2, char_height, Style.Color.rgb(200, 200, 200)));
}
// Draw dropdown arrow
@ -424,15 +403,11 @@ pub fn autocompleteRect(
var filtered_indices: [256]usize = undefined;
var filtered_count: usize = 0;
if (options.len == 0) {
state.closeDropdown();
} else {
for (options, 0..) |opt, i| {
if (filtered_count >= filtered_indices.len) break;
if (matchesFilter(opt, filter_text, config.match_mode, config.case_sensitive)) {
filtered_indices[filtered_count] = i;
filtered_count += 1;
}
for (options, 0..) |opt, i| {
if (filtered_count >= filtered_indices.len) break;
if (matchesFilter(opt, filter_text, config.match_mode, config.case_sensitive)) {
filtered_indices[filtered_count] = i;
filtered_count += 1;
}
}