@@ -159,7 +159,18 @@ void JsonViewDlg::DrawJsonTree()
159159 auto res = PopulateTreeUsingSax (rootNode, txtForParsing);
160160 if (res.has_value ())
161161 {
162- ShowMessage (JSON_ERROR_TITLE, res.value (), MB_OK | MB_ICONERROR);
162+ // This is the case when Notepad++ has JsonViewer Window opened for previous intance
163+ // Later on second launch, don't show the error message as this could be some text file
164+ // If it is real json file but has some error, then there must be more than 1 node exist.
165+
166+ if (!m_IsNppReady && m_hTreeView->GetNodeCount () <= 1 )
167+ {
168+ m_hTreeView->InsertNode (JSON_ERR_VALIDATE, NULL , rootNode);
169+ }
170+ else
171+ {
172+ ShowMessage (JSON_ERROR_TITLE, res.value (), MB_OK | MB_ICONERROR);
173+ }
163174 }
164175 }
165176
@@ -585,8 +596,7 @@ auto JsonViewDlg::CopyPath() const -> std::wstring
585596
586597int JsonViewDlg::ShowMessage (const std::wstring &title, const std::wstring &msg, int flag, bool bDontShow)
587598{
588- // Don't show message untill NPP ready message is received.
589- return (!bDontShow && m_IsNppReady) ? ::MessageBox (_hParent, msg.c_str (), title.c_str (), flag) : IDOK;
599+ return !bDontShow ? ::MessageBox (_hParent, msg.c_str (), title.c_str (), flag) : IDOK;
590600}
591601
592602void JsonViewDlg::ReportError (const Result &result)
0 commit comments