From 2470dec05b02cf1749cea237d0e13c28337ea36c Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 19 Mar 2017 12:26:43 +0000 Subject: [PATCH] ide: Find all optimized git-svn-id: svn://ultimatepp.org/upp/trunk@10956 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/FindReplace.cpp | 4 ++-- uppsrc/ide/FindInFiles.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/uppsrc/CodeEditor/FindReplace.cpp b/uppsrc/CodeEditor/FindReplace.cpp index 557ee6440..240d84e98 100644 --- a/uppsrc/CodeEditor/FindReplace.cpp +++ b/uppsrc/CodeEditor/FindReplace.cpp @@ -245,8 +245,8 @@ void CodeEditor::FindAll() while(FindFrom(foundpos, false, true)) { found.Add(MakeTuple(foundpos, foundsize)); foundpos += foundsize; - if(found.GetCount() >= 1000) { - Exclamation("Too many matches, only first 1000 will be shown."); + if(found.GetCount() >= 10000) { + Exclamation("Too many matches, only first 10000 will be shown."); break; } } diff --git a/uppsrc/ide/FindInFiles.cpp b/uppsrc/ide/FindInFiles.cpp index def0cfcd0..61f7eeb29 100644 --- a/uppsrc/ide/FindInFiles.cpp +++ b/uppsrc/ide/FindInFiles.cpp @@ -122,7 +122,6 @@ void Ide::AddFoundFile(const String& fn, int ln, const String& line, int pos, in f.message = "\1" + EditorSyntax::GetSyntaxForFilename(fn) + "\1" + AsString(pos) + "\1" + AsString(count) + "\1" + line; ffound.Add(fn, ln, f.message, RawToValue(f)); - ffound.Sync(); } bool Ide::SearchInFile(const String& fn, const String& pattern, bool wholeword, bool ignorecase, @@ -133,18 +132,22 @@ bool Ide::SearchInFile(const String& fn, const String& pattern, bool wholeword, bool wb = wholeword ? iscid(*pattern) : false; bool we = wholeword ? iscid(*pattern.Last()) : false; int infile = 0; + bool sync = false; while(!in.IsEof()) { String line = in.GetLine(); bool bw = true; int count; if(regexp) { - if(regexp->Match(line)) + if(regexp->Match(line)) { AddFoundFile(fn, ln, line, regexp->GetOffset(), regexp->GetLength()); + sync = true; + } } else for(const char *s = line; *s; s++) { if(bw && Match(pattern, s, we, ignorecase, count)) { AddFoundFile(fn, ln, line, int(s - line), count); + sync = true; infile++; n++; break; @@ -154,6 +157,9 @@ bool Ide::SearchInFile(const String& fn, const String& pattern, bool wholeword, ln++; } + if(sync) + ffound.Sync(); + in.Close(); int ffs = ~ff.style; if(infile && ffs != STYLE_NO_REPLACE)