From ae00a1d61b40cf2cd1372585d729256a92d265fb Mon Sep 17 00:00:00 2001 From: Danko Aleksejevs Date: Wed, 18 Jun 2025 12:58:31 +0200 Subject: [PATCH] fix: Remove 1ms delay before inserting list prefix, fix race condition in tests (#8207) Fixed the race condition that made the existing E2E tests fail. There was a 1ms delay between inserting a newline and the line prefix to facilitate creation of two "undo" entries (so "ctrl+z" basically undoes the list continuation, but not the newline). Thus scripted text changes may have happened out of order. This only ever reliably worked in Firefox and seems to still work there even without a timeout. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8207 Reviewed-by: Earl Warren Reviewed-by: Gusted Co-authored-by: Danko Aleksejevs Co-committed-by: Danko Aleksejevs --- web_src/js/features/comp/ComboMarkdownEditor.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js index 21bc7e694f..5f452b3802 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.js +++ b/web_src/js/features/comp/ComboMarkdownEditor.js @@ -587,9 +587,7 @@ class ComboMarkdownEditor { // Split the newline and prefix addition in two, so that it's two separate undo entries in Firefox // Chrome seems to bundle everything together more aggressively, even with prior text input. if (document.execCommand('insertText', false, '\n')) { - setTimeout(() => { - document.execCommand('insertText', false, text); - }, 1); + document.execCommand('insertText', false, text); } else { this.textarea.setRangeText(`\n${text}`); }