Skip to content

Commit a2603aa

Browse files
sowicmsowicm
authored andcommitted
fix: 重新加载之后的没内容的untitled标题会变成空白
1 parent 6127d4e commit a2603aa

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

LiteEditor/mainbook.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,38 @@ void MainBook::RestoreSession(SessionEntry& session)
303303
for(size_t i = 0; i < vTabInfoArr.size(); i++) {
304304
const TabInfo& ti = vTabInfoArr[i];
305305
m_reloadingDoRaise = (i == vTabInfoArr.size() - 1); // Raise() when opening only the last editor
306-
const wxString* buffer = NULL;
307-
//if (ti.unsaved())
308-
//{
309-
// buffer = &(ti.contents());
310-
//}
311-
LEditor* editor = OpenFile(ti.GetFileName(), buffer);
306+
307+
308+
if (ti.GetFileName().Length() < 1 && ti.contents().Length() < 1)
309+
{
310+
wxString fileNameStr(_("untitled"));
311+
wxFileName fileName(fileNameStr);
312+
313+
// A Nice trick: hide the notebook, open the editor
314+
// and then show it
315+
// bool hidden(false);
316+
// if(m_book->GetPageCount() == 0) hidden = GetSizer()->Hide(m_book);
317+
318+
LEditor* editor = new LEditor(m_book);
319+
editor->SetFileName(fileName);
320+
editor->untitled(true);
321+
AddPage(editor, fileName.GetFullName(), fileName.GetFullPath(), wxNullBitmap, true);
322+
323+
#ifdef __WXMAC__
324+
m_book->GetSizer()->Layout();
325+
#endif
326+
327+
// SHow the notebook
328+
// if(hidden) GetSizer()->Show(m_book);
329+
330+
// editor->SetActive();
331+
// return editor;
332+
333+
continue;
334+
}
335+
336+
337+
LEditor* editor = OpenFile(ti.GetFileName());
312338
if(!editor) {
313339
if(i < sel) {
314340
// have to adjust selected tab number because couldn't open tab

0 commit comments

Comments
 (0)