Skip to main content

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

The disposable pattern is fundamental to preventing memory leaks in VS Code.Located in: src/vs/base/common/lifecycle.ts
Critical Rule: Always dispose resources immediately after creation. Use DisposableStore, MutableDisposable, or DisposableMap to manage disposables properly.

Event System

VS Code implements a custom event system for type-safe, disposable event handling.Located in: src/vs/base/common/event.ts

Async Utilities

Located in: src/vs/base/common/async.ts

URI Handling

Located in: src/vs/base/common/uri.ts

Browser Utilities

The src/vs/base/browser/ directory contains browser-specific utilities:

DOM Manipulation

Located in: src/vs/base/browser/dom.ts

Keyboard and Mouse Events

Common Utilities

The src/vs/base/common/ directory contains platform-independent utilities:

Collections

Located in: src/vs/base/common/arrays.ts

Platform Detection

Reusable UI Parts

The src/vs/base/parts/ directory contains reusable UI components:

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/, and node/ 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