clarity-pattern-parser 11.3.7 → 11.3.9

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-pattern-parser",
3
- "version": "11.3.7",
3
+ "version": "11.3.9",
4
4
  "description": "Parsing Library for Typescript and Javascript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -123,6 +123,30 @@ describe("AutoComplete", () => {
123
123
  expect(result.cursor).not.toBeNull();
124
124
  });
125
125
 
126
+
127
+ test("Option should error at furthest match index", () => {
128
+ const john = new Literal("john", "John");
129
+ const space = new Literal("space", " ");
130
+ const doe = new Literal("doe", "Doe");
131
+ const smith = new Literal("smith", "Smith");
132
+ const name = new Sequence("name", [john, space, new Options("last-name", [smith, doe])]);
133
+
134
+ const text = "John Smi"
135
+ const autoComplete = new AutoComplete(name);
136
+ const result = autoComplete.suggestFor(text);
137
+ const expectedOptions = [{
138
+ text: "th",
139
+ startIndex: 8
140
+ }];
141
+
142
+ expect(result.ast).toBeNull();
143
+ expect(result.options).toEqual(expectedOptions);
144
+ expect(result.errorAtIndex).toBe(text.length);
145
+ expect(result.isComplete).toBeFalsy();
146
+ expect(result.cursor).not.toBeNull();
147
+ });
148
+
149
+
126
150
  test("Root Regex Pattern suggests customTokens", () => {
127
151
  const freeTextPattern = new Regex(
128
152
  `free-text`,
@@ -93,7 +93,7 @@ export class AutoComplete {
93
93
  const furthestMatch = cursor.allMatchedNodes[cursor.allMatchedNodes.length - 1];
94
94
 
95
95
  if (furthestError && furthestMatch) {
96
- if (furthestError.lastIndex > furthestMatch.endIndex) {
96
+ if (furthestMatch.endIndex > furthestError.lastIndex ) {
97
97
  return furthestMatch.endIndex;
98
98
  } else {
99
99
  return furthestError.lastIndex;