Skip to content

Commit

Permalink
Fix infinite loading on large single line files in list view #10
Browse files Browse the repository at this point in the history
  • Loading branch information
RedCMD committed May 6, 2024
1 parent 3d15a82 commit 9fdd5d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/treeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const TreeDataProvider: vscode.TreeDataProvider<element> = {
treeLabel,
cachedRule._match ? vscode.TreeItemCollapsibleState.None : vscode.TreeItemCollapsibleState.Expanded, // TODO: toggle option
);
item.id = `${id}`;
item.description = timeFixed + "ms" + (time >= 1 ? ' ⚠️' : '');
// item.description = timeFixed + "ms" + (ruleChached[rule.matchedRuleId] == id /* && !cachedRule._match */ ? ' ⚠️' : '');
if (cachedRule._match) {
Expand Down Expand Up @@ -304,12 +305,13 @@ export const TreeDataProvider: vscode.TreeDataProvider<element> = {
const time = grammar.lines[line].time - (grammar.lines[line - 1]?.time ?? 0);
const timeFixed = time.toFixed(3);

const label = /* timeFixed + 'ms: ' + */ document.lineAt(line).text;
const label = /* timeFixed + 'ms: ' + */ document.lineAt(line).text.slice(0, 50);
const treeLabel: vscode.TreeItemLabel = {
label: label,
// highlights: time >= 10 ? [[0, timeFixed.length]] : null,
};
const item = new vscode.TreeItem(treeLabel, vscode.TreeItemCollapsibleState.Collapsed);
item.id = `${line}`;
item.description = timeFixed + "ms" + (time >= 500 ? ' ⚠️' : '');
item.iconPath = new vscode.ThemeIcon('symbol-key', new vscode.ThemeColor('symbolIcon.stringForeground'));
item.tooltip = `Line: ${line + 1}`;
Expand Down Expand Up @@ -348,6 +350,7 @@ export const TreeDataProvider: vscode.TreeDataProvider<element> = {
// highlights: time >= 10 ? [[0, timeFixed.length]] : null,
};
const item = new vscode.TreeItem(treeLabel, vscode.TreeItemCollapsibleState.Collapsed);
item.id = `${line}_${element.tokenId}`;
// Account for newlines in uncaptured tokens
const newLineAdjust = token.scopes.length == 1 && (grammar.lines[line].tokens.length - 1 == element.tokenId) ? 1 : 0;
item.description = token.startIndex + " - " + (token.endIndex - newLineAdjust);
Expand Down Expand Up @@ -382,6 +385,7 @@ export const TreeDataProvider: vscode.TreeDataProvider<element> = {
label: label,
};
const item = new vscode.TreeItem(treeLabel, vscode.TreeItemCollapsibleState.None);
item.id = `${line}_${element.tokenId}_${element.scopeId}`;

return item;
}
Expand Down

0 comments on commit 9fdd5d0

Please sign in to comment.