Skip to content

Commit 251ed51

Browse files
committed
Selected node path contains dot (.) before array
#fixes #143 and #closes #143
1 parent b50367d commit 251ed51

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

NppJSONViewer/NppJsonViewer/TreeViewCtrl.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,34 +233,30 @@ auto TreeViewCtrl::GetNodePath(HTREEITEM hti) -> std::wstring
233233
if (nodeKey[nodeKey.size() - 1] == TEXT('"'))
234234
nodeKey.pop_back();
235235

236-
if (wstrJsonPath.empty())
236+
std::wstring separator = TEXT(".");
237+
if (nodeKey[0] == TEXT('['))
237238
{
238-
wstrJsonPath = nodeKey;
239+
bArray = true;
240+
wstrJsonPath = nodeKey + separator + wstrJsonPath;
239241
}
240242
else
241243
{
242-
std::wstring separator = TEXT(".");
243-
if (nodeKey[0] == TEXT('['))
244+
if (bArray)
244245
{
245-
bArray = true;
246-
wstrJsonPath = nodeKey + separator + wstrJsonPath;
247-
}
248-
else
249-
{
250-
if (bArray)
251-
{
252-
bArray = false;
253-
separator.clear();
254-
}
255-
wstrJsonPath = nodeKey + separator + wstrJsonPath;
246+
bArray = false;
247+
separator.clear();
256248
}
249+
wstrJsonPath = nodeKey + separator + wstrJsonPath;
257250
}
258251
}
259252

260253
HTREEITEM htiParent = GetParentItem(hitTravel);
261254
hitTravel = htiParent;
262255
}
263256

257+
// remove trailling dot (.)
258+
wstrJsonPath.pop_back();
259+
264260
return wstrJsonPath;
265261
}
266262

0 commit comments

Comments
 (0)