Do not modify doc if sort when doc is already sorted
Fix #8558, close #8559
This commit is contained in:
parent
b724a04eeb
commit
d42f13071d
|
@ -3612,16 +3612,19 @@ void ScintillaEditView::sortLines(size_t fromLine, size_t toLine, ISorter *pSort
|
||||||
}
|
}
|
||||||
assert(toLine - fromLine + 1 == splitText.size());
|
assert(toLine - fromLine + 1 == splitText.size());
|
||||||
const std::vector<generic_string> sortedText = pSort->sort(splitText);
|
const std::vector<generic_string> sortedText = pSort->sort(splitText);
|
||||||
const generic_string joined = stringJoin(sortedText, getEOLString());
|
generic_string joined = stringJoin(sortedText, getEOLString());
|
||||||
if (sortEntireDocument)
|
if (sortEntireDocument)
|
||||||
{
|
{
|
||||||
assert(joined.length() == text.length());
|
assert(joined.length() == text.length());
|
||||||
replaceTarget(joined.c_str(), int(startPos), int(endPos));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(joined.length() + getEOLString().length() == text.length());
|
assert(joined.length() + getEOLString().length() == text.length());
|
||||||
replaceTarget((joined + getEOLString()).c_str(), int(startPos), int(endPos));
|
joined += getEOLString();
|
||||||
|
}
|
||||||
|
if (text != joined)
|
||||||
|
{
|
||||||
|
replaceTarget(joined.c_str(), int(startPos), int(endPos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue