patch: fix add_note on a single note in a column

I was earlier relying on there sometimes being a note in Cache that
wasn't (yet) backed by a file. One gotcha less in the code.
This commit is contained in:
Kartik K. Agaram 2022-11-24 09:55:27 -08:00
parent eff2df3fe1
commit 7f2c97f2f7

View File

@ -1019,12 +1019,9 @@ function command.add_note(rel)
if #Surface[Cursor_pane.col] == 1 and not array.find(Non_unique_edges, rel) then
-- column has a single note; turn it into unroll
Surface[Cursor_pane.col] = {name=('%s from %s'):format(rel, pane.id)}
populate_unroll_column(Surface[Cursor_pane.col], pane.id, rel) -- invalidates new_pane
Cursor_pane.row = #Surface[Cursor_pane.col]
Surface[Cursor_pane.col][Cursor_pane.row].editable = true
bring_cursor_column_on_screen()
bring_cursor_of_cursor_pane_in_view('down')
elseif string.match(Surface[Cursor_pane.col].name, rel..' from %S+') then
populate_unroll_column(Surface[Cursor_pane.col], pane.id, rel)
end
if string.match(Surface[Cursor_pane.col].name, rel..' from %S+') then
-- we're unrolling along the same rel; just append to it
-- (we couldn't be inserting in the middle if we didn't return earlier in
-- the function)