@@ -166,6 +166,16 @@ module SolutionExplorer =
166166 | " .exe" -> " Reference"
167167 | _ -> " Content" // Default fallback
168168
169+ // Check if a folder should be included in the tree view
170+ let isSpecialFolder ( folderName : string ) =
171+ folderName = " .deps"
172+ || folderName = " bin"
173+ || folderName = " obj"
174+ || folderName = " packages"
175+ || folderName = " docs"
176+ || folderName = " scripts"
177+ || folderName = " tools"
178+
169179 let private getProjectModel ( proj : Project ) =
170180 let projects = Project.getLoaded () |> Seq.toArray
171181
@@ -187,10 +197,7 @@ module SolutionExplorer =
187197 let stats = node.fs.statSync ( U2.Case1 fullPath)
188198 let isDir = stats.isDirectory ()
189199
190- let isTargetFolder =
191- ( item = " .deps" || item = " bin" || item = " obj" || item = " packages" )
192-
193- isDir && isTargetFolder)
200+ isDir && isSpecialFolder item)
194201 |> Seq.map ( fun folder ->
195202 let fullPath = node.path.join ( projectDir, folder)
196203 ( folder, fullPath))
@@ -300,6 +307,14 @@ module SolutionExplorer =
300307 // Add additional folders that aren't in the solution file
301308 let solutionDir = node.path.dirname sln.Path
302309
310+ // Get existing folder names from solution items to avoid duplicates
311+ let existingFolderNames =
312+ solutionItems
313+ |> List.collect ( fun item ->
314+ match item with
315+ | WorkspaceFolder(_, name, _) -> [ name ]
316+ | _ -> [])
317+
303318 let additionalSolutionFolders =
304319 try
305320 let dirContents = node.fs.readdirSync ( U2.Case1 solutionDir)
@@ -310,55 +325,39 @@ module SolutionExplorer =
310325 let stats = node.fs.statSync ( U2.Case1 fullPath)
311326 let isDir = stats.isDirectory ()
312327
313- let isTargetFolder =
314- ( item = " .deps"
315- || item = " bin"
316- || item = " obj"
317- || item = " packages"
318- || item = " docs"
319- || item = " scripts"
320- || item = " tools" )
321-
322-
323- isDir && isTargetFolder)
328+ isDir && isSpecialFolder item && not ( existingFolderNames |> List.contains item))
324329 |> Seq.map ( fun folder ->
325330 let fullPath = node.path.join ( solutionDir, folder)
326331
327332 // Recursively scan the contents of this folder
328- let rec scanFolderContents ( currentPath : string ) ( currentName : string ) ( depth : int ) =
333+ let rec scanFolderContents ( currentPath : string ) ( depth : int ) =
334+ // Helper function to determine if an item should be hidden
335+ let shouldHideItem ( item : string ) ( depth : int ) =
336+ item.StartsWith( " ." ) && item <> " .deps"
337+ || item = " node_modules"
338+ || item = " .git"
339+ || item = " .vs"
340+ || ( item = " packages" && depth > 0 )
341+
329342 try
330343 let contents = node.fs.readdirSync ( U2.Case1 currentPath)
331344
332345 contents
333- |> Seq.filter ( fun item ->
334- // Filter out unwanted items at solution level
335- let isUnwanted =
336- item.StartsWith( " ." ) && item <> " .deps"
337- || // Hide hidden files except .deps
338- item = " node_modules"
339- || // Hide node_modules
340- item = " .git"
341- || // Hide git folder
342- item = " .vs"
343- || // Hide Visual Studio folder
344- item = " packages" && depth > 0 // Hide nested packages folders
345-
346- not isUnwanted)
346+ |> Seq.filter ( fun item -> not ( shouldHideItem item depth))
347347 |> Seq.map ( fun item ->
348348 let itemPath = node.path.join ( currentPath, item)
349349 let stats = node.fs.statSync ( U2.Case1 itemPath)
350350
351351 if stats.isDirectory () then
352352 // Recursively scan subdirectories (limit depth to avoid infinite recursion)
353353 if depth < 6 then
354- let subContents = scanFolderContents itemPath item ( depth + 1 )
354+ let subContents = scanFolderContents itemPath ( depth + 1 )
355355 Model.Folder( ref None, item, itemPath, subContents, " " )
356356 else
357357 // For very deep directories, just show as empty folder
358358 Model.Folder( ref None, item, itemPath, [], " " )
359359 else
360360 // Use the same file type mapping as project level
361- let ext = node.path.extname( item) .ToLowerInvariant()
362361 let itemType = getItemTypeForFile item
363362
364363 // For files, create a file representation
@@ -367,7 +366,7 @@ module SolutionExplorer =
367366 with ex ->
368367 []
369368
370- let folderContents = scanFolderContents fullPath folder 0
369+ let folderContents = scanFolderContents fullPath 0
371370
372371
373372 // Create a WorkspaceFolder with the scanned contents
0 commit comments