Skip to content

Commit

Permalink
v1.6.0 all docs in events explorer
Browse files Browse the repository at this point in the history
selecting first line does not reveal line 0
  • Loading branch information
mbehr1 committed May 9, 2020
1 parent f15db09 commit b6a68ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to the "smart-log" extension will be documented in this file

<!-- Check [Keep a Changelog](http:https://keepachangelog.com/) for recommendations on how to structure this file. -->

## [1.6.0]
- Events explorer shows events for all open documents as preparation to compare/diff event trees.

## [1.5.1]
- change the checkActiveExtensions impl. Debounce a bit.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "smart-log",
"displayName": "Smart-Log",
"description": "Provides analysis and visualization features for text based log files.",
"version": "1.5.1",
"version": "1.6.0",
"license": "CC BY-NC-SA 4.0",
"publisher": "mbehr1",
"author": {
Expand Down
23 changes: 8 additions & 15 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export default class SmartLogs implements vscode.TreeDataProvider<EventNode>, vs
});
this._subscriptions.push(this._smartLogTreeView.onDidChangeSelection(event => {
console.log(`smartLogTreeView.onDidChangeSelection(${event.selection.length} ${event.selection[0].uri})`);
if (event.selection.length && event.selection[0].uri) {
if (event.selection.length && event.selection[0].uri && event.selection[0].uri.fragment.length > 0) {
// find the editor for this uri in active docs:
let uriWoFrag = event.selection[0].uri.with({ fragment: "" }).toString();
const activeTextEditors = vscode.window.visibleTextEditors;
Expand All @@ -424,7 +424,6 @@ export default class SmartLogs implements vscode.TreeDataProvider<EventNode>, vs

}
}));
this._smartLogTreeView.reveal({ label: "", uri: null, parent: null, children: [] });
}
}
}
Expand Down Expand Up @@ -679,7 +678,7 @@ export default class SmartLogs implements vscode.TreeDataProvider<EventNode>, vs

console.log(` identifiedFileConfig ${identifiedFileConfig.name} matches with ${rEvents.length}!`);

let eventRoot: EventNode = { label: identifiedFileConfig.name, uri: doc.uri, parent: null, children: [] };
let eventRoot: EventNode = { label: `${identifiedFileConfig.name}:${path.basename(doc.uri.fsPath)}`, uri: doc.uri, parent: null, children: [] };
let decorations = new Map<vscode.TextEditorDecorationType, vscode.DecorationOptions[]>();

function getParent(level: number): EventNode {
Expand Down Expand Up @@ -741,6 +740,7 @@ export default class SmartLogs implements vscode.TreeDataProvider<EventNode>, vs
} catch (error) {
console.log(`error: ${error} occurred!`);
}
const doReveal = !data.eventTreeNode;
data.eventTreeNode = eventRoot;

data.decorations = new Array<[vscode.TextEditorDecorationType, Array<vscode.DecorationOptions>]>();
Expand All @@ -754,6 +754,7 @@ export default class SmartLogs implements vscode.TreeDataProvider<EventNode>, vs
this.updateDecorations(data);
// we fire here the event as well to update the tree:
this._onDidChangeTreeData.fire();
if (doReveal) { this._smartLogTreeView?.reveal(data.eventTreeNode, { select: false, focus: false, expand: false }); }

// start generating the cache here:
this.provideTimeByData(data, data.doc.lineCount - 1);
Expand Down Expand Up @@ -815,18 +816,10 @@ export default class SmartLogs implements vscode.TreeDataProvider<EventNode>, vs

public getChildren(element?: EventNode): EventNode[] | Thenable<EventNode[]> {
// console.log(`smart-log.getChildren(${element?.label}, ${element?.uri?.toString()}) this=${this} called.`);
if (!element) { // if no element we have to return the root element.
// check whether we have a EventNode for the current document:
const doc = vscode.window.activeTextEditor?.document;
if (doc && this) {
const node = this._documents.get(doc.uri.toString())?.eventTreeNode;
if (node) {
// console.log(` eventTreeNode for doc ${doc.uri.toString()} found`);
return [node];
}
console.log(` no eventTreeNode for doc ${doc.uri.toString()} available`);
}
return [{ label: "", uri: null, parent: null, children: [] }];
if (!element) { // if no element we have to return the root elements.
let nodeArray: EventNode[] = [];
this._documents.forEach((data) => { if (data.eventTreeNode) { nodeArray.push(data.eventTreeNode); } });
return nodeArray;
} else {
return element.children;
}
Expand Down

0 comments on commit b6a68ca

Please sign in to comment.