From d0c759c6fbc8dbf2b80a4a98036963670fc75d66 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 20 Apr 2015 14:26:56 +0100 Subject: [PATCH] always send the latest position when emitting updatePosition event Avoid sending outdated position by capturing the current position in $scope.currentPostion on every call and sending it the when the timer for updatePosition runs. --- .../coffee/ide/online-users/OnlineUsersManager.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/web/public/coffee/ide/online-users/OnlineUsersManager.coffee b/services/web/public/coffee/ide/online-users/OnlineUsersManager.coffee index fe9c46d64b..785889ec66 100644 --- a/services/web/public/coffee/ide/online-users/OnlineUsersManager.coffee +++ b/services/web/public/coffee/ide/online-users/OnlineUsersManager.coffee @@ -82,13 +82,15 @@ define [ sendCursorPositionUpdate: (position) -> + if position? + @$scope.currentPosition = position # keep track of the latest position if !@cursorUpdateTimeout? @cursorUpdateTimeout = setTimeout ()=> doc_id = @$scope.editor.open_doc_id - + # always send the latest position to other clients @ide.socket.emit "clientTracking.updatePosition", { - row: position.row - column: position.column + row: @$scope.currentPosition?.row + column: @$scope.currentPosition?.column doc_id: doc_id }