clarity-pattern-parser 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/TextSuggester.ts
CHANGED
|
@@ -187,7 +187,7 @@ export default class TextSuggester {
|
|
|
187
187
|
let options = this.rootPattern?.getTokens();
|
|
188
188
|
|
|
189
189
|
options = options?.filter((option: any) => {
|
|
190
|
-
return option.indexOf(this.text)
|
|
190
|
+
return option.indexOf(this.text) === 0;
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
if (options?.length === 0) {
|
|
@@ -284,4 +284,14 @@ describe("TextInspector", () => {
|
|
|
284
284
|
expect(result.options.values[2]).toBe("FlagZ");
|
|
285
285
|
expect(result.options.values[3]).toBe("(");
|
|
286
286
|
});
|
|
287
|
+
|
|
288
|
+
test("Do not match on first partial token.", () => {
|
|
289
|
+
const expression = generateExpression(["FlagX", "FlagY", "FlagZ"]);
|
|
290
|
+
const result = TextSuggester.suggest("l", expression);
|
|
291
|
+
|
|
292
|
+
expect(result.options).toBe(null);
|
|
293
|
+
expect(result.error?.startIndex).toBe(0);
|
|
294
|
+
expect(result.error?.endIndex).toBe(0);
|
|
295
|
+
expect(result.error?.text).toBe("l");
|
|
296
|
+
});
|
|
287
297
|
});
|