fix: high CPU load and unresponsiveness through SynEdit highlighter when starting to edit large text in popup editor

Refs #2388
This commit is contained in:
Ansgar Becker
2026-02-22 16:29:43 +01:00
parent 2acce35206
commit 676fcd793f
3 changed files with 12 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2026-02-19 18:41+0100\n"
"PO-Revision-Date: 2026-02-22 16:29+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"Language: en\n"
@@ -6648,8 +6648,8 @@ msgstr "Style:"
msgid "Error in code formatting: %s"
msgstr "Error in code formatting: %s"
msgid "Auto-disabling wordwrap for large text"
msgstr "Auto-disabling wordwrap for large text"
msgid "Auto-disabling wordwrap and syntax highlighter for large text"
msgstr "Auto-disabling wordwrap and syntax highlighter for large text"
msgid "%d tab(s) took longer than expected to restore. Closing and reopening these should fix that: %s"
msgstr "%d tab(s) took longer than expected to restore. Closing and reopening these should fix that: %s"

View File

@@ -1224,7 +1224,7 @@ begin
if Result then begin
FButton.Visible := ButtonVisible;
SetBounds(Rect(0, 0, 0, 0));
if (Length(FEdit.Text) > SIZE_KB) or (ScanLineBreaks(FEdit.Text) <> lbsNone) then
if (Length(FEdit.Text) >= GRIDMAXDATA) or (ScanLineBreaks(FEdit.Text) <> lbsNone) then
ButtonClick(FTree)
else begin
FPanel.Show;

View File

@@ -141,11 +141,15 @@ begin
end;
if Assigned(Detected) then
SelectLineBreaks(Detected);
if (Length(text) > SIZE_MB) then begin
MainForm.LogSQL(_('Auto-disabling wordwrap for large text'));
if (Length(text) > SIZE_KB*10) then begin
MainForm.LogSQL(_('Auto-disabling wordwrap and syntax highlighter for large text'));
btnWrap.Enabled := False;
comboHighlighter.Enabled := False;
btnCustomizeHighlighter.Enabled := False;
end else begin
btnWrap.Enabled := True;
comboHighlighter.Enabled := True;
btnCustomizeHighlighter.Enabled := True;
end;
MemoText.Text := text;
@@ -379,6 +383,8 @@ var
SelStart, SelLength: Integer;
begin
// Code highlighter selected
if not comboHighlighter.Enabled then
Exit;
SelStart := MemoText.SelStart;
SelLength := MemoText.SelEnd - MemoText.SelStart;
MemoText.Highlighter := nil;