more robust state validation
[?]
Mar 17, 2023, 4:36 PM
7VGDIPLCFDG3PVE4JH3WDKZ4A7PG5UYW7TLFFFOWN2JEUZYYTFJQCDependencies
- [2]
KKMFQDR4editing source code from within the app - [3]
CQYKYJJUremember window positions across restart/ctrl+e - [4]
LF7BWEG4group all editor globals - [5]
2L5MEZV3experiment: new edit namespace - [6]
EMG7SDLWbugfix: cold start - [7]
LNUHQOGHstart passing in Editor_state explicitly - [8]
4KC7I3E2make colors easier to edit - [9]
QZ2SXLHFsome debug prints - [10]
5STHSG4Uremove some duplication - [11]
ERQKFTPVextract method - [12]
2CK5QI7Wmake love event names consistent - [13]
HCFDBUXHfix stale comment
Change contents
- edit in run.lua at line 31
edit.fixup_cursor(Editor_state) - edit in run.lua at line 34
if Editor_state.cursor1.line > #Editor_state.lines or Editor_state.lines[Editor_state.cursor1.line].mode ~= 'text' thenedit.fixup_cursor(Editor_state)end - edit in run.lua at line 35
edit.check_locs(Editor_state) - replacement in run.lua at line 112
edit.fixup_cursor(Editor_state)edit.check_locs(Editor_state) - replacement in edit.lua at line 112
function edit.fixup_cursor(State)function edit.check_locs(State)-- if State is inconsistent (i.e. file changed by some other program),-- throw away all cursor state entirelyif edit.invalid1(State, State.screen_top1)or edit.invalid1(State, State.cursor1)or not edit.cursor_on_text(State)or not Text.le1(State.screen_top1, State.cursor1) thenState.screen_top1 = {line=1, pos=1}edit.put_cursor_on_first_text_line(State)endendfunction edit.invalid1(State, loc1)return loc1.line > #State.linesor loc1.pos > #State.lines[loc1.line].dataendfunction edit.cursor_on_text(State)return State.cursor1.line <= #State.linesand State.lines[State.cursor1.line].mode == 'text'endfunction edit.put_cursor_on_first_text_line(State) - replacement in edit.lua at line 137
State.cursor1.line = iState.cursor1 = {line=i, pos=1}