Skip to content

Commit

Permalink
fix(sqllab): race condition when updating same cursor position (#30141)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Sep 4, 2024
1 parent ff449ad commit 880d634
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,15 @@ const AceEditorWrapper = ({

currentSelectionCache.current = selectedText;
});

editor.selection.on('changeCursor', () => {
const cursor = editor.getCursorPosition();
onCursorPositionChange(cursor);
const { row, column } = cursorPosition;
// Prevent a maximum update depth exceeded error
// by skipping repeated updates to the same cursor position
if (cursor.row !== row && cursor.column !== column) {
onCursorPositionChange(cursor);
}
});

const { row, column } = cursorPosition;
Expand Down

0 comments on commit 880d634

Please sign in to comment.