mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-06 14:56:16 +01:00
558503ae2c
After adopting the sessions grid we lost the previous "restore on reload" behaviour. Restore the full visible grid (order, sticky/pinned state and the active session, including the empty new-session slot) from persisted workspace state instead of only the last active session. - Snapshot the live visibility model on save and rebuild it atomically via VisibleSessions.restoreGrid so multiple restored sessions appear in one shot without flicker; late-arriving sessions are inserted into their persisted position incrementally. - Suppress the empty new-session view while restore runs (view-owned restoring flag + grid hide) so the composer does not flash before sessions are laid out. - Show per-leaf load progress on each chat view's own ProgressBar (mirroring editor-group ScopedProgressIndicator) while its chat model loads. - Move keyboard focus into the active session by observing ISessionsManagementService.activeSession from the part, guarded so it never steals focus from another surface (e.g. the sessions list). - Use a dedicated restore cancellation token that is actually cancelled when the user opens a session, and bound provider waits with a timeout so a deleted session cannot keep restore (and its listeners) pending forever. - Add a coding guideline forbidding lazy invokeFunction/accessor.get service resolution. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2.9 KiB
2.9 KiB
description, applyTo
| description | applyTo |
|---|---|
| VS Code coding guidelines — naming, style, types, strings, and code quality rules. Reference when writing or reviewing code. | src/vs/** |
Coding Guidelines
Canonical reference: https://github.com/microsoft/vscode/wiki/Coding-Guidelines
Also see the Source Code Organization wiki page.
Indentation
Use tabs, not spaces.
Naming
- PascalCase for types and enum values
- camelCase for functions, methods, properties, and local variables
- Use whole words when possible
Types
- Do not export types or functions unless shared across multiple components
- Do not introduce new types or values to the global namespace
Comments
- Use JSDoc style comments for functions, interfaces, enums, and classes
Strings
"double quotes"for user-visible strings that need localization'single quotes'for everything else- All user-visible strings must be externalized via
nls.localize()— no string concatenation, use{0}placeholders
UI Labels
- Title case for command labels, buttons, and menu items (each major word capitalized)
- Don't capitalize prepositions of four or fewer letters unless first or last word
- Sentence case for view titles/headings (only first word capitalized), no trailing period
Style
- Arrow functions over anonymous function expressions
- Only parenthesize arrow parameters when necessary:
x => x + xnot(x) => x + x - Always surround loop and conditional bodies with curly braces
- Open curly braces on the same line
- No surrounding whitespace in parenthesized constructs
- Prefer
export function x(…) {…}overexport const x = (…) => {…}at top-level scope (better stack traces)
Code Quality
- Include Microsoft copyright header in all files
- Prefer
async/awaitoverPromise.then() - Localize all user-facing messages
- Prefer named regex capture groups over numbered ones
- Do not use
anyorunknownunless absolutely necessary - Register disposables immediately after creation — use
DisposableStore,MutableDisposable, orthis._register() - Declare service dependencies in constructors via DI — never access services through
IInstantiationServiceelsewhere. In particular, do not lazily resolve a service withthis.instantiationService.invokeFunction(accessor => accessor.get(ISomeService)); add@ISomeServiceas a constructor parameter instead. If a constructor cycle prevents direct injection, break the cycle (e.g. pass the dependency into aninit()/wiring method from the orchestrator, or relocate the call) rather than reaching throughinvokeFunction/accessor.get. - Use
IEditorServiceto open editors, notIEditorGroupsService.activeGroup.openEditor - Avoid
bind()/call()/apply()solely forthis— prefer arrow functions - Avoid events for control flow between components — prefer direct method calls