Skip to content

Commit 7d207a4

Browse files
committed
fix: high CPU load and unresponsiveness through SynEdit highlighter when starting to edit large text in popup editor
Refs #2388
1 parent 6262880 commit 7d207a4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

source/grideditlinks.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ function TInplaceEditorLink.BeginEdit: Boolean;
11891189
if Result then begin
11901190
FButton.Visible := ButtonVisible;
11911191
SetBounds(Rect(0, 0, 0, 0));
1192-
if (Length(FEdit.Text) > SIZE_KB) or (ScanLineBreaks(FEdit.Text) <> lbsNone) then
1192+
if (Length(FEdit.Text) >= GRIDMAXDATA) or (ScanLineBreaks(FEdit.Text) <> lbsNone) then
11931193
ButtonClick(FTree)
11941194
else begin
11951195
FPanel.Show;

source/texteditor.pas

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,15 @@ procedure TfrmTextEditor.SetText(text: String);
142142
end;
143143
if Assigned(Detected) then
144144
SelectLineBreaks(Detected);
145-
if (Length(text) > SIZE_MB) then begin
146-
MainForm.LogSQL(_('Auto-disabling wordwrap for large text'));
145+
if (Length(text) > SIZE_KB*10) then begin
146+
MainForm.LogSQL(_('Auto-disabling wordwrap and syntax highlighter for large text'));
147147
btnWrap.Enabled := False;
148+
comboHighlighter.Enabled := False;
149+
btnCustomizeHighlighter.Enabled := False;
148150
end else begin
149151
btnWrap.Enabled := True;
152+
comboHighlighter.Enabled := True;
153+
btnCustomizeHighlighter.Enabled := True;
150154
end;
151155

152156
MemoText.Text := text;
@@ -380,6 +384,8 @@ procedure TfrmTextEditor.comboHighlighterSelect(Sender: TObject);
380384
SelStart, SelLength: Integer;
381385
begin
382386
// Code highlighter selected
387+
if not comboHighlighter.Enabled then
388+
Exit;
383389
SelStart := MemoText.SelStart;
384390
SelLength := MemoText.SelLength;
385391
MemoText.Highlighter := nil;

0 commit comments

Comments
 (0)