Skip to content

Commit

Permalink
Show variable on first mention in display
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Jan 25, 2024
1 parent 4741f9c commit f76f2f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/webview/variables/variable-decorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EventEmitter, IEvent } from '../utils/events';
import { ColumnContribution } from '../columns/column-contribution-service';
import { Decorator } from '../decorations/decoration-service';
import { ReactNode } from 'react';
import { areVariablesEqual, compareBigInt, isWithin, BigIntMemoryRange, BigIntVariableRange } from '../../common/memory-range';
import { areVariablesEqual, compareBigInt, BigIntMemoryRange, BigIntVariableRange, doOverlap } from '../../common/memory-range';
import * as React from 'react';

const NON_HC_COLORS = [
Expand Down Expand Up @@ -82,17 +82,17 @@ export class VariableDecorator implements ColumnContribution, Decorator {
}, []);
}

/** Returns variables that start in the given range. */
protected lastCall?: bigint;
protected currentIndex = 0;
/** Returns variables that start in the given range. */
protected getVariablesInRange(range: BigIntMemoryRange): Array<{ variable: BigIntVariableRange, color: string }> | undefined {
if (!this.currentVariables?.length) { return undefined; }
if (this.currentIndex === this.currentVariables.length - 1 && this.currentVariables[this.currentIndex].startAddress < range.startAddress) { return undefined; }
if (this.lastCall === undefined || range.startAddress < this.lastCall) { this.currentIndex = 0; }
this.lastCall = range.startAddress;
const result = [];
while (this.currentIndex < this.currentVariables.length && this.currentVariables[this.currentIndex].startAddress < range.endAddress) {
if (isWithin(this.currentVariables[this.currentIndex].startAddress, range)) {
if (doOverlap(this.currentVariables[this.currentIndex], range)) {
result.push({ color: NON_HC_COLORS[this.currentIndex % 5], variable: this.currentVariables[this.currentIndex] });
}
this.currentIndex++;
Expand Down

0 comments on commit f76f2f3

Please sign in to comment.