Duplicate Folder Issue in VS Code File Explorer: Causes and Solutions

Abstract: Resolve duplicate folder display in VS Code File Explorer by closing redundant windows or removing extra workspace roots.

Created: 2026-08-29 by

Visual Studio Code displays duplicate folders in the File Explorer when multiple workspace windows open the same directory or when a folder is dragged into an existing window. This behavior is intentional UI design that allows you to manage separate instances of the same project, but it can be confusing if you are unaware of how VS Code handles workspace roots.

Understanding Workspace Roots and Multi-Root Workspaces

The core reason for seeing what appears to be duplicate folders lies in how Visual Studio Code manages workspace roots. Unlike many other text editors that treat a single folder as the entire universe of your project, VS Code allows you to open multiple folders simultaneously within one window. When you drag a folder from your operating system’s file manager into the VS Code sidebar, you are not "opening" it in the traditional sense of replacing the current view; you are adding it as an additional root to the current workspace. If you have two separate VS Code windows both pointing to the same directory path (for example, C:\Projects\MyApp), each window will display that folder independently. To a new user, this looks like duplication. However, these are distinct instances of the editor. The first window might have its own set of open files, terminal sessions, and debug configurations, while the second window has different ones. They are not synchronized by default unless you explicitly configure them to share state, which is rare. This separation is crucial for developers who need to work on related but distinct parts of a codebase without interference. For instance, you might want to keep a documentation folder open in one window and the source code in another, even if they reside on the same disk. Understanding this distinction prevents unnecessary troubleshooting efforts aimed at "fixing" a feature that is working as designed.

Distinguishing Between Hovering and Opening

A common point of confusion arises when users interact with the Explorer pane. If you hover over a folder in the Explorer tree, VS Code may highlight it or show a preview tooltip, but it does not open a new instance. It simply focuses the context menu or highlights the selection. However, if you double-click or press Enter, you expand the folder to reveal its contents within the current view. If you see the same folder name listed twice under the "WORKSPACE" section of the sidebar, it means the workspace currently contains two roots that happen to be the same physical directory. This often happens accidentally during drag-and-drop operations. You might drag a folder icon from your desktop onto the VS Code title bar or the sidebar area, inadvertently creating a second root entry for the same location. To verify if you have multiple roots, look at the top level of the Explorer sidebar. Each item listed there represents a root. If you see folder-name and then folder-name again below it, you have duplicated the reference. This is not a bug in the file system indexing; it is a reflection of the workspace configuration stored in memory.

Solutions to Remove Duplicate Folder References

Resolving the issue depends entirely on whether you intend to keep multiple instances open or consolidate them into a single view. Here are the practical steps to clean up your workspace structure.

1. Close Unnecessary Windows

If you have opened the same project in two separate VS Code windows, the simplest solution is to close one of them. Click the close button (X) on the window you no longer need. This will remove the duplicate instance from your taskbar and free up system resources. Ensure that any unsaved changes in the closed window are saved before closing to prevent data loss.

2. Remove Extra Roots from the Current Workspace

If both folder references appear in the same window’s Explorer sidebar, you need to remove the extra root. Right-click on the duplicate folder name in the Explorer pane. From the context menu, select Remove Folder from Workspace. This action detaches that specific folder reference from the current workspace configuration without deleting any files from your hard drive. After removing the duplicate, the Explorer will refresh, and you should see only one instance of the folder. If you had files open from the removed root, those tabs will remain open in the editor until you manually close them, but they will no longer be associated with the workspace file structure.

3. Use "Open Folder" Instead of Drag-and-Drop

To prevent accidental duplication in the future, prefer using the standard file opening mechanism rather than drag-and-drop. Navigate to File > Open Folder... in the menu bar. Select your desired directory. This method ensures that VS Code treats the action as a primary workspace load rather than an addition to an existing multi-root setup. Drag-and-drop is convenient but ambiguous. When you drop a folder onto the sidebar, VS Code interprets it as "add this to my current list of roots." When you drop it onto the title bar, it may attempt to open a new window. Being deliberate about how you initiate folder access eliminates ambiguity.

4. Reset Workspace Configuration

In rare cases where the workspace state becomes corrupted or stuck, you can reset the configuration. Go to File > Save Workspace As... and save a new version of the workspace file. Then, close all folders via File > Close Folder and reopen the workspace from the newly saved file. This clears out any lingering references or cached states that might be causing visual glitches in the Explorer pane.

Preventing Future Confusion

Being aware of the multi-root capability helps avoid this issue. If you frequently work with large projects, consider organizing your code into a single root folder containing subdirectories, rather than keeping separate top-level folders. This aligns with how most build tools and linters expect project structures. For more complex setups involving multiple repositories, consider using Multi-Root Workspaces intentionally. Create a workspace file (*.code-workspace) that lists your desired folders. This provides a persistent, explicit configuration that overrides the default behavior of adding folders individually. This approach is cleaner than relying on transient drag-and-drop actions. If you are experiencing issues with the Windows File Explorer itself, such as freezing or slow performance, these can indirectly affect VS Code's ability to render the tree view efficiently. While VS Code has its own rendering engine, heavy I/O contention from a struggling OS file explorer can cause delays. For insights on maintaining system stability, you might find our guide on preventing file explorer freezing helpful. Additionally, if you encounter input issues while navigating menus, checking your keyboard settings is advisable.

Frequently Asked Questions

Does removing a folder from the workspace delete the files?

No, removing a folder from the workspace only removes the reference from VS Code's internal list. The actual files remain intact on your hard drive. You can still access them through your operating system's file manager.

Why do my open tabs disappear when I remove a duplicate folder?

Tabs associated with files from a removed root may become orphaned. VS Code keeps them open temporarily, but they lose their connection to the workspace structure. You should manually close these tabs or re-open the files from the remaining root to restore proper context.

Can I merge two separate VS Code windows into one?

Not directly. You must manually move files between windows or use the "Add Folder to Workspace" command to combine roots into a single window instance. There is no automatic merge function for separate application windows.

Is it possible to have the same folder open in two windows with synchronized cursors?

By default, no. Each window operates independently. To synchronize editing across windows, you would need to use extensions specifically designed for collaborative editing or remote development features, but even then, direct synchronization of cursors between local instances is not a standard feature.

How do I check how many roots are in my current workspace?

Look at the top section of the Explorer sidebar labeled "WORKSPACE". Count the number of folder icons listed there. Each icon represents one root. If you see duplicates, count them to confirm the issue before attempting removal.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More