diff --git a/log-viewer/modules/components/analysis-view/AnalysisView.ts b/log-viewer/modules/components/analysis-view/AnalysisView.ts index 1b02a1ac..fbe530e3 100644 --- a/log-viewer/modules/components/analysis-view/AnalysisView.ts +++ b/log-viewer/modules/components/analysis-view/AnalysisView.ts @@ -110,6 +110,7 @@ export class AnalysisView extends LitElement { options: { matchCase: false }, }; totalMatches = 0; + blockClearHighlights = false; constructor() { super(); @@ -224,8 +225,10 @@ export class AnalysisView extends LitElement { newFindArgs.text = ''; } if (newSearch || clearHighlights) { + this.blockClearHighlights = true; //@ts-expect-error This is a custom function added in by Find custom module const result = this.analysisTable.find(this.findArgs); + this.blockClearHighlights = false; this.totalMatches = result.totalMatches; this.findMap = result.matchIndexes; @@ -236,6 +239,12 @@ export class AnalysisView extends LitElement { } } + const hasHighlights = Object.keys(this.findMap).length !== 0; + if (!hasHighlights) { + return; + } + this.blockClearHighlights = true; + this.analysisTable?.blockRedraw(); const currentRow = this.findMap[this.findArgs.count]; const rows = [ currentRow, @@ -247,6 +256,8 @@ export class AnalysisView extends LitElement { }); //@ts-expect-error This is a custom function added in by RowNavigation custom module this.analysisTable.goToRow(currentRow, { scrollIfVisible: false, focusRow: false }); + this.analysisTable?.restoreRedraw(); + this.blockClearHighlights = false; } async _renderAnalysis(rootMethod: ApexLog) { @@ -410,9 +421,11 @@ export class AnalysisView extends LitElement { ], }); - this.analysisTable.on('dataFiltering', () => { - this._resetFindWidget(); - this._clearSearchHighlights(); + this.analysisTable.on('renderStarted', () => { + if (!this.blockClearHighlights) { + this._resetFindWidget(); + this._clearSearchHighlights(); + } }); } diff --git a/log-viewer/modules/components/calltree-view/CalltreeView.ts b/log-viewer/modules/components/calltree-view/CalltreeView.ts index e552e062..73c323cf 100644 --- a/log-viewer/modules/components/calltree-view/CalltreeView.ts +++ b/log-viewer/modules/components/calltree-view/CalltreeView.ts @@ -57,7 +57,7 @@ export class CalltreeView extends LitElement { findMap: { [key: number]: RowComponent } = {}; totalMatches = 0; - canClearSearchHighlights = false; + blockClearHighlights = false; searchString = ''; findArgs: { text: string; count: number; options: { matchCase: boolean } } = { text: '', @@ -350,7 +350,6 @@ export class CalltreeView extends LitElement { if (!isTableVisible && !this.totalMatches) { return; } - this.canClearSearchHighlights = false; const newFindArgs = JSON.parse(JSON.stringify(e.detail)); const newSearch = @@ -363,8 +362,10 @@ export class CalltreeView extends LitElement { newFindArgs.text = ''; } if (newSearch || clearHighlights) { + this.blockClearHighlights = true; //@ts-expect-error This is a custom function added in by Find custom module const result = this.calltreeTable.find(this.findArgs); + this.blockClearHighlights = false; this.totalMatches = result.totalMatches; this.findMap = result.matchIndexes; @@ -375,6 +376,12 @@ 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) { + return; + } + this.blockClearHighlights = true; this.calltreeTable?.blockRedraw(); const currentRow = this.findMap[this.findArgs.count]; const rows = [ @@ -391,7 +398,7 @@ export class CalltreeView extends LitElement { this.calltreeTable.goToRow(currentRow, { scrollIfVisible: false, focusRow: false }); } this.calltreeTable?.restoreRedraw(); - this.canClearSearchHighlights = true; + this.blockClearHighlights = false; } _highlight(inputString: string, substring: string) { @@ -772,16 +779,6 @@ export class CalltreeView extends LitElement { ], }); - this.calltreeTable.on('dataFiltering', () => { - // With a datatree the dataFiltering event occurs multi times and we only want to call this once. - // We will reset the flag when the user next searches. - if (this.canClearSearchHighlights) { - this.canClearSearchHighlights = false; - this._resetFindWidget(); - this._clearSearchHighlights(); - } - }); - this.calltreeTable.on('dataFiltered', () => { totalTimeFilterCache.clear(); selfTimeFilterCache.clear(); @@ -791,6 +788,13 @@ export class CalltreeView extends LitElement { this.typeFilterCache.clear(); }); + this.calltreeTable.on('renderStarted', () => { + if (!this.blockClearHighlights) { + this._resetFindWidget(); + this._clearSearchHighlights(); + } + }); + this.calltreeTable.on('tableBuilt', () => { resolve(); }); diff --git a/log-viewer/modules/components/database-view/DMLView.ts b/log-viewer/modules/components/database-view/DMLView.ts index 7ea6d345..a9e39a04 100644 --- a/log-viewer/modules/components/database-view/DMLView.ts +++ b/log-viewer/modules/components/database-view/DMLView.ts @@ -62,7 +62,7 @@ export class DMLView extends LitElement { }; findMap: { [key: number]: RowComponent } = {}; totalMatches = 0; - canClearHighlights = false; + blockClearHighlights = false; constructor() { super(); @@ -204,6 +204,8 @@ export class DMLView extends LitElement { this.findArgs.count = highlightIndex; const currentRow = this.findMap[highlightIndex]; const rows = [currentRow, this.findMap[this.oldIndex]]; + this.blockClearHighlights = true; + this.dmlTable.blockRedraw(); rows.forEach((row) => { row?.reformat(); }); @@ -211,6 +213,8 @@ export class DMLView extends LitElement { //@ts-expect-error This is a custom function added in by RowNavigation custom module this.dmlTable.goToRow(currentRow, { scrollIfVisible: false, focusRow: false }); } + this.dmlTable.restoreRedraw(); + this.blockClearHighlights = false; this.oldIndex = highlightIndex; } @@ -220,8 +224,6 @@ export class DMLView extends LitElement { return; } - this.canClearHighlights = true; - const newFindArgs = JSON.parse(JSON.stringify(e.detail)); if (!isTableVisible) { newFindArgs.text = ''; @@ -237,8 +239,10 @@ export class DMLView extends LitElement { newFindArgs.text = ''; } if (newSearch || clearHighlights) { + this.blockClearHighlights = true; //@ts-expect-error This is a custom function added in by Find custom module const result = this.dmlTable.find(this.findArgs); + this.blockClearHighlights = false; this.totalMatches = result.totalMatches; this.findMap = result.matchIndexes; @@ -250,7 +254,6 @@ export class DMLView extends LitElement { ); } } - this.canClearHighlights = false; } _renderDMLTable(dmlTableContainer: HTMLElement, dmlLines: DMLBeginLine[]) { @@ -380,13 +383,6 @@ export class DMLView extends LitElement { }, }); - this.dmlTable.on('dataFiltering', () => { - if (this.canClearHighlights) { - this._resetFindWidget(); - this._clearSearchHighlights(); - } - }); - this.dmlTable.on('groupClick', (e: UIEvent, group: GroupComponent) => { const { type } = window.getSelection() ?? {}; if (type === 'Range') { @@ -415,6 +411,11 @@ export class DMLView extends LitElement { }); this.dmlTable.on('renderStarted', () => { + if (!this.blockClearHighlights) { + this._resetFindWidget(); + this._clearSearchHighlights(); + } + const holder = this._getTableHolder(); holder.style.minHeight = holder.clientHeight + 'px'; holder.style.overflowAnchor = 'none'; diff --git a/log-viewer/modules/components/database-view/SOQLView.ts b/log-viewer/modules/components/database-view/SOQLView.ts index 2915fe9b..7d9e7150 100644 --- a/log-viewer/modules/components/database-view/SOQLView.ts +++ b/log-viewer/modules/components/database-view/SOQLView.ts @@ -73,7 +73,7 @@ export class SOQLView extends LitElement { }; findMap: { [key: number]: RowComponent } = {}; totalMatches = 0; - canClearHighlights = false; + blockClearHighlights = false; get _soqlTableWrapper(): HTMLDivElement | null { return this.renderRoot?.querySelector('#db-soql-table') ?? null; @@ -235,6 +235,8 @@ export class SOQLView extends LitElement { this.findArgs.count = highlightIndex; const currentRow = this.findMap[highlightIndex]; + this.blockClearHighlights = true; + this.soqlTable.blockRedraw(); const rows = [currentRow, this.findMap[this.oldIndex]]; rows.forEach((row) => { row?.reformat(); @@ -244,6 +246,8 @@ export class SOQLView extends LitElement { //@ts-expect-error This is a custom function added in by RowNavigation custom module this.soqlTable.goToRow(currentRow, { scrollIfVisible: false, focusRow: false }); } + this.soqlTable.restoreRedraw(); + this.blockClearHighlights = false; this.oldIndex = highlightIndex; } @@ -254,8 +258,6 @@ export class SOQLView extends LitElement { return; } - this.canClearHighlights = true; - const newFindArgs = JSON.parse(JSON.stringify(e.detail)); const newSearch = newFindArgs.text !== this.findArgs.text || @@ -267,8 +269,10 @@ export class SOQLView extends LitElement { newFindArgs.text = ''; } if (newSearch || clearHighlights) { + this.blockClearHighlights = true; //@ts-expect-error This is a custom function added in by Find custom module const result = this.soqlTable.find(this.findArgs); + this.blockClearHighlights = false; this.totalMatches = 0; this.findMap = result.matchIndexes; @@ -280,8 +284,6 @@ export class SOQLView extends LitElement { ); } } - - this.canClearHighlights = false; } _renderSOQLTable(soqlTableContainer: HTMLElement, soqlLines: SOQLExecuteBeginLine[]) { @@ -537,14 +539,12 @@ export class SOQLView extends LitElement { row.getCell('soql').getElement().style.height = origRowHeight + 'px'; }); - this.soqlTable.on('dataFiltering', () => { - if (this.canClearHighlights) { + this.soqlTable.on('renderStarted', () => { + if (!this.blockClearHighlights) { this._resetFindWidget(); this._clearSearchHighlights(); } - }); - this.soqlTable.on('renderStarted', () => { const holder = this._getTableHolder(); holder.style.minHeight = holder.clientHeight + 'px'; holder.style.overflowAnchor = 'none';