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