Skip to content

Commit 22fceb9

Browse files
committed
Pull addons
1 parent 6669a37 commit 22fceb9

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/addons/addons/middle-click-popup/WorkspaceQuerier.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,8 @@ class TokenTypeBlock extends TokenType {
733733
strings.push(...blockPart.toLowerCase().split(" "));
734734
} else if (blockPart.type === BlockInputType.ENUM) {
735735
for (const enumValue of blockPart.values) {
736+
if (this.stringForms.length >= WorkspaceQuerier.MAX_RESULTS) return;
737+
736738
enumerateStringForms(
737739
partIdx + 1,
738740
[...strings, ...enumValue.string.toLowerCase().split(" ")],
@@ -749,6 +751,13 @@ class TokenTypeBlock extends TokenType {
749751
};
750752

751753
enumerateStringForms();
754+
755+
if (this.stringForms.length >= WorkspaceQuerier.MAX_STRING_FORMS) {
756+
console.warn(
757+
"Warning: Block '" + this.block.id + "' has too many string forms. Search results may not be very good."
758+
);
759+
this.stringForms.length = 0;
760+
}
752761
}
753762

754763
/**
@@ -1164,7 +1173,12 @@ export default class WorkspaceQuerier {
11641173
/**
11651174
* The maximum number of tokens to find before giving up.
11661175
*/
1167-
static MAX_TOKENS = 10000;
1176+
static MAX_TOKENS = 100000;
1177+
1178+
/**
1179+
* The maximum number of string forms a block can have before we give up.
1180+
*/
1181+
static MAX_STRING_FORMS = 500;
11681182

11691183
/**
11701184
* Indexes a workspace in preparation for querying it.
@@ -1208,12 +1222,12 @@ export default class WorkspaceQuerier {
12081222
}
12091223
++query.resultCount;
12101224
if (!limited && query.resultCount >= WorkspaceQuerier.MAX_RESULTS) {
1211-
console.log("Warning: Workspace query exceeded maximum result count.");
1225+
console.warn("Warning: Workspace query exceeded maximum result count.");
12121226
limited = true;
12131227
}
12141228

12151229
if (!query.canCreateMoreTokens()) {
1216-
console.log("Warning: Workspace query exceeded maximum token count.");
1230+
console.warn("Warning: Workspace query exceeded maximum token count.");
12171231
limited = true;
12181232
break;
12191233
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"commit":"df5f51e"}
1+
{"commit":"f41d6de"}

0 commit comments

Comments
 (0)