forked from qt-creator/qt-creator
Fix ordering of items in open documents popup
When the document history was updated, it was cleaned of any items which no longer had a document open for them. This worked fine when that only happened when user closed documents. Nowadays this also happens when suspending documents without user interaction. Only remove items from the document history if they are no longer available even as a suspended document. Task-number: QTCREATORBUG-19758 Change-Id: I131a24823b5c456879b67a35b039768a15bd7716 Reviewed-by: Konstantin Tokarev <annulen@yandex.ru> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -517,6 +517,11 @@ Utils::optional<int> DocumentModel::indexOfDocument(IDocument *document)
|
||||
return d->indexOfDocument(document);
|
||||
}
|
||||
|
||||
Utils::optional<int> DocumentModel::indexOfFilePath(const Utils::FileName &filePath)
|
||||
{
|
||||
return d->indexOfFilePath(filePath);
|
||||
}
|
||||
|
||||
DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document)
|
||||
{
|
||||
return Utils::findOrDefault(d->m_entries,
|
||||
|
@@ -69,6 +69,7 @@ public:
|
||||
static int entryCount();
|
||||
static QList<Entry *> entries();
|
||||
static Utils::optional<int> indexOfDocument(IDocument *document);
|
||||
static Utils::optional<int> indexOfFilePath(const Utils::FileName &filePath);
|
||||
static Entry *entryForDocument(IDocument *document);
|
||||
static Entry *entryForFilePath(const Utils::FileName &filePath);
|
||||
static QList<IDocument *> openedDocuments();
|
||||
|
@@ -268,11 +268,10 @@ void EditorView::updateEditorHistory(IEditor *editor, QList<EditLocation> &histo
|
||||
location.state = QVariant(state);
|
||||
|
||||
for (int i = 0; i < history.size(); ++i) {
|
||||
if (history.at(i).document == 0
|
||||
|| history.at(i).document == document
|
||||
){
|
||||
const EditLocation &item = history.at(i);
|
||||
if (item.document == document
|
||||
|| !DocumentModel::indexOfFilePath(FileName::fromString(item.fileName))) {
|
||||
history.removeAt(i--);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
history.prepend(location);
|
||||
|
Reference in New Issue
Block a user