Preferred x bug fixed

master
Allen Webster 2019-10-08 12:16:20 -07:00
parent de6429a2a1
commit 4668adbca4
3 changed files with 6 additions and 4 deletions

View File

@ -154,7 +154,7 @@ edit_fix_markers(Models *models, Editing_File *file, Edit edit){
i64 cursor_pos = cursors[cursor_count++].pos; i64 cursor_pos = cursors[cursor_count++].pos;
view->mark = cursors[cursor_count++].pos; view->mark = cursors[cursor_count++].pos;
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
view_set_cursor_and_scroll(models, view, cursor_pos, true, edit_pos.scroll); view_set_cursor_and_scroll(models, view, cursor_pos, edit_pos.scroll);
} }
} }

View File

@ -347,10 +347,12 @@ view_set_scroll(Models *models, View *view, Buffer_Scroll scroll){
} }
internal void internal void
view_set_cursor_and_scroll(Models *models, View *view, i64 pos, b32 set_preferred_x, Buffer_Scroll scroll){ view_set_cursor_and_scroll(Models *models, View *view, i64 pos, Buffer_Scroll scroll){
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
file_edit_positions_set_cursor(&edit_pos, pos); file_edit_positions_set_cursor(&edit_pos, pos);
view->preferred_x = 0.f; Buffer_Cursor cursor = view_compute_cursor(view, seek_pos(pos));
Vec2_f32 p = view_relative_xy_of_pos(models, view, cursor.line, pos);
view->preferred_x = p.x;
file_edit_positions_set_scroll(&edit_pos, scroll); file_edit_positions_set_scroll(&edit_pos, scroll);
edit_pos.last_set_type = EditPos_None; edit_pos.last_set_type = EditPos_None;
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);

View File

@ -5,7 +5,7 @@ moving the cursor, which work even without the default 4coder framework.
// TOP // TOP
static void function void
write_character_parameter(Application_Links *app, u8 *character, u32 length){ write_character_parameter(Application_Links *app, u8 *character, u32 length){
if (length != 0){ if (length != 0){
View_ID view = get_active_view(app, AccessOpen); View_ID view = get_active_view(app, AccessOpen);