fix(sqllab): race condition when updating same cursor position (#30141)

This commit is contained in:
JUST.in DO IT 2024-09-04 04:18:42 -07:00 committed by GitHub
parent ff449ad8ab
commit 880d634dc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -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;