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,37 +72,39 @@ 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)
};
// Account for TextArea's block borders (1 for each side) let (cursor_line, cursor_col) = current_cursor;
let block_offset_x = 1;
let block_offset_y = 1;
// Simple positioning: assume trigger is visible and use direct coordinates // Account for TextArea's block borders (1 for each side)
// This works for small scripts but may need improvement for larger ones let block_offset_x = 1;
let visible_line = trigger_line; let block_offset_y = 1;
let visible_col = trigger_col + 1 + add_logic_state.script_editor_filter_text.len();
let input_rect = Rect { // Position autocomplete at current cursor position
x: (inner_area.x + block_offset_x + visible_col as u16).min(inner_area.right().saturating_sub(20)), // Add 1 to column to position dropdown right after the cursor
y: (inner_area.y + block_offset_y + visible_line as u16 + 1).min(inner_area.bottom().saturating_sub(5)), let autocomplete_x = cursor_col + 1;
width: 1, // Minimum width for positioning let autocomplete_y = cursor_line;
height: 1,
};
// Render autocomplete dropdown let input_rect = Rect {
autocomplete::render_autocomplete_dropdown( x: (inner_area.x + block_offset_x + autocomplete_x as u16).min(inner_area.right().saturating_sub(20)),
f, y: (inner_area.y + block_offset_y + autocomplete_y as u16).min(inner_area.bottom().saturating_sub(5)),
input_rect, width: 1, // Minimum width for positioning
f.area(), // Full frame area for clamping height: 1,
theme, };
&add_logic_state.script_editor_suggestions,
add_logic_state.script_editor_selected_suggestion_index, // Render autocomplete dropdown
); autocomplete::render_autocomplete_dropdown(
} f,
input_rect,
f.area(), // Full frame area for clamping
theme,
&add_logic_state.script_editor_suggestions,
add_logic_state.script_editor_selected_suggestion_index,
);
} }
return; // Exit early for fullscreen mode return; // Exit early for fullscreen mode