Mercurial Hosting > editor
changeset 67:2c050fcf2614 default tip
add document count
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 06 Jun 2025 18:59:44 -0600 |
parents | d10058fd247d |
children | |
files | src/luan_editor/Window.luan |
diffstat | 1 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
diff -r d10058fd247d -r 2c050fcf2614 src/luan_editor/Window.luan --- a/src/luan_editor/Window.luan Fri Jun 06 10:46:07 2025 -0600 +++ b/src/luan_editor/Window.luan Fri Jun 06 18:59:44 2025 -0600 @@ -148,11 +148,13 @@ if document ~= nil then text_area.document = document elseif file ~= nil then - local document = documents[title] - if document ~= nil then - text_area.document = document + local document_info = documents[title] + if document_info ~= nil then + text_area.document = document_info.document + document_info.count = document_info.count + 1 else - documents[title] = text_area.document + document_info = { document = text_area.document, count = 1 } + documents[title] = document_info if file.exists() then text_area.text = file.read_text() text_area.document.clear_unedited() @@ -197,6 +199,11 @@ Luan.exit() end remove_list_window_item(list_window_item) + local document_info = documents[title] or error() + document_info.count = document_info.count - 1 + if document_info.count == 0 then + documents[title] = nil + end end) frame.add_window_focus_listener(function() list_view.selected_value = list_window_item @@ -252,7 +259,7 @@ return false end title = file.canonical().to_string() - documents[title] = text_area.document + documents[title] = { document = text_area.document, count = 1 } window.is_unedited = nil undo_listener() end