From 0d3db19c854cc70b82e9935c7ae8f6ad6986d89f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 3 Dec 2023 10:29:24 -0800 Subject: clearing starty is redundant in mutations We'll end up calling Text.redraw_all anyway, which will clear starty and much more besides. We'll still conservatively continue clearing starty in a few places where there's a possibility that Text.redraw_all may not be called. This change is riskier than most. --- edit.lua | 5 ----- source_edit.lua | 5 ----- 2 files changed, 10 deletions(-) diff --git a/edit.lua b/edit.lua index 0e552b7..cfc1478 100644 --- a/edit.lua +++ b/edit.lua @@ -380,7 +380,6 @@ function edit.text_input(State, t) else local drawing_index, drawing = Drawing.current_drawing(State) if drawing_index == nil then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll Text.text_input(State, t) end end @@ -438,7 +437,6 @@ function edit.keychord_press(State, chord, key) Text.redraw_all(State) -- undo elseif chord == 'C-z' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll local event = undo_event(State) if event then local src = event.before @@ -454,7 +452,6 @@ function edit.keychord_press(State, chord, key) schedule_save(State) end elseif chord == 'C-y' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll local event = redo_event(State) if event then local src = event.after @@ -478,14 +475,12 @@ function edit.keychord_press(State, chord, key) App.set_clipboard(s) end elseif chord == 'C-x' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll local s = Text.cut_selection(State, State.left, State.right) if s then App.set_clipboard(s) end schedule_save(State) elseif chord == 'C-v' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll -- We don't have a good sense of when to scroll, so we'll be conservative -- and sometimes scroll when we didn't quite need to. local before_line = State.cursor1.line diff --git a/source_edit.lua b/source_edit.lua index 9d37466..40af2e8 100644 --- a/source_edit.lua +++ b/source_edit.lua @@ -384,7 +384,6 @@ function edit.text_input(State, t) else local drawing_index, drawing = Drawing.current_drawing(State) if drawing_index == nil then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll Text.text_input(State, t) end end @@ -442,7 +441,6 @@ function edit.keychord_press(State, chord, key) Text.redraw_all(State) -- undo elseif chord == 'C-z' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll local event = undo_event(State) if event then local src = event.before @@ -458,7 +456,6 @@ function edit.keychord_press(State, chord, key) schedule_save(State) end elseif chord == 'C-y' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll local event = redo_event(State) if event then local src = event.after @@ -482,14 +479,12 @@ function edit.keychord_press(State, chord, key) App.set_clipboard(s) end elseif chord == 'C-x' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll local s = Text.cut_selection(State, State.left, State.right) if s then App.set_clipboard(s) end schedule_save(State) elseif chord == 'C-v' then - for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll -- We don't have a good sense of when to scroll, so we'll be conservative -- and sometimes scroll when we didn't quite need to. local before_line = State.cursor1.line -- cgit 1.4.1-2-gfad0