silently ignore captures without edit on restart

This commit is contained in:
Kartik K. Agaram 2022-08-11 11:05:38 -07:00
parent 24fe137492
commit c11dfcacd1

View File

@ -451,12 +451,36 @@ function run_command_with_args(cmd_with_args)
end
-- commands that create columns also need to be recreatable from a title
-- I'm assuming that special columns have multiple words, and single-word
-- columns are always filenames. pensieve.love won't ever create filenames
-- containing spaces.
function create_column(column_name)
if file_exists(Directory..column_name) then
local column = {name=column_name}
local pane = load_pane(column_name)
table.insert(column, pane)
table.insert(Surface, column)
elseif not column_name:find(' ') then
-- File not found
--
-- It makes me nervous to silently drop errors, but at this point there's
-- really nothing actionable someone can do in response to an error.
--
-- Deeper issue: no way yet to communicate errors in the UI.
--
-- Philosophical question: what does crash-only mean if you ever run into
-- data loss? There's a hard tension between resilience and silent failures.
--
-- For now I'm going to rely on all my protections against data loss
-- elsewhere. Lines.love has never lost my data in several months of use.
--
-- While data loss seems unlikely, there _is_ a legitimate way you can end
-- up with a filename that doesn't exist: start a capture, then change
-- your mind and never type anything into it. It will continue to show as
-- a column on the surface, but there's no file backing it. You can still
-- edit it later and create a file for it. But if you just quit, the
-- column will silently disappear after restart.
print('file not found: '..column_name)
else
-- delegate to one of various helpers based on the column name
local column = {name=column_name}