Overview
The Base Layer (src/vs/base/) provides the foundational utilities and abstractions that all other layers build upon. It contains zero dependencies on other VS Code layers, making it the most reusable and testable part of the codebase.
Directory Structure
Core Utilities
Lifecycle Management
Disposables - Memory Management
Disposables - Memory Management
The disposable pattern is fundamental to preventing memory leaks in VS Code.Located in:
src/vs/base/common/lifecycle.tsDisposableStore - Managing Multiple Resources
DisposableStore - Managing Multiple Resources
Critical Rule: Always dispose resources immediately after creation. Use
DisposableStore, MutableDisposable, or DisposableMap to manage disposables properly.Event System
Events - Type-Safe Event Handling
Events - Type-Safe Event Handling
VS Code implements a custom event system for type-safe, disposable event handling.Located in:
src/vs/base/common/event.tsEvent Utilities - Transformation and Filtering
Event Utilities - Transformation and Filtering
Async Utilities
Promises and Async Operations
Promises and Async Operations
Located in:
src/vs/base/common/async.tsRunOnceScheduler - Debounced Execution
RunOnceScheduler - Debounced Execution
URI Handling
URI - Universal Resource Identifier
URI - Universal Resource Identifier
Located in:
src/vs/base/common/uri.tsBrowser Utilities
Thesrc/vs/base/browser/ directory contains browser-specific utilities:
DOM Manipulation
DOM Utilities
DOM Utilities
Located in:
src/vs/base/browser/dom.tsKeyboard and Mouse Events
Common Utilities
Thesrc/vs/base/common/ directory contains platform-independent utilities:
Collections
- Arrays
- Maps
- Strings
Located in:
src/vs/base/common/arrays.tsPlatform Detection
Reusable UI Parts
Thesrc/vs/base/parts/ directory contains reusable UI components:
QuickInput - Command Palette Widget
QuickInput - Command Palette Widget
Tree Widget - Hierarchical List
Tree Widget - Hierarchical List
Performance Utilities
Key Takeaways
- The Base Layer has no dependencies on other VS Code layers
- All resources must be properly disposed using the Disposable pattern
- Use Events for type-safe, disposable communication between components
- Platform-specific code is separated into
browser/,common/, andnode/directories - The Base Layer provides the foundation for all higher-level functionality
Next Steps
Platform Layer
Learn about platform services and dependency injection
Architecture Overview
Return to architecture overview