line.y -> line_cache.starty in a few more places
Disquieting that none of my tests caught these. On the other hand, I also haven't noticed any issues in practice. Perhaps cache invalidation is often unnecessary.
This commit is contained in:
parent
48162b9816
commit
4ce716fe44
16
edit.lua
16
edit.lua
|
@ -286,7 +286,7 @@ function edit.mouse_released(State, x,y, mouse_button)
|
|||
end
|
||||
|
||||
function edit.textinput(State, t)
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll
|
||||
if State.search_term then
|
||||
State.search_term = State.search_term..t
|
||||
State.search_text = nil
|
||||
|
@ -350,7 +350,7 @@ function edit.keychord_pressed(State, chord, key)
|
|||
edit.update_font_settings(State, 20)
|
||||
Text.redraw_all(State)
|
||||
elseif chord == 'C-z' then
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
for _,line in ipairs(State.lines) do line.starty = nil end -- just in case we scroll
|
||||
local event = undo_event(State)
|
||||
if event then
|
||||
local src = event.before
|
||||
|
@ -366,7 +366,7 @@ function edit.keychord_pressed(State, chord, key)
|
|||
schedule_save(State)
|
||||
end
|
||||
elseif chord == 'C-y' then
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
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
|
||||
|
@ -382,20 +382,20 @@ function edit.keychord_pressed(State, chord, key)
|
|||
end
|
||||
-- clipboard
|
||||
elseif chord == 'C-c' then
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll
|
||||
local s = Text.selection(State)
|
||||
if s then
|
||||
App.setClipboardText(s)
|
||||
end
|
||||
elseif chord == 'C-x' then
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
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.setClipboardText(s)
|
||||
end
|
||||
schedule_save(State)
|
||||
elseif chord == 'C-v' then
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
for _,line in ipairs(State.lines) do line.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
|
||||
|
@ -416,7 +416,7 @@ function edit.keychord_pressed(State, chord, key)
|
|||
record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
|
||||
-- dispatch to drawing or text
|
||||
elseif App.mouse_down(1) or chord:sub(1,2) == 'C-' then
|
||||
-- DON'T reset line.y here
|
||||
-- DON'T reset line_cache.starty here
|
||||
local drawing_index, drawing = Drawing.current_drawing(State)
|
||||
if drawing_index then
|
||||
local before = snapshot(State, drawing_index)
|
||||
|
@ -451,7 +451,7 @@ function edit.keychord_pressed(State, chord, key)
|
|||
end
|
||||
schedule_save(State)
|
||||
else
|
||||
for _,line in ipairs(State.lines) do line.y = nil end -- just in case we scroll
|
||||
for _,line_cache in ipairs(State.line_cache) do line_cache.starty = nil end -- just in case we scroll
|
||||
Text.keychord_pressed(State, chord)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -831,7 +831,7 @@ function test_move_cursor_using_mouse()
|
|||
Editor_state.screen_top1 = {line=1, pos=1}
|
||||
Editor_state.screen_bottom1 = {}
|
||||
Editor_state.selection1 = {}
|
||||
edit.draw(Editor_state) -- populate line.y for each line in Editor_state.lines
|
||||
edit.draw(Editor_state) -- populate line_cache.starty for each line Editor_state.line_cache
|
||||
edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
|
||||
check_eq(Editor_state.cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line')
|
||||
check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')
|
||||
|
@ -849,7 +849,7 @@ function test_select_text_using_mouse()
|
|||
Editor_state.screen_top1 = {line=1, pos=1}
|
||||
Editor_state.screen_bottom1 = {}
|
||||
Editor_state.selection1 = {}
|
||||
edit.draw(Editor_state) -- populate line.y for each line in Editor_state.lines
|
||||
edit.draw(Editor_state) -- populate line_cache.starty for each line Editor_state.line_cache
|
||||
-- press and hold on first location
|
||||
edit.run_after_mouse_press(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
|
||||
-- drag and release somewhere else
|
||||
|
@ -870,7 +870,7 @@ function test_select_text_using_mouse_and_shift()
|
|||
Editor_state.screen_top1 = {line=1, pos=1}
|
||||
Editor_state.screen_bottom1 = {}
|
||||
Editor_state.selection1 = {}
|
||||
edit.draw(Editor_state) -- populate line.y for each line in Editor_state.lines
|
||||
edit.draw(Editor_state) -- populate line_cache.starty for each line Editor_state.line_cache
|
||||
-- click on first location
|
||||
edit.run_after_mouse_press(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
|
||||
edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
|
||||
|
@ -896,7 +896,7 @@ function test_select_text_repeatedly_using_mouse_and_shift()
|
|||
Editor_state.screen_top1 = {line=1, pos=1}
|
||||
Editor_state.screen_bottom1 = {}
|
||||
Editor_state.selection1 = {}
|
||||
edit.draw(Editor_state) -- populate line.y for each line in Editor_state.lines
|
||||
edit.draw(Editor_state) -- populate line_cache.starty for each line Editor_state.line_cache
|
||||
-- click on first location
|
||||
edit.run_after_mouse_press(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
|
||||
edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
|
||||
|
|
4
undo.lua
4
undo.lua
|
@ -67,8 +67,8 @@ function snapshot(State, s,e)
|
|||
--? print('copying', line.points, 'with', #line.points, 'points into', points)
|
||||
local shapes=deepcopy(line.shapes)
|
||||
--? print('copying', line.shapes, 'with', #line.shapes, 'shapes into', shapes)
|
||||
table.insert(event.lines, {mode='drawing', y=line.y, h=line.h, points=points, shapes=shapes, pending={}})
|
||||
--? table.insert(event.lines, {mode='drawing', y=line.y, h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})
|
||||
table.insert(event.lines, {mode='drawing', h=line.h, points=points, shapes=shapes, pending={}})
|
||||
--? table.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})
|
||||
else
|
||||
print(line.mode)
|
||||
assert(false)
|
||||
|
|
Loading…
Reference in New Issue