bugfix
[?]
Mar 26, 2023, 3:17 PM
5Y24ZDZISLWYQ5ZILKUGMQJ2DBHIRKYPH2ZINMHSPUQWYASTC5ZQCDependencies
- [2]
MTJEVRJRadd state arg to a few functions - [3]
LF7BWEG4group all editor globals - [4]
LNUHQOGHstart passing in Editor_state explicitly - [5]
2L5MEZV3experiment: new edit namespace - [*]
K2X6G75Zstart writing some tests for drawings - [*]
L6XA5EY2test: moving a point
Change contents
- replacement in edit.lua at line 494
local byte_offset = Text.offset(p.name, len-1)if len == 1 then byte_offset = 0 endp.name = string.sub(p.name, 1, byte_offset)record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})if len > 0 thenlocal byte_offset = Text.offset(p.name, len-1)if len == 1 then byte_offset = 0 endp.name = string.sub(p.name, 1, byte_offset)record_undo_event(State, {before=before, after=snapshot(State, State.lines.current_drawing_index)})end - edit in drawing_tests.lua at line 429[8.19][8.19]
function test_name_point_then_hit_backspace()-- create a drawing with a lineApp.screen.init{width=Test_margin_left+256, height=300} -- drawing coordinates 1:1 with pixelsEditor_state = edit.initialize_test_state()Editor_state.filename = 'foo'Editor_state.lines = load_array{'```lines', '```', ''}Text.redraw_all(Editor_state)Editor_state.current_drawing_mode = 'line'edit.draw(Editor_state)-- draw a lineedit.run_after_mouse_press(Editor_state, Editor_state.left+5, Editor_state.top+Drawing_padding_top+6, 1)edit.run_after_mouse_release(Editor_state, Editor_state.left+35, Editor_state.top+Drawing_padding_top+36, 1)local drawing = Editor_state.lines[1]check_eq(#drawing.shapes, 1, 'baseline/#shapes')check_eq(#drawing.points, 2, 'baseline/#points')check_eq(drawing.shapes[1].mode, 'line', 'baseline/shape:1')local p1 = drawing.points[drawing.shapes[1].p1]local p2 = drawing.points[drawing.shapes[1].p2]check_eq(p1.x, 5, 'baseline/p1:x')check_eq(p1.y, 6, 'baseline/p1:y')check_eq(p2.x, 35, 'baseline/p2:x')check_eq(p2.y, 36, 'baseline/p2:y')check_nil(p2.name, 'baseline/p2:name')-- enter 'name' mode without moving the mouseedit.run_after_keychord(Editor_state, 'C-n')check_eq(Editor_state.current_drawing_mode, 'name', 'mode:1')-- hit backspaceedit.run_after_keychord(Editor_state, 'backspace')-- no crashend