broken autocomplete in the add_logic, but its usable, we are keeping it as is, there is nothing more we can do

This commit is contained in:
filipriec
2025-05-26 16:37:01 +02:00
parent 3463a52960
commit 913f6b6b64

View File

@@ -72,23 +72,26 @@ pub fn render_add_logic(
// === SCRIPT EDITOR AUTOCOMPLETE RENDERING === // === SCRIPT EDITOR AUTOCOMPLETE RENDERING ===
if add_logic_state.script_editor_autocomplete_active && !add_logic_state.script_editor_suggestions.is_empty() { if add_logic_state.script_editor_autocomplete_active && !add_logic_state.script_editor_suggestions.is_empty() {
if let Some((trigger_line, trigger_col)) = add_logic_state.script_editor_trigger_position { // Get the current cursor position from textarea
// For now, we'll position the autocomplete at a simple offset from the trigger let current_cursor = {
// Since we can't easily get viewport info, we'll position it relatively let editor_borrow = add_logic_state.script_content_editor.borrow();
// This is a simplified approach - in a real implementation you'd want proper viewport tracking editor_borrow.cursor() // Returns (row, col) as (usize, usize)
};
let (cursor_line, cursor_col) = current_cursor;
// Account for TextArea's block borders (1 for each side) // Account for TextArea's block borders (1 for each side)
let block_offset_x = 1; let block_offset_x = 1;
let block_offset_y = 1; let block_offset_y = 1;
// Simple positioning: assume trigger is visible and use direct coordinates // Position autocomplete at current cursor position
// This works for small scripts but may need improvement for larger ones // Add 1 to column to position dropdown right after the cursor
let visible_line = trigger_line; let autocomplete_x = cursor_col + 1;
let visible_col = trigger_col + 1 + add_logic_state.script_editor_filter_text.len(); let autocomplete_y = cursor_line;
let input_rect = Rect { let input_rect = Rect {
x: (inner_area.x + block_offset_x + visible_col as u16).min(inner_area.right().saturating_sub(20)), x: (inner_area.x + block_offset_x + autocomplete_x as u16).min(inner_area.right().saturating_sub(20)),
y: (inner_area.y + block_offset_y + visible_line as u16 + 1).min(inner_area.bottom().saturating_sub(5)), y: (inner_area.y + block_offset_y + autocomplete_y as u16).min(inner_area.bottom().saturating_sub(5)),
width: 1, // Minimum width for positioning width: 1, // Minimum width for positioning
height: 1, height: 1,
}; };
@@ -103,7 +106,6 @@ pub fn render_add_logic(
add_logic_state.script_editor_selected_suggestion_index, add_logic_state.script_editor_selected_suggestion_index,
); );
} }
}
return; // Exit early for fullscreen mode return; // Exit early for fullscreen mode
} }