-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc fixes #704
misc fixes #704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { newLogger } from '@dbux/common/src/log/logger'; | ||
import NestedError from '@dbux/common/src/NestedError'; | ||
import allApplications from '@dbux/data/src/applications/allApplications'; | ||
import traceSelection from '@dbux/data/src/traceSelection'; | ||
import searchController from '../search/searchController'; | ||
|
@@ -49,8 +50,18 @@ export default class GlobalAnalysisViewController { | |
* #########################################################################*/ | ||
|
||
async focusOnSearchResult() { | ||
const searchResultNode = this.treeDataProvider.getNodeByClass(GlobalSearchNode); | ||
await this.treeView.reveal(searchResultNode, { select: false, expand: 1 }); | ||
const searchResultNode = this.treeDataProvider.getRootByClass(GlobalSearchNode); | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MiccWan |
||
/** | ||
* NOTE: VSCode sometimes failed to reveal if `refresh` is executing simultaneously, which causes an error: | ||
* `Error: TreeError [dbuxTraceDetailsView] Data tree node not found: [object Object]`. | ||
* But currently VSCode API does not support thenable `refresh`. | ||
*/ | ||
await this.treeView.reveal(searchResultNode, { select: false, expand: 1 }); | ||
} | ||
catch (err) { | ||
warn(new NestedError(`Failed to focus on search result`, err)); | ||
} | ||
} | ||
|
||
/** ########################################################################### | ||
|
@@ -64,10 +75,10 @@ export default class GlobalAnalysisViewController { | |
|
||
async revealSelectedError() { | ||
if (!this.children) { | ||
const errorNode = this.treeDataProvider.getNodeByClass(GlobalErrorsNode); | ||
const errorNode = this.treeDataProvider.getRootByClass(GlobalErrorsNode); | ||
await this.treeView.reveal(errorNode, { select: false, expand: true }); | ||
} | ||
const errorNode = this.treeDataProvider.getNodeByClass(GlobalErrorsNode); | ||
const errorNode = this.treeDataProvider.getRootByClass(GlobalErrorsNode); | ||
const selectedErrorNode = errorNode.getSelectedChild(); | ||
if (selectedErrorNode) { | ||
await this.treeView.reveal(selectedErrorNode); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import sleep from './sleep'; | ||
|
||
export default class TriggerablePromise { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to |
||
promise; | ||
|
||
_resolve; | ||
_reject; | ||
|
||
constructor(timeout) { | ||
this.timeout = timeout; | ||
} | ||
|
||
startIfNotStarted() { | ||
if (!this.promise) { | ||
this.start(); | ||
} | ||
return this.promise; | ||
} | ||
|
||
start() { | ||
const promise = new Promise((resolve, reject) => { | ||
this._resolve = resolve; | ||
this._reject = reject; | ||
}); | ||
|
||
if (this.timeout) { | ||
this.promise = Promise.race([promise, sleep(this.timeout).then(() => this.resolve())]); | ||
} | ||
else { | ||
this.promise = promise; | ||
} | ||
} | ||
|
||
resolve(arg) { | ||
if (this.promise) { | ||
this._handleFinish(); | ||
this._resolve(arg); | ||
} | ||
} | ||
|
||
reject(arg) { | ||
if (this.promise) { | ||
this._handleFinish(); | ||
this._reject(arg); | ||
} | ||
} | ||
|
||
wait() { | ||
return this.promise; | ||
} | ||
|
||
_handleFinish() { | ||
this.promise = null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,12 +329,12 @@ class CallGraphNodes { | |
context, | ||
}); | ||
this.contextNodesByContext.set(context, node); | ||
|
||
node.addDisposable(() => { | ||
this._handleContextNodeDisposed(context, node); | ||
}); | ||
} | ||
|
||
node.addDisposable(() => { | ||
this._handleContextNodeDisposed(node); | ||
}); | ||
|
||
return node; | ||
} | ||
|
||
|
@@ -403,10 +403,26 @@ class CallGraphNodes { | |
* dispose, delete, clear | ||
* ##########################################################################*/ | ||
|
||
_handleContextNodeDisposed = (context, contextNode) => { | ||
if (this.getContextNodeByContext(context) === contextNode) { | ||
// actual removal of node | ||
this.contextNodesByContext.delete(context); | ||
/** | ||
* remove disposed node from `this.contextNodesByContext` | ||
* @param {ContextNode | HoleNode} node | ||
*/ | ||
_handleContextNodeDisposed = (node) => { | ||
let contexts; | ||
if (node instanceof ContextNode) { | ||
contexts = [node.state.context]; | ||
} | ||
else if (node instanceof HoleNode) { | ||
contexts = node.group.contexts; | ||
} | ||
else { | ||
throw new Error(`Calling "_handleContextNodeDisposed" with non-ContextNode parameter`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
} | ||
|
||
for (const context of contexts) { | ||
if (this.getContextNodeByContext(context) === node) { | ||
this.contextNodesByContext.delete(context); | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MiccWan move to
BaseTreeViewNode