mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
TextEditor: Debounce update_preview() in on_change event
This avoids lag spikes when undoing/redoing large chunks of HTML/CSS with the HTML preview open. This had been bugging me when reducing LibWeb issues in the text editor. The debounce timeout is 100ms so the delay should not be noticeable.
This commit is contained in:
parent
cdcdc095df
commit
8266ebf3c6
Notes:
sideshowbarker
2024-07-17 08:46:51 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/8266ebf3c6 Pull-request: https://github.com/SerenityOS/serenity/pull/14618 Reviewed-by: https://github.com/linusg
@ -11,6 +11,7 @@
|
||||
#include <AK/URL.h>
|
||||
#include <Applications/TextEditor/TextEditorWindowGML.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/Debounce.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCpp/SyntaxHighlighter.h>
|
||||
#include <LibDesktop/Launcher.h>
|
||||
@ -63,9 +64,10 @@ MainWidget::MainWidget()
|
||||
else
|
||||
VERIFY_NOT_REACHED();
|
||||
|
||||
m_editor->on_change = [this] {
|
||||
m_editor->on_change = Core::debounce([this] {
|
||||
update_preview();
|
||||
};
|
||||
},
|
||||
100);
|
||||
|
||||
m_editor->on_modified_change = [this](bool modified) {
|
||||
window()->set_modified(modified);
|
||||
|
Loading…
Reference in New Issue
Block a user