Skip to content

Cursor shifts after setting ace content and cursor #350

Open
jvanveen opened this Issue Jul 22, 2011 · 0 comments

1 participant

@jvanveen

I'm not sure if this can be considered a bug, but this occured to me as unwanted behaviour. With infinote i have to update the ace content on each change event from the document's ot-state. I save the cursor position, and try to restore it so the user won't notice that this update occurs. Using code like:

var cursor = ce.editor.getCursorPosition();
ce.editorDoc.setValue(ce._state.buffer.toString())         
ce.editor.moveCursorToPosition(cursor);

I have to block scrolling in order to prevent the current line to shift to the top of the visible area. I would expect that the current line won't shift, but maybe i use the wrong api calls? Anyway, fixed it with:

//only triggers on non-arrow keys
CollabEditor.prototype._handle_keypress = function(event){
    if(event.which >= 33 && event.which <=40) {
        var _cursor = ce.editor.getCursorPosition();
        var params = {id:ce._localUser, cursor:_cursor};
        ce.opts['ws_handler'].remote(ce.opts['ws_caret'], {params: params},function(response){});
    }
    if(event.which == 13){ce.editor.$blockScrolling = 0;}
    else {ce.editor.$blockScrolling = 1;}
}

@gissues:{"order":61.49068322981384,"status":"backlog"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.