@@ -48,7 +48,9 @@ void PendingChangesMap::debounceAndUpdate(
4848
4949void PendingChangesMap::enqueueChange (
5050 const llvm::lsp::DidChangeTextDocumentParams ¶ms) {
51- const auto now = nowFn ();
51+ // Key by normalized LSP file path. If your pipeline allows multiple
52+ // spellings (symlinks/case), normalize upstream or canonicalize here.
53+ const auto now = std::chrono::steady_clock::now ();
5254 const std::string key = params.textDocument .uri .file ().str ();
5355
5456 std::scoped_lock lock (mu);
@@ -69,7 +71,7 @@ void PendingChangesMap::debounceAndThen(
6971 DebounceOptions options,
7072 std::function<void (std::unique_ptr<PendingChanges>)> cb) {
7173 const std::string key = params.textDocument .uri .file ().str ();
72- const auto scheduleTime = nowFn ();
74+ const auto scheduleTime = std::chrono::steady_clock::now ();
7375
7476 // If debounce is disabled, run on main thread
7577 if (options.disableDebounce ) {
@@ -85,7 +87,8 @@ void PendingChangesMap::debounceAndThen(
8587 // Simple timer: sleep min-quiet before checking. We rely on the fact
8688 // that newer edits can arrive while we sleep, updating lastChangeTime.
8789 if (options.debounceMinMs > 0 )
88- waitForMinMs (options.debounceMinMs , scheduleTime);
90+ std::this_thread::sleep_for (
91+ std::chrono::milliseconds (options.debounceMinMs ));
8992
9093 std::unique_ptr<PendingChanges>
9194 result; // decided under lock, callback after
@@ -95,7 +98,7 @@ void PendingChangesMap::debounceAndThen(
9598 auto it = pending.find (key);
9699 if (it != pending.end ()) {
97100 PendingChanges &pc = it->second ;
98- const auto now = nowFn ();
101+ const auto now = std::chrono::steady_clock::now ();
99102
100103 // quietSinceSchedule: if no newer edits arrived after we scheduled
101104 // this task, then we consider the burst "quiet" and flush now.
@@ -139,20 +142,5 @@ PendingChangesMap::takeAndErase(llvm::StringMap<PendingChanges>::iterator it) {
139142 return out;
140143}
141144
142- void PendingChangesMap::waitForMinMs (uint64_t ms,
143- SteadyClock::time_point start) {
144- if (!ms)
145- return ;
146- if (!useManualClock) {
147- std::this_thread::sleep_for (std::chrono::milliseconds (ms));
148- return ;
149- }
150- // Manual clock: busy-wait with yields until now() reaches start + ms.
151- const auto target = start + std::chrono::milliseconds (ms);
152- while (nowFn () < target) {
153- std::this_thread::yield ();
154- }
155- }
156-
157145} // namespace lsp
158146} // namespace circt
0 commit comments