From 2ddf7032ed47b688a403a006926fed80ce84f791 Mon Sep 17 00:00:00 2001 From: Suguru Yamamoto Date: Sun, 19 Mar 2023 16:24:13 +0900 Subject: [PATCH] fix: Allow top level headings without a child --- src/extension.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index def3cbd..d8399df 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -60,7 +60,11 @@ class RstSectionProvider implements vscode.DocumentSymbolProvider { } } - stack[stack.length - 1].children.push(section); + if (stack.length === 0) { + roots.push(section); + } else { + stack[stack.length - 1].children.push(section); + } } else { roots.push(section); hierarchy.push(section.type);