|
1158 | 1158 | _createClass(ExactMatch, [{ |
1159 | 1159 | key: "search", |
1160 | 1160 | value: function search(text) { |
1161 | | - var location = 0; |
1162 | | - var index; |
1163 | | - var indices = []; |
1164 | | - var patternLen = this.pattern.length; // Get all exact matches |
1165 | | - |
1166 | | - while ((index = text.indexOf(this.pattern, location)) > -1) { |
1167 | | - location = index + patternLen; |
1168 | | - indices.push([index, location - 1]); |
1169 | | - } |
1170 | | - |
1171 | | - var isMatch = !!indices.length; |
| 1161 | + var isMatch = text === this.pattern; |
1172 | 1162 | return { |
1173 | 1163 | isMatch: isMatch, |
1174 | | - score: isMatch ? 1 : 0, |
1175 | | - indices: indices |
| 1164 | + score: isMatch ? 0 : 1, |
| 1165 | + indices: [0, this.pattern.length - 1] |
1176 | 1166 | }; |
1177 | 1167 | } |
1178 | 1168 | }], [{ |
|
1183 | 1173 | }, { |
1184 | 1174 | key: "multiRegex", |
1185 | 1175 | get: function get() { |
1186 | | - return /^'"(.*)"$/; |
| 1176 | + return /^="(.*)"$/; |
1187 | 1177 | } |
1188 | 1178 | }, { |
1189 | 1179 | key: "singleRegex", |
1190 | 1180 | get: function get() { |
1191 | | - return /^'(.*)$/; |
| 1181 | + return /^=(.*)$/; |
1192 | 1182 | } |
1193 | 1183 | }]); |
1194 | 1184 |
|
|
1465 | 1455 | return FuzzyMatch; |
1466 | 1456 | }(BaseMatch); |
1467 | 1457 |
|
1468 | | - var searchers = [ExactMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch]; |
| 1458 | + var IncludeMatch = /*#__PURE__*/function (_BaseMatch) { |
| 1459 | + _inherits(IncludeMatch, _BaseMatch); |
| 1460 | + |
| 1461 | + var _super = _createSuper(IncludeMatch); |
| 1462 | + |
| 1463 | + function IncludeMatch(pattern) { |
| 1464 | + _classCallCheck(this, IncludeMatch); |
| 1465 | + |
| 1466 | + return _super.call(this, pattern); |
| 1467 | + } |
| 1468 | + |
| 1469 | + _createClass(IncludeMatch, [{ |
| 1470 | + key: "search", |
| 1471 | + value: function search(text) { |
| 1472 | + var location = 0; |
| 1473 | + var index; |
| 1474 | + var indices = []; |
| 1475 | + var patternLen = this.pattern.length; // Get all exact matches |
| 1476 | + |
| 1477 | + while ((index = text.indexOf(this.pattern, location)) > -1) { |
| 1478 | + location = index + patternLen; |
| 1479 | + indices.push([index, location - 1]); |
| 1480 | + } |
| 1481 | + |
| 1482 | + var isMatch = !!indices.length; |
| 1483 | + return { |
| 1484 | + isMatch: isMatch, |
| 1485 | + score: isMatch ? 1 : 0, |
| 1486 | + indices: indices |
| 1487 | + }; |
| 1488 | + } |
| 1489 | + }], [{ |
| 1490 | + key: "type", |
| 1491 | + get: function get() { |
| 1492 | + return 'include'; |
| 1493 | + } |
| 1494 | + }, { |
| 1495 | + key: "multiRegex", |
| 1496 | + get: function get() { |
| 1497 | + return /^'"(.*)"$/; |
| 1498 | + } |
| 1499 | + }, { |
| 1500 | + key: "singleRegex", |
| 1501 | + get: function get() { |
| 1502 | + return /^'(.*)$/; |
| 1503 | + } |
| 1504 | + }]); |
| 1505 | + |
| 1506 | + return IncludeMatch; |
| 1507 | + }(BaseMatch); |
| 1508 | + |
| 1509 | + var searchers = [ExactMatch, IncludeMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch]; |
1469 | 1510 | var searchersLen = searchers.length; // Regex to split by spaces, but keep anything in quotes together |
1470 | 1511 |
|
1471 | 1512 | var SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/; |
|
1522 | 1563 |
|
1523 | 1564 | // to a singl match |
1524 | 1565 |
|
1525 | | - var MultiMatchSet = new Set([FuzzyMatch.type, ExactMatch.type]); |
| 1566 | + var MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]); |
1526 | 1567 | /** |
1527 | 1568 | * Command-like searching |
1528 | 1569 | * ====================== |
|
1534 | 1575 | * |
1535 | 1576 | * | Token | Match type | Description | |
1536 | 1577 | * | ----------- | -------------------------- | -------------------------------------- | |
1537 | | - * | `jscript` | fuzzy-match | Items that match `jscript` | |
1538 | | - * | `'python` | exact-match | Items that include `python` | |
| 1578 | + * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` | |
| 1579 | + * | `=scheme` | exact-match | Items that are `scheme` | |
| 1580 | + * | `'python` | include-match | Items that include `python` | |
1539 | 1581 | * | `!ruby` | inverse-exact-match | Items that do not include `ruby` | |
1540 | 1582 | * | `^java` | prefix-exact-match | Items that start with `java` | |
1541 | 1583 | * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` | |
|
0 commit comments