Ace editor: cursor movement is undone immediately (because bijectEditorValue triggers onRefresh after onEdit?)
Below is a simple example using the Ace editor. In iTasks.Extensions.Editors.Ace,
aceEditor to hide the position of the cursor (among other things). But when an edit event comes in from the client, this triggers
onEdit and then
onRefresh, which resets the cursor position (as it cannot be retained in the mapping function given to
bijectEditorValue). So when you move the cursor in the example below it will immediately jump back to the initial position.
Assuming it is intentional, how do we fix the problem in the Ace editor? One way I see is to add a new editor modifier with type
!(a -> b) !((Maybe b) a -> b) !(b -> a) !(Editor b) -> Editor a. The first argument is used for
genUI, the second for
onRefresh - this mapping receives the old internal state from
editorValueFromSt. I think it is preferable to add a new modifier than to change the current
bijectEditorValue because in many cases it is used for a simple transformation (e.g. wrapping a constructor around a value) and then this extra parameter would cause unnecessary overhead. We could call the new modifier
module test import iTasks import iTasks.Extensions.Editors.Ace Start w = doTasks edit w edit :: Task String edit = updateSharedInformation () [UpdateUsing id (\_ x->x) aceTextArea] contents contents = sharedStore "contents" "some text"