TSynEdit crashes when loading text lazarus / 31-LCL ---------------------------------------------------------------------- domasz · 2023-06-01 18:13 When I click this button twice the program crashes. Might be something with highlighters (TSynMultiSyn, TSynPHPSyn, TSynHTMLSyn). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var Str: String;    L: TStringList;begin  L := TStringList.Create;  L.LoadFromFile('test.htm');   Str := L.Text;  L.Free;  SynEdit1.Text:=Str; //crashesend;  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   object SynMultiSyn1: TSynMultiSyn    Enabled = False    Schemes = <          item        StartExpr = ''        Highlighter = SynCssSyn1        MarkerAttri.Background = clNone      MarkerAttri.Foreground = 16744448      end              item        StartExpr = '<\?php'        EndExpr = '\?>'        Highlighter = SynPHPSyn1        MarkerAttri.Background = clNone        MarkerAttri.Foreground = 16512      end>    DefaultHighlighter = SynHTMLSyn1    Left = 592    Top = 40  end Attached is super simple demo. ---------------------------------------------------------------------- Martin_fr · 2023-06-01 18:25 I can reproduce... It seems something in the Multi-HL. Not sure yet ---------------------------------------------------------------------- Martin_fr · 2023-06-01 18:30 Ideally report on the bug tracker please ---------------------------------------------------------------------- domasz · 2023-06-01 18:35 Quote from: Martin_fr on June 01, 2023, 08:30:46 pmIdeally report on the bug tracker please Not sure if I did it right. Don't know how to post files there. https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40292 ---------------------------------------------------------------------- Martin_fr · 2023-06-01 18:40 ok, thanks ---------------------------------------------------------------------- Martin_fr · 2023-06-02 17:34 A temporary patch. I still need to do some testing. Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/components/synedit/synhighlightermulti.pas b/components/synedit/synhighlightermulti.pasindex 1343e5d554..ca662dc37d 100644--- a/components/synedit/synhighlightermulti.pas+++ b/components/synedit/synhighlightermulti.pas@@ -845,22 +845,22 @@ procedure TSynHLightMultiVirtualLines.RealLinesDeleted(AIndex, ACount: Integer);     // Real-lines starting in the middle of the Section     CountInSection := Min(AIndex + ACount, p^.EndPos.y + 1) - AIndex;     FirstVLine := p^.VirtualLine + AIndex - p^.StartPos.y;-    PrevEndVLine := p^.VirtualLine + p^.EndPos.y - p^.EndPos.y;+    PrevEndVLine := p^.VirtualLine + p^.EndPos.y - p^.StartPos.y;     p^.EndPos.y := p^.EndPos.y - CountInSection;     inc(i);     if i = FSectionList.Count then begin       DelVLines;       exit;     end;   p := FSectionList.PSections[i];    VLineCount := CountInSection;   end;   while p^.EndPos.y < AIndex + ACount do begin     // Completly delete node (All Real lines deleted)     VLineCount := VLineCount + p^.EndPos.y - p^.StartPos.y + 1;     if PrevEndVLine = p^.VirtualLine then       dec(VLineCount);-    PrevEndVLine := p^.VirtualLine + p^.EndPos.y - p^.EndPos.y;+    PrevEndVLine := p^.VirtualLine + p^.EndPos.y - p^.StartPos.y;     FSectionList.Delete(i);     if i = FSectionList.Count then begin       DelVLines; ---------------------------------------------------------------------- domasz · 2023-06-02 18:46 Seems to work great, thank you for such a quick fix! I tried it with hundreds of files from real websites and I found no problems. ---------------------------------------------------------------------- Martin_fr · 2023-06-03 19:37 Found a few other issues too. For patch, see the commit mentioned in the reported issue.