VS Code extension: Problems stay current
VS Code extension commands, and Problems that follow files an agent edits on disk.
Read this when the VS Code Problems panel looks stale or you want to know what each drag-lint command does. Pascal edits made on disk now re-lint on their own. Setting dragLint.engineStaleAction = auto swaps a stale engine in by itself once the editor has been idle for dragLint.engineUpdateIdleMinutes (default notify only).
Details
The drag-lint VS Code extension (editors\vscode\drag-lint) runs drag-lint lsp as the
language server for Pascal files: hover, go-to-definition, references, completion, signature
help and lint diagnostics in the Problems panel.
Commands
Open the Command Palette (Ctrl+Shift+P) and type drag-lint.
| Command | Use it when |
|---|---|
drag-lint: Refresh Problems (dragLint.refreshProblems) | Problems look stale. Re-lints, from disk, every file that currently shows a drag-lint problem. No restart, no reload. First thing to try. |
drag-lint: Restart Language Server (dragLint.restartServer) | Refresh did not help, the server crashed or latched into a failed state, or you changed dragLint.serverPath / dragLint.databases. Restarts the client and its engine process. |
drag-lint: Update Engine Copy Now (dragLint.updateEngine) | You rebuilt or redeployed the engine and want the extension's private engine copy refreshed now instead of on the next window start. |
drag-lint: Apply RAD Studio Colours (Pascal only) (dragLint.applyRadStudioColours) | You want Pascal files coloured like your RAD Studio editor. Instant, leaves other languages alone. |
drag-lint: Generate Theme From RAD Studio Colours (dragLint.generateTheme) | You changed your RAD Studio colour scheme and want the Delphi IDE (drag-lint) theme rebuilt. VS Code reads a theme once, so it offers a window reload. |
drag-lint: Select Platform / Select Project (dragLint.selectPlatform, dragLint.selectProject) | You want a different platform or project index to answer lookups. Also reachable from the status-bar context item. |
Problems follow files edited on disk
The extension watches **/*.{pas,dpr,dpk,inc,dfm} (VS Code uses OS change notifications) and
sends workspace/didChangeWatchedFiles to the server. For a .pas, .dpr or .dpk file that
is not open in an editor, the server re-lints it from disk and publishes the result; a
deleted file gets an empty diagnostics array. A file that is open is left alone: the editor
buffer is authoritative, and VS Code sends didChange when it reloads the buffer.
- Bursts are bounded: duplicates inside one message are dropped and at most 64 files are re-linted per message.
- Nothing here reindexes the project. Lint findings follow the file at once; index-backed answers (hover, find-references) follow the next reindex.
drag-lint: Refresh Problemsuses the custom notificationdraglint/refreshDiagnostics, which also refreshes open documents (using the live buffer).
Auto uses on save
VS Code runs editor.codeActionsOnSave on every save. The extension ships a default for
Pascal files, so the uses clause adds what is missing without a click:
| Code action kind | Default | What it does |
|---|---|---|
source.addMissingImports | on ("explicit") | adds the unit that declares an undeclared name, but only when exactly one unit declares it. An ambiguous name (two or more units) is never applied silently; it stays a light-bulb quick fix. |
source.removeUnusedImports | off | removes a dead uses entry (unused-unit-in-uses). Enable it in your settings: "[pascal]": { "editor.codeActionsOnSave": { "source.removeUnusedImports": "explicit" } } |
Removal is gated. VS Code runs the save actions before the file reaches disk and before the
index rescans it, so an ungated removal could delete the unit the code you just typed needs.
The action is offered only when the buffer is identical to what the index last read AND the
whole index is fresh. In practice a removal lands on the first save after the index has caught
up with the buffer; a stale index, or an {$IFDEF} (any {$ directive) inside the uses
clause, suppresses it. The light-bulb quick fix stays available in every case.
Never reported or removed: a unit with an initialization or finalization section, a unit
declaring a class constructor or class destructor, and a unit instantiated by the form's
.dfm -- they are linked for their side effect.
No while-typing mode. Half-typed names resolve to the wrong unit or none, and the index is never fresh mid-keystroke. The light bulb already works while typing.
Problems look stale
- Run drag-lint: Refresh Problems.
- Still wrong, or the server looks dead: drag-lint: Restart Language Server.
- Avoid Developer: Reload Window when Claude Code sessions run in that window: the reload ends them. Refresh Problems and Restart Language Server do not touch other extensions.
Guard: tests\autotest\run_lsp_watch_pascal_guard.ps1 (drives the LSP over stdio: Changed on a
closed file with a finding publishes it, rewritten clean publishes an empty array, an open file
and a non-source file publish nothing). Related guards: run_lsp_clear_diags_guard.ps1,
run_vscode_extension_contract.ps1.
Automatic engine-copy swap (opt-in, 1.6.14)
By default (DEC-14) a window only SAYS that a newer deployed engine exists (dragLint.engineStaleNoticeMinutes, default 15) and offers Update engine copy now; it never swaps a live language server by itself.
Setting dragLint.engineStaleAction to auto relaxes that on opt-in only: when a newer build is seen the extension runs Update Engine Copy Now itself, but only when
- no Pascal editor has unsaved changes,
- the window has been idle (no typing, cursor moves, editor switches or focus changes) for
dragLint.engineUpdateIdleMinutes(default 5), and - no engine hold (
drag-lint ide-release) is active.
If any condition fails the check is retried on the next tick. notify (the default) never swaps. Ignored with dragLint.serverPath set or dragLint.engineUpdate = off; needs engineStaleNoticeMinutes above 0. The decision is lib/engineautoupdate.js, tested by test/engineautoupdate.test.js. Owner ruling Q158-RC-1 (c).