Repository navigation
0.24.0: std's command follows the build, not an edit buffer, and an open file a build rule transforms is a shadowed source that formats (#95) - #96
Merged
Conversation
…pen file a build rule transforms is a shadowed source that formats (#95) clangd restarted, and every module was prepared again, each time `import std` came into main.cpp or left it. std is built with the arguments of one representative unit: the first that imported std and was no interface, read from the edit buffer too. In a package whose build programs share the targets' toolchain and import std, typing the import made main.cpp the representative and saving without it moved std to a build program's unit, whose command differs (-I, -g, warnings). The representative is now chosen by set, then by unit, from what the build describes: the targets' sets before the build programs', a set that imports std as the build database states it before one that does not; in the set, its first unit that is no interface. The plan names it (plan.stdFollows) and the plan diff says when it moves. The mcpp-std-representative fixture drives the reported shape with mcpp's own build database: 0.23.0 restarts clangd at each save, this never. With `[build] sources = []` and a rule that generates the compiled unit from the file being edited (HuxerUI's hcg), the open original declared the module the generated copy provides: it was an ambiguous-module, the workspace degraded, and formatting answered nothing. The server now reads ide.generated (S1 7.2), and an open file no set describes that provides a module the build provides is a shadowed source: a notice and an information diagnostic naming the unit standing for it (generated-from, with the step, or outside-build), not an issue. A file the plan leaves out is formatted by clangd under a scratch name beside it, opened for the one request; what clangd says about that name is dropped. Files clangd set aside keep an empty answer, and the log and a not-formatted notice say why. Design: .agents/docs/2026-11-22-issue-95-std-command-stability-and-shadowed-sources-design.md
… the checkout's line endings
Sunrisepeak
force-pushed
the
fix/issue-95-std-and-shadowed-sources
branch
from
November 22, 2026 15:37
a8bedb5 to
8304ca1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #95. Design:
.agents/docs/2026-11-22-issue-95-std-command-stability-and-shadowed-sources-design.md(§8 the plan and its dependencies, §10 what implementing it found).What was wrong
stdis built with the arguments of one representative unit. It was the first unit that importedstdand was not an interface, and the edit buffer counted. In a package whose build programs share the targets' toolchain and importstd, typingimport std;intomain.cppmademain.cppthe representative. Saving without it movedstdto a build program's unit, whose command differs, and clangd restarted each time.degraded+ Format Document doing nothing. HuxerUI'shcggenerates the compiled unit fromsrc/app.cppm, and[build] sources = []. The open original was planned as a second provider ofapp, so it becameambiguous-module, was left out, and no formatter was asked.What changes (server only; no engine or mcpp change)
std's representative is chosen by set first: target sets before build-program sets, then a set that importsstdas the build database states it (never the buffer). Within that set it is the first non-interface unit. S3: the plan records the choice (plan.stdFollows), and the plan diff logsstd follows … now (was …).ide.generated(S1 §7.2), writes it back (the model cache keeps it), and reads the authored source of a generated unit from it: a statedorigin(emit build-database: a generated source does not say which authored file it is a transformed copy of (S1 ide.generated names it only among inputs) mcpp-community/mcpp#1004), else the single C++ input of the generating step.generated-fromwith the step, oroutside-build), not an issue, and the state staysready.<name>.mcppls-format<ext>, didOpen → format → didClose). Everything clangd says about that URI is dropped. G2a: files clangd set aside keep the empty answer, and anot-formattednotice and log line say why.stdwithout the project's-I) waits for experiments E2/E3 (design §7.5).Evidence
mcpp-std-representative(new conformance fixture, realmcpp emit build-database, the reported shape): removing and restoringimport std;inmain.cpp. 0.23.0 restarts clangd twice ("units are compiled with other arguments (std.compat.cppm)"), this branch never. Run locally on linux-x64 with mcpp 2026.11.20.1.shadowed-source(new, mock mcpp, thehcgshape): stateready, noambiguous-module, theshadowed-sourcediagnostic, and Format Document equal to the golden file with the fixture's.clang-format, through the scratch document.generated-from,outside-buildand the real two-provider ambiguity; G0 parse, round-trip andorigin/inputs.23.1.0-mcppls.12answers formatting for a just-opened scratch module unit in 1 ms, with the parent.clang-format.mcpp test630/630;devtools check all;validate.py; fixturesmcpp-build-programs,generated-module,format-explicit,mcpp-splitunchanged.