forked from qt-creator/qt-creator
Limit length of file names in DiffEditorDocument::suggestedFileName().
Change-Id: I168831b24bcece5ef825825c448edf684f4f536d Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -129,6 +129,7 @@ bool DiffEditorDocument::open(QString *errorString, const QString &fileName)
|
|||||||
|
|
||||||
QString DiffEditorDocument::suggestedFileName() const
|
QString DiffEditorDocument::suggestedFileName() const
|
||||||
{
|
{
|
||||||
|
enum { maxSubjectLength = 50 };
|
||||||
QString result = QStringLiteral("0001");
|
QString result = QStringLiteral("0001");
|
||||||
const QString description = m_controller->description();
|
const QString description = m_controller->description();
|
||||||
if (!description.isEmpty()) {
|
if (!description.isEmpty()) {
|
||||||
@@ -144,6 +145,10 @@ QString DiffEditorDocument::suggestedFileName() const
|
|||||||
subject[i] = space;
|
subject[i] = space;
|
||||||
}
|
}
|
||||||
subject = subject.simplified();
|
subject = subject.simplified();
|
||||||
|
if (subject.size() > maxSubjectLength) {
|
||||||
|
const int lastSpace = subject.lastIndexOf(space, maxSubjectLength);
|
||||||
|
subject.truncate(lastSpace > 0 ? lastSpace : maxSubjectLength);
|
||||||
|
}
|
||||||
subject.replace(space, dash);
|
subject.replace(space, dash);
|
||||||
result += dash;
|
result += dash;
|
||||||
result += subject;
|
result += subject;
|
||||||
|
|||||||
Reference in New Issue
Block a user