This commit is contained in:
pavel 2026-07-09 08:27:13 +02:00
commit 985aa16236
13 changed files with 1381 additions and 241 deletions

View file

@ -207,7 +207,14 @@ editor_insert_text :: proc(active: ^Editor_Buffer, text: string) {
editor_update_dirty :: proc(active: ^Editor_Buffer) {
if active == nil do return
active.dirty = active.buffer.version != active.saved_version
if active.buffer.version == active.saved_version {
active.dirty = false
return
}
text := buffer_bytes(&active.buffer)
defer delete(text)
active.dirty = !bytes_equal(text[:], active.original_storage[:])
}
editor_outdent :: proc(active: ^Editor_Buffer) -> bool {
@ -300,6 +307,9 @@ editor_save_active :: proc(editor: ^Editor) -> bool {
return false
}
delete(active.original_storage)
saved_text := clone_bytes(text[:])
active.original_storage = saved_text[:]
active.saved_version = active.buffer.version
active.dirty = false
return true
@ -317,6 +327,9 @@ editor_save_all :: proc(editor: ^Editor) -> bool {
fmt.println("save failed:", buffer.path, err)
ok = false
} else {
delete(buffer.original_storage)
saved_text := clone_bytes(text[:])
buffer.original_storage = saved_text[:]
buffer.saved_version = buffer.buffer.version
buffer.dirty = false
}