Skip to content

Commit 714bda9

Browse files
committed
use the tmp save path as the key for storing bookmarks
part of #413
1 parent 3119a8d commit 714bda9

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/Commands/CmdBookmarks.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BowPad.
22
//
3-
// Copyright (C) 2014-2016, 2020-2023 - Stefan Kueng
3+
// Copyright (C) 2014-2016, 2020-2023, 2025 - Stefan Kueng
44
//
55
// This program is free software: you can redistribute it and/or modify
66
// it under the terms of the GNU General Public License as published by
@@ -58,11 +58,16 @@ void CCmdBookmarks::OnDocumentClose(DocID id)
5858
{
5959
auto& settings = CIniSettings::Instance();
6060
const auto& doc = GetDocumentFromID(id);
61+
auto docPath = doc.m_path;
6162
if (doc.m_path.empty())
62-
return;
63+
{
64+
docPath = doc.m_tmpSavePath;
65+
if (docPath.empty())
66+
return;
67+
}
6368

6469
// look if the path is already in our list
65-
bool bModified = (m_bookmarks.erase(doc.m_path) > 0);
70+
bool bModified = (m_bookmarks.erase(docPath) > 0);
6671

6772
// find all bookmarks
6873
std::vector<sptr_t> bookmarkLines;
@@ -76,7 +81,7 @@ void CCmdBookmarks::OnDocumentClose(DocID id)
7681

7782
if (!bookmarkLines.empty())
7883
{
79-
m_bookmarks[doc.m_path] = std::make_tuple(std::time(nullptr), std::move(bookmarkLines));
84+
m_bookmarks[docPath] = std::make_tuple(std::time(nullptr), std::move(bookmarkLines));
8085
bModified = true;
8186
}
8287

@@ -123,10 +128,11 @@ void CCmdBookmarks::OnDocumentClose(DocID id)
123128
void CCmdBookmarks::OnDocumentOpen(DocID id)
124129
{
125130
const CDocument& doc = GetDocumentFromID(id);
131+
auto docPath = doc.m_path;
126132
if (doc.m_path.empty())
127133
return;
128134

129-
auto it = m_bookmarks.find(doc.m_path);
135+
auto it = m_bookmarks.find(docPath);
130136
if (it != m_bookmarks.end())
131137
{
132138
const auto& [time, lines] = it->second;

src/Commands/CmdSession.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BowPad.
22
//
3-
// Copyright (C) 2014-2018, 2020-2024 - Stefan Kueng
3+
// Copyright (C) 2014-2018, 2020-2025 - Stefan Kueng
44
//
55
// This program is free software: you can redistribute it and/or modify
66
// it under the terms of the GNU General Public License as published by
@@ -193,6 +193,7 @@ void CCmdSessionLoad::OnClose()
193193
doc.m_bNeedsSaving = false;
194194
SaveDoc(docId, backupPath);
195195
doc.m_path = CStringUtils::Format(L"%d%s", saveIndex, filename.c_str());
196+
doc.m_tmpSavePath = backupPath;
196197
}
197198
settings.SetString(sessionSection(), CStringUtils::Format(L"path%d", saveIndex).c_str(), doc.m_path.c_str());
198199
settings.SetInt64(sessionSection(), CStringUtils::Format(L"tabspace%d", saveIndex).c_str(), static_cast<int>(doc.m_tabSpace));

src/Document.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BowPad.
22
//
3-
// Copyright (C) 2013-2018, 2020-2021, 2023-2024 - Stefan Kueng
3+
// Copyright (C) 2013-2018, 2020-2021, 2023-2025 - Stefan Kueng
44
//
55
// This program is free software: you can redistribute it and/or modify
66
// it under the terms of the GNU General Public License as published by
@@ -132,6 +132,7 @@ class CDocument
132132

133133
Document m_document;
134134
std::wstring m_path;
135+
std::wstring m_tmpSavePath;
135136
int m_encoding;
136137
int m_encodingSaving;
137138
unsigned __int64 m_fileSize;

0 commit comments

Comments
 (0)