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/dist/index.browser.js +51 -26
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +51 -26
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/intellisense/AutoComplete.test.ts +24 -0
- package/src/intellisense/AutoComplete.ts +1 -1
package/package.json
CHANGED
|
@@ -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
|
|
96
|
+
if (furthestMatch.endIndex > furthestError.lastIndex ) {
|
|
97
97
|
return furthestMatch.endIndex;
|
|
98
98
|
} else {
|
|
99
99
|
return furthestError.lastIndex;
|