From 412b8cdc988adbb408a22841417fc10aa1fd4374 Mon Sep 17 00:00:00 2001 From: MiccWan Date: Mon, 4 Apr 2022 16:36:15 +0800 Subject: [PATCH] fix `traceAtCursor` missing traces in VirtualContexts --- dbux-data/src/dataProviderUtil.js | 18 ++++++++++++++++-- .../indexes/TracesByRealStaticContextIndex.js | 3 +-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dbux-data/src/dataProviderUtil.js b/dbux-data/src/dataProviderUtil.js index 121c80aa3..6115b4abd 100644 --- a/dbux-data/src/dataProviderUtil.js +++ b/dbux-data/src/dataProviderUtil.js @@ -1657,11 +1657,11 @@ export default { /** @param {DataProvider} dp */ getRealStaticContextIdOfStaticContext(dp, staticContextId) { - const { parentId, type } = dp.collections.staticContexts.getById(staticContextId); + const { parentId } = dp.collections.staticContexts.getById(staticContextId); // NOTE: "first virtual" context of context is "real context" - if (!isVirtualStaticContextType(type)) { + if (dp.util.isRealStaticContext(staticContextId)) { return staticContextId; } @@ -1686,6 +1686,20 @@ export default { // return realContext.staticContextId; }, + /** @param {DataProvider} dp */ + isRealStaticContext(dp, staticContextId) { + const staticContext = dp.collections.staticContexts.getById(staticContextId); + if (!isVirtualStaticContextType(staticContext.type)) { + return true; + } + else if (staticContext.isInterruptable) { + // `isInterruptable === true` for the first virtual context + return true; + } + + return false; + }, + /** @param {DataProvider} dp */ getRealContextIdOfTrace(dp, traceId) { const { contextId } = dp.collections.traces.getById(traceId); diff --git a/dbux-data/src/impl/indexes/TracesByRealStaticContextIndex.js b/dbux-data/src/impl/indexes/TracesByRealStaticContextIndex.js index 490abf296..7807dac2f 100644 --- a/dbux-data/src/impl/indexes/TracesByRealStaticContextIndex.js +++ b/dbux-data/src/impl/indexes/TracesByRealStaticContextIndex.js @@ -15,8 +15,7 @@ export default class TracesByRealStaticContextIndex extends CollectionIndex { */ makeKey(dp, trace) { const { contextId } = trace; - const { staticContextId } = dp.collections.executionContexts.getById(contextId); - const realContextId = dp.util.getRealStaticContextIdOfStaticContext(staticContextId); + const realContextId = dp.util.getRealStaticContextIdOfContext(contextId); return realContextId || 0; }