[Fix] Snippet will not be displayed correctly when file content is too short.
This commit is contained in:
parent
ac5f47e374
commit
d050d4ea28
|
@ -396,7 +396,10 @@ int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord)
|
|||
{
|
||||
std::string s = data.substr((*pos < 60)? 0: (*pos - 60) , size + 120);
|
||||
QString snippet = QString::fromStdString(s);
|
||||
if(snippet.size() > 6 + QString::fromStdString(keyWord).size())
|
||||
snippet.replace(0,3,"...").replace(snippet.size()-3,3,"...");
|
||||
else
|
||||
snippet.append("...").prepend("...");
|
||||
snippets.append(snippet);
|
||||
QString().swap(snippet);
|
||||
std::string().swap(s);
|
||||
|
|
Loading…
Reference in New Issue