Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions log-viewer/modules/components/analysis-view/AnalysisView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class AnalysisView extends LitElement {
options: { matchCase: false },
};
totalMatches = 0;
blockClearHighlights = false;
blockClearHighlights = true;

constructor() {
super();
Expand Down Expand Up @@ -239,8 +239,7 @@ export class AnalysisView extends LitElement {
}
}

const hasHighlights = Object.keys(this.findMap).length !== 0;
if (!hasHighlights) {
if (this.totalMatches <= 0) {
return;
}
this.blockClearHighlights = true;
Expand Down Expand Up @@ -420,7 +419,7 @@ export class AnalysisView extends LitElement {
});

this.analysisTable.on('renderStarted', () => {
if (!this.blockClearHighlights) {
if (!this.blockClearHighlights && this.totalMatches > 0) {
this._resetFindWidget();
this._clearSearchHighlights();
}
Expand All @@ -432,11 +431,12 @@ export class AnalysisView extends LitElement {
}

_clearSearchHighlights() {
this._find(
new CustomEvent('lv-find-close', {
detail: { text: '', count: 0, options: { matchCase: false } },
}),
);
this.findArgs.text = '';
this.findArgs.count = 0;
//@ts-expect-error This is a custom function added in by Find custom module
this.analysisTable.clearFindHighlights(Object.values(this.findMap));
this.findMap = {};
this.totalMatches = 0;
}
}
export class Metric {
Expand Down
19 changes: 10 additions & 9 deletions log-viewer/modules/components/calltree-view/CalltreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class CalltreeView extends LitElement {
findMap: { [key: number]: RowComponent } = {};
totalMatches = 0;

blockClearHighlights = false;
blockClearHighlights = true;
searchString = '';
findArgs: { text: string; count: number; options: { matchCase: boolean } } = {
text: '',
Expand Down Expand Up @@ -361,6 +361,7 @@ export class CalltreeView extends LitElement {
if (clearHighlights) {
newFindArgs.text = '';
}

if (newSearch || clearHighlights) {
this.blockClearHighlights = true;
//@ts-expect-error This is a custom function added in by Find custom module
Expand All @@ -377,8 +378,7 @@ export class CalltreeView extends LitElement {
}

// Highlight the current row and reset the previous or next depending on whether we are stepping forward or back.
const hasHighlights = Object.keys(this.findMap).length !== 0;
if (!hasHighlights) {
if (this.totalMatches <= 0) {
return;
}
this.blockClearHighlights = true;
Expand Down Expand Up @@ -793,7 +793,7 @@ export class CalltreeView extends LitElement {
});

this.calltreeTable.on('renderStarted', () => {
if (!this.blockClearHighlights) {
if (!this.blockClearHighlights && this.totalMatches > 0) {
this._resetFindWidget();
this._clearSearchHighlights();
}
Expand All @@ -810,11 +810,12 @@ export class CalltreeView extends LitElement {
}

private _clearSearchHighlights() {
this._find(
new CustomEvent('lv-find-close', {
detail: { text: '', count: 0, options: { matchCase: false } },
}),
);
this.findArgs.text = '';
this.findArgs.count = 0;
//@ts-expect-error This is a custom function added in by Find custom module
this.calltreeTable.clearFindHighlights(Object.values(this.findMap));
this.findMap = {};
this.totalMatches = 0;
}

private _expandCollapseAll(rows: RowComponent[], expand: boolean = true) {
Expand Down
36 changes: 21 additions & 15 deletions log-viewer/modules/components/calltree-view/module/Find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class Find extends Module {
super(table);
// @ts-expect-error registerTableFunction() needs adding to tabulator types
this.registerTableFunction('find', this._find.bind(this));
// @ts-expect-error registerTableFunction() needs adding to tabulator types
this.registerTableFunction('clearFindHighlights', this._clearFindHighlights.bind(this));
}

initialize() {}
Expand Down Expand Up @@ -100,6 +102,16 @@ export class Find extends Module {
return result;
}

_clearFindHighlights(rows: RowComponent[]) {
this.table.blockRedraw();
for (const row of rows) {
const data = row.getData();
data.highlightIndexes = [];
row.reformat();
}
this.table.restoreRedraw();
}

_countMatches(elem: Node, findArgs: FindArgs, regex: RegExp) {
let count = 0;

Expand Down Expand Up @@ -201,25 +213,19 @@ export class Find extends Module {

export function formatter(row: RowComponent, findArgs: FindArgs) {
const { text, count } = findArgs;
if (!text || !count || !row.getData()) {
if (!text || !count || !row.getData() || !row.getData().highlightIndexes?.length) {
return;
}
requestAnimationFrame(() => {
const data = row.getData();
const highlights = {
indexes: data.highlightIndexes,
currentMatch: 0,
};

row.getCells().forEach((cell) => {
const cellElem = cell.getElement();
_highlightText(cellElem, findArgs, highlights);
});
const data = row.getData();
const highlights = {
indexes: data.highlightIndexes,
currentMatch: 0,
};

//@ts-expect-error This is private to tabulator, but we have no other choice atm.
if (row._getSelf().type === 'row') {
row.normalizeHeight();
}
row.getCells().forEach((cell) => {
const cellElem = cell.getElement();
_highlightText(cellElem, findArgs, highlights);
});
}

Expand Down
33 changes: 22 additions & 11 deletions log-viewer/modules/components/database-view/DMLView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class DMLView extends LitElement {
};
findMap: { [key: number]: RowComponent } = {};
totalMatches = 0;
blockClearHighlights = false;
blockClearHighlights = true;

constructor() {
super();
Expand Down Expand Up @@ -196,6 +196,7 @@ export class DMLView extends LitElement {
});
}

// todo: fix search on grouped data
_highlightMatches(highlightIndex: number) {
if (!this.dmlTable?.element?.clientHeight) {
return;
Expand Down Expand Up @@ -304,7 +305,7 @@ export class DMLView extends LitElement {
selectableRows: 'highlight',
dataTree: true,
dataTreeBranchElement: false,
dataTreeStartExpanded: true,
dataTreeStartExpanded: false,
columnDefaults: {
title: 'default',
resizable: true,
Expand Down Expand Up @@ -381,7 +382,9 @@ export class DMLView extends LitElement {
row.normalizeHeight();
}

formatter(row, this.findArgs);
requestAnimationFrame(() => {
formatter(row, this.findArgs);
});
},
});

Expand All @@ -391,9 +394,16 @@ export class DMLView extends LitElement {
return;
}

this.dmlTable?.blockRedraw();
group.toggle();
this.dmlTable?.restoreRedraw();
if (this.dmlTable && group.isVisible()) {
this.dmlTable.blockRedraw();
for (const row of group.getRows()) {
if (row.getTreeChildren() && !row.isTreeExpanded()) {
row.treeExpand();
}
}
this.dmlTable.restoreRedraw();
}
});

this.dmlTable.on('rowClick', function (e, row) {
Expand All @@ -413,7 +423,7 @@ export class DMLView extends LitElement {
});

this.dmlTable.on('renderStarted', () => {
if (!this.blockClearHighlights) {
if (!this.blockClearHighlights && this.totalMatches > 0) {
this._resetFindWidget();
this._clearSearchHighlights();
}
Expand All @@ -439,11 +449,12 @@ export class DMLView extends LitElement {
}

private _clearSearchHighlights() {
this._find(
new CustomEvent('lv-find-close', {
detail: { text: '', count: 0, options: { matchCase: false } },
}),
);
this.findArgs.text = '';
this.findArgs.count = 0;
//@ts-expect-error This is a custom function added in by Find custom module
this.dmlTable.clearFindHighlights(Object.values(this.findMap));
this.findMap = {};
this.totalMatches = 0;
}

_getTable() {
Expand Down
34 changes: 22 additions & 12 deletions log-viewer/modules/components/database-view/SOQLView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class SOQLView extends LitElement {
};
findMap: { [key: number]: RowComponent } = {};
totalMatches = 0;
blockClearHighlights = false;
blockClearHighlights = true;

get _soqlTableWrapper(): HTMLDivElement | null {
return this.renderRoot?.querySelector('#db-soql-table') ?? null;
Expand Down Expand Up @@ -346,7 +346,7 @@ export class SOQLView extends LitElement {
},
dataTree: true,
dataTreeBranchElement: false,
dataTreeStartExpanded: true,
dataTreeStartExpanded: false,
columnDefaults: {
title: 'default',
resizable: true,
Expand Down Expand Up @@ -510,7 +510,9 @@ export class SOQLView extends LitElement {
row.normalizeHeight();
}

formatter(row, this.findArgs);
requestAnimationFrame(() => {
formatter(row, this.findArgs);
});
},
});

Expand All @@ -519,10 +521,17 @@ export class SOQLView extends LitElement {
if (type === 'Range') {
return;
}

this.soqlTable?.blockRedraw();
group.toggle();
this.soqlTable?.restoreRedraw();

if (this.soqlTable && group.isVisible()) {
this.soqlTable.blockRedraw();
for (const row of group.getRows()) {
if (row.getTreeChildren() && !row.isTreeExpanded()) {
row.treeExpand();
}
}
this.soqlTable.restoreRedraw();
}
});

this.soqlTable.on('rowClick', function (e, row) {
Expand All @@ -542,7 +551,7 @@ export class SOQLView extends LitElement {
});

this.soqlTable.on('renderStarted', () => {
if (!this.blockClearHighlights) {
if (!this.blockClearHighlights && this.totalMatches > 0) {
this._resetFindWidget();
this._clearSearchHighlights();
}
Expand All @@ -568,11 +577,12 @@ export class SOQLView extends LitElement {
}

_clearSearchHighlights() {
this._find(
new CustomEvent('lv-find-close', {
detail: { text: '', count: 0, options: { matchCase: false } },
}),
);
this.findArgs.text = '';
this.findArgs.count = 0;
//@ts-expect-error This is a custom function added in by Find custom module
this.soqlTable.clearFindHighlights(Object.values(this.findMap));
this.findMap = {};
this.totalMatches = 0;
}

_getTable() {
Expand Down
Loading