From 8ec1859f567960c74cbc9d9e59657d44c06658fe Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Fri, 28 Apr 2023 06:50:23 +1200 Subject: [PATCH] Fix a couple of crashes. --- LOG.md | 19 +++++++++---------- src/main.jai | 4 ++-- src/widgets/open_file_dialog.jai | 14 ++++++++++---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/LOG.md b/LOG.md index d2e7e8578..cd4c06ee4 100644 --- a/LOG.md +++ b/LOG.md @@ -14,11 +14,8 @@ =========================== -+ Save All -+ BUG: crash when trying to delete line near the top -- BUG: crash when trying to open the newly created file - -- Switch project +- Don't skip spaces when editing with multiple cursors +- Show default config (readonly) - Line wrap: - Sticky viewport @@ -27,17 +24,13 @@ - Have a maximum allowed line length (then force a line wrap, but with a possibility to disable and face the consequences) - Inspect all places where we use line_starts and consider using real_line_starts (with a switch?) -- Don't skip spaces when editing with multiple cursors - -- Drop a folder into the editor to add it to workspace - - Make sure behaviour is consistent when selecting by cursor or by mouse (either with ctrl+D or with ctrl+arrows) - Highlight C/C++ -- Detect conflicting keys in the same context in the same config - Use keyboard in the confirmation dialog +- Drop a folder into the editor to add it to workspace - Highlight matching braces @@ -59,6 +52,8 @@ - Ignore project folders which are children of another project folder? - Profile the whole project to see if we're doing something stupid +- Detect conflicting keys in the same context in the same config + - Add horizontal scrollbar - Alt-HL smooth scroll @@ -146,6 +141,10 @@ - Investigate a crash when font size is too large - copy glyph to buffer segfaults # DONE ++ BUG: crash when trying to open the newly created file ++ Save All ++ BUG: crash when trying to delete line near the top ++ Switch project + Open projects folder + Open global config + Open project config diff --git a/src/main.jai b/src/main.jai index c006d450a..8ee2098f0 100644 --- a/src/main.jai +++ b/src/main.jai @@ -1,5 +1,5 @@ -VERSION :: "0.1.0"; -RELEASE_DATE :: "26 April 2023"; +VERSION :: "0.1.1"; +RELEASE_DATE :: "28 April 2023"; main :: () { cpu_info = get_cpu_info(); diff --git a/src/widgets/open_file_dialog.jai b/src/widgets/open_file_dialog.jai index 25de30e87..b58315f88 100644 --- a/src/widgets/open_file_dialog.jai +++ b/src/widgets/open_file_dialog.jai @@ -92,8 +92,12 @@ open_file_dialog_open_entry :: (selected: s64, placement: Editor_Placement, fold case .file; if folder_only return; - path := entry.full_path; - editors_open_file(path, placement); + if entry.buffer_id >= 0 { + editors_open_buffer(entry.buffer_id, placement); + } else { + path := entry.full_path; + editors_open_file(path, placement); + } hide_open_file_dialog(); case .drive; @@ -272,7 +276,7 @@ refresh_entries :: (scan_folder := false) { // This bit will be set when we want to make sure an entry appears on top top_priority_bit: u64 = 1 << 62; // NOT the topmost bit because we'll be converting to s64 later - for buffer : open_buffers { + for buffer, buffer_id : open_buffers { if buffer.deleted && !buffer.modified continue; // NOTE: we might still want to see externally deleted buffers. // Maybe use 'deleted' and 'modified_on_disk' to distingiush the buffers // we haven't deleted ourselves? @@ -286,6 +290,7 @@ refresh_entries :: (scan_folder := false) { if score < 0 continue; entry := array_add(*entries.filtered); + entry.buffer_id = buffer_id; entry.file = buffer.file; entry.entry_name = buffer_name; if !buffer.has_file { @@ -430,8 +435,9 @@ Open_File_Dialog :: struct { #scope_file Entry :: struct { + buffer_id := -1; // not all entries have buffers using file: File_Info; - flags: enum_flags u8 { + flags: enum_flags u8 { // TODO: remove and just use the buffer pointer, now it should be safe MODIFIED; MODIFIED_ON_DISK; }