diff --git a/0022-on.text_input b/0022-on.text_input index 55efe6c..204a36a 100644 --- a/0022-on.text_input +++ b/0022-on.text_input @@ -1,24 +1,13 @@ on.text_input = function(t) print('text input', t) - if Cursor_node then + if Cursor_node and Cursor_node.editor.cursor_x then local old_top = {line=Cursor_node.editor.screen_top1.line, pos=Cursor_node.editor.screen_top1.pos} edit.text_input(Cursor_node.editor, t) - if not eq(Cursor_node.editor.screen_top1, old_top) then - Viewport.y = Cursor_node.y + y_of_schema1(Cursor_node.editor, Cursor_node.editor.screen_top1) - -- Most of the time, we update the screen_top of nodes from Viewport.y. - -- But here we went the other way. - -- It's very important to avoid creating a recurrence, to avoid running - -- both sides of this feedback loop in a single frame. These apps are - -- not very numerically precise (e.g. we force text lines to start at - -- integer pixels regardless of zoom, because that keeps text crisp), - -- and the computations of Viewport.y and node.top will almost certainly - -- not converge. The resulting bugs are extremely difficult to chase - -- down. - -- The optional skip_updating_screen_top_for arg ensures we don't run - -- the other side of the feedback loop. - A(--[[skip updating screen_top for]] Cursor_node) - return + pan_viewport_to_contain_cursor(Cursor_node) + if eq(Cursor_node.editor.screen_top1, old_top) then + B() + else + A() end - B() end end diff --git a/0030-update_editor_box b/0030-update_editor_box index 288687c..9c82d62 100644 --- a/0030-update_editor_box +++ b/0030-update_editor_box @@ -1,6 +1,5 @@ -update_editor_box = function(node, skip_updating) +update_editor_box = function(node) if node.editor == nil then return end - if node == skip_updating then return end if node.editor.font_height ~= scale(20) then edit.update_font_settings(node.editor, scale(20)) end diff --git a/Manual_tests.md b/Manual_tests.md index df76836..76a68e0 100644 --- a/Manual_tests.md +++ b/Manual_tests.md @@ -185,7 +185,7 @@ Lua is dynamically typed. Tests can't patch over lack of type-checking. For example, `string.sub` should never use a `_pos`, only an `_offset`. * Some ADT/interface support would be helpful in keeping per-line state in - sync. Any change to line data should clear line `fragments` and + sync. Any change to line data should clear the derived line property `screen_line_starting_pos`. * Some inputs get processed in love.textinput and some in love.keypressed. diff --git a/app.lua b/app.lua index f968b7b..592b037 100644 --- a/app.lua +++ b/app.lua @@ -119,7 +119,7 @@ function love.run() App.files = nativefs.getDirectoryItems App.mkdir = nativefs.createDirectory App.remove = nativefs.remove - App.source_dir = love.filesystem.getSource()..'/' + App.source_dir = love.filesystem.getSource()..'/' -- '/' should work even on Windows App.current_dir = nativefs.getWorkingDirectory()..'/' App.save_dir = love.filesystem.getSaveDirectory()..'/' App.get_time = love.timer.getTime