@@ -67,12 +67,13 @@ void JsonViewDlg::ShowDlg(bool bShow)
67
67
DrawJsonTree ();
68
68
}
69
69
70
- UpdateTitle ();
71
70
DockingDlgInterface::display (bShow);
72
71
}
73
72
74
73
void JsonViewDlg::FormatJson ()
75
74
{
75
+ UpdateTitle ();
76
+
76
77
const auto selectedData = m_pEditor->GetJsonText ();
77
78
const auto selectedText = IsSelectionValidJson (selectedData);
78
79
@@ -103,6 +104,8 @@ void JsonViewDlg::FormatJson()
103
104
104
105
void JsonViewDlg::CompressJson ()
105
106
{
107
+ UpdateTitle ();
108
+
106
109
const auto selectedData = m_pEditor->GetJsonText ();
107
110
const auto selectedText = IsSelectionValidJson (selectedData);
108
111
@@ -131,6 +134,8 @@ void JsonViewDlg::CompressJson()
131
134
132
135
void JsonViewDlg::SortJsonByKey ()
133
136
{
137
+ UpdateTitle ();
138
+
134
139
const auto selectedData = m_pEditor->GetJsonText ();
135
140
const auto selectedText = IsSelectionValidJson (selectedData);
136
141
@@ -287,13 +292,14 @@ void JsonViewDlg::HandleTabActivated()
287
292
{
288
293
FormatJson ();
289
294
}
290
- UpdateTitle ();
291
295
}
292
296
}
293
297
}
294
298
295
299
void JsonViewDlg::ValidateJson ()
296
300
{
301
+ UpdateTitle ();
302
+
297
303
const auto selectedData = m_pEditor->GetJsonText ();
298
304
const auto selectedText = IsSelectionValidJson (selectedData);
299
305
@@ -324,6 +330,8 @@ void JsonViewDlg::ValidateJson()
324
330
325
331
void JsonViewDlg::DrawJsonTree ()
326
332
{
333
+ UpdateTitle ();
334
+
327
335
// Disable all buttons and treeView
328
336
std::vector<DWORD> ctrls = {IDC_BTN_REFRESH, IDC_BTN_VALIDATE, IDC_BTN_FORMAT, IDC_BTN_SEARCH, IDC_EDT_SEARCH};
329
337
EnableControls (ctrls, false );
@@ -526,28 +534,34 @@ void JsonViewDlg::SearchInTree()
526
534
527
535
void JsonViewDlg::UpdateTitle ()
528
536
{
529
- GetTitleFileName ();
530
- updateDockingDlg ();
531
- }
532
-
533
- void JsonViewDlg::GetTitleFileName ()
534
- {
535
- if (!m_pCurrFileName)
537
+ const auto titleFileName = GetTitleFileName ();
538
+ if (!titleFileName.empty ())
536
539
{
537
- m_pCurrFileName = std::make_unique<wchar_t []>(FILENAME_LEN_IN_TITLE);
540
+ if (!m_pCurrFileName)
541
+ {
542
+ m_pCurrFileName = std::make_unique<wchar_t []>(FILENAME_LEN_IN_TITLE);
543
+ }
544
+
545
+ if (_wcsicmp (m_pCurrFileName.get (), titleFileName.c_str ()) != 0 )
546
+ {
547
+ memset (m_pCurrFileName.get (), 0 , FILENAME_LEN_IN_TITLE);
548
+ wcsncpy_s (m_pCurrFileName.get (), FILENAME_LEN_IN_TITLE, titleFileName.c_str (), _TRUNCATE);
549
+
550
+ updateDockingDlg ();
551
+ }
538
552
}
553
+ }
539
554
555
+ auto JsonViewDlg::GetTitleFileName () const -> std::wstring
556
+ {
540
557
auto currFile = m_pEditor->GetCurrentFileName ();
541
558
if (currFile.length () >= FILENAME_LEN_IN_TITLE)
542
559
{
543
560
// If the filename is too long, truncate it and add "..."
544
561
currFile = currFile.substr (0 , FILENAME_LEN_IN_TITLE - 4 ) + L" ..." ;
545
562
}
546
563
547
- memset (m_pCurrFileName.get (), 0 , FILENAME_LEN_IN_TITLE);
548
- wcsncpy_s (m_pCurrFileName.get (), FILENAME_LEN_IN_TITLE, currFile.c_str (), _TRUNCATE);
549
-
550
- updateDockingDlg ();
564
+ return currFile;
551
565
}
552
566
553
567
void JsonViewDlg::PrepareButtons ()
0 commit comments