forked from 1b-agent/opencadstudio-upstream
plugin: announce DocumentOpened once per load, not per tab switch
The guard remembered only the last announced (tab, generation), so switching A -> B -> A announced A's load again. Each tab now carries its own pending flag, set when a document is installed and cleared by the boundary dispatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
68330ce39e
commit
4d66a58374
7 files changed
+28
-51
No files matched your search
@@ -344,9 +344,9 @@ impl OpenCADStudio {
|
||||
|
||||
/// Announce that a whole document became resident in the active tab —
|
||||
/// opened from file, created from a template, or loaded by a system open
|
||||
/// (API v9). Keyed on `(tab id, document generation)`, which changes only
|
||||
/// when a tab's content is wholesale replaced, so an edit can never fire
|
||||
/// it twice and a reload fires it exactly once. Part of the same
|
||||
/// (API v9). Each tab carries its own pending flag, set only when its
|
||||
/// content is wholesale replaced, so neither an edit nor a tab switch can
|
||||
/// fire it twice and a reload fires it exactly once. Part of the same
|
||||
/// post-message boundary as the selection and document dispatches: runs
|
||||
/// after the mutation settles and pending history scopes closed, never
|
||||
/// inside history replay or interactive picking.
|
||||
@@ -359,11 +359,9 @@ impl OpenCADStudio {
|
||||
if self.tabs[i].is_start {
|
||||
return;
|
||||
}
|
||||
let key = (self.tabs[i].id, self.tabs[i].document_generation);
|
||||
if self.last_plugin_document_opened == Some(key) {
|
||||
if !std::mem::take(&mut self.tabs[i].document_opened_pending) {
|
||||
return;
|
||||
}
|
||||
self.last_plugin_document_opened = Some(key);
|
||||
crate::plugin::v4_support::publish_document_opened(self.tabs[i].id);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user