|
9 | 9 | isMarkdownFile, |
10 | 10 | normalizeLocationPath, |
11 | 11 | } from './types'; |
| 12 | +import { discoverWalkthroughFiles } from './discovery'; |
12 | 13 | import { WalkthroughProvider } from './WalkthroughProvider'; |
13 | 14 | import { StepDetailPanel } from './StepDetailPanel'; |
14 | 15 | import { HighlightManager, HighlightColor } from './HighlightManager'; |
@@ -186,28 +187,12 @@ export function activate(context: vscode.ExtensionContext) { |
186 | 187 | ) |
187 | 188 | ); |
188 | 189 |
|
189 | | - // Find walkthrough file (.walkthrough.json at root or any .json in walkthroughs/) |
| 190 | + // Find walkthrough file (any .walkthrough.json or walkthroughs/*.json at any depth) |
190 | 191 | const findWalkthroughFile = (): string | undefined => { |
191 | | - // Check for .walkthrough.json at root |
192 | | - const rootWalkthroughPath = path.join(workspaceRoot, '.walkthrough.json'); |
193 | | - if (fs.existsSync(rootWalkthroughPath)) { |
194 | | - return rootWalkthroughPath; |
| 192 | + const files = discoverWalkthroughFiles(workspaceRoot); |
| 193 | + if (files.length > 0) { |
| 194 | + return path.join(workspaceRoot, files[0]); |
195 | 195 | } |
196 | | - |
197 | | - // Check for any .json file in walkthroughs/ directory |
198 | | - const walkthroughsDir = path.join(workspaceRoot, 'walkthroughs'); |
199 | | - if (fs.existsSync(walkthroughsDir) && fs.statSync(walkthroughsDir).isDirectory()) { |
200 | | - try { |
201 | | - const files = fs.readdirSync(walkthroughsDir); |
202 | | - const jsonFile = files.find((f) => f.endsWith('.json')); |
203 | | - if (jsonFile) { |
204 | | - return path.join(walkthroughsDir, jsonFile); |
205 | | - } |
206 | | - } catch { |
207 | | - // Ignore errors |
208 | | - } |
209 | | - } |
210 | | - |
211 | 196 | return undefined; |
212 | 197 | }; |
213 | 198 |
|
@@ -661,10 +646,10 @@ export function activate(context: vscode.ExtensionContext) { |
661 | 646 | }) |
662 | 647 | ); |
663 | 648 |
|
664 | | - // Watch for walkthrough file changes (both .walkthrough.json at root and walkthroughs/*.json) |
| 649 | + // Watch for walkthrough file changes at any depth |
665 | 650 | const watcherPatterns = [ |
666 | | - new vscode.RelativePattern(workspaceRoot, '.walkthrough.json'), |
667 | | - new vscode.RelativePattern(workspaceRoot, 'walkthroughs/*.json'), |
| 651 | + new vscode.RelativePattern(workspaceRoot, '**/.walkthrough.json'), |
| 652 | + new vscode.RelativePattern(workspaceRoot, '**/walkthroughs/*.json'), |
668 | 653 | ]; |
669 | 654 |
|
670 | 655 | // Create watchers for both patterns |
|
0 commit comments