From f440baf14c64bd88a2c487dfff6a7d91c9946ce2 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Thu, 12 Oct 2023 01:18:58 +0200 Subject: [PATCH] CtrlLib: Fixed problem with TextCtrl view mode --- uppsrc/CtrlLib/Text.cpp | 11 +++++------ uppsrc/ide/idefile.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/uppsrc/CtrlLib/Text.cpp b/uppsrc/CtrlLib/Text.cpp index 6b9d2d742..9fcce56ba 100644 --- a/uppsrc/CtrlLib/Text.cpp +++ b/uppsrc/CtrlLib/Text.cpp @@ -258,8 +258,8 @@ int TextCtrl::LoadLines(Vector& ls, int n, int64& total, Stream& in, byte ch auto put_ln = [&]() -> bool { if(view_line_count) { (*view_line_count)++; - total += charset == CHARSET_UTF8 && (b8 & 0x80) ? Utf32Len(~ln, ln.GetCount()) - : ln.GetCount(); + total += (charset == CHARSET_UTF8 && (b8 & 0x80) ? Utf32Len(~ln, ln.GetCount()) + : ln.GetCount()) + 1; } else { Ln& l = ls.Add(); @@ -361,7 +361,7 @@ void TextCtrl::ViewLoading() enum { MAX_LINES = INT_MAX - 512 }; #endif - if(view->IsEof() || viewlines > INT_MAX - 512) { + if(view->IsEof() || viewlines > MAX_LINES) { WhenViewMapping(view->GetPos()); view_all = true; break; @@ -445,7 +445,7 @@ const TextCtrl::Ln& TextCtrl::GetLn(int i) const bool b; view_cache[0].line.Clear(); view_cache[0].blk = blk; - LoadLines(view_cache[0].line, 256, t, *view, charset, 5000, INT_MAX, b); + LoadLines(view_cache[0].line, 256, t, *view, charset, 10000, INT_MAX, b); } return view_cache[0].line[i & 255]; } @@ -634,8 +634,7 @@ int TextCtrl::GetLinePos64(int64& pos) const { if(pos < n) break; pos -= n; - blk++; - if(blk >= total256.GetCount()) { + if(++blk >= total256.GetCount()) { pos = GetLineLength(GetLineCount() - 1); return GetLineCount() - 1; } diff --git a/uppsrc/ide/idefile.cpp b/uppsrc/ide/idefile.cpp index 69fa918ff..685ef4137 100644 --- a/uppsrc/ide/idefile.cpp +++ b/uppsrc/ide/idefile.cpp @@ -11,7 +11,7 @@ String ViewFileHash(const String& path) FindFile ff(path); if(ff) { Sha1Stream sha; - sha << path << ';' << Time(ff.GetLastWriteTime()) << ';' << ff.GetLength(); + sha << path << ',' << Time(ff.GetLastWriteTime()) << ',' << ff.GetLength(); return AppendFileName(ViewCache(), sha.FinishString()); } return Null;