Skip to content

Commit e17628a

Browse files
authored
Simplify numbers regex (#1259)
## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet
1 parent e596dad commit e17628a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libs/cursorless-engine/tokenizer/tokenizer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ const FIXED_TOKENS = [
4242

4343
export const IDENTIFIER_WORD_REGEXES = ["\\p{L}", "\\p{M}", "\\p{N}"];
4444
const SINGLE_SYMBOLS_REGEX = "[^\\s\\w]";
45-
const NUMBERS_REGEX = "(?<=[^.\\d]|^)\\d+\\.\\d+(?=[^.\\d]|$)"; // (not-dot/digit digits dot digits not-dot/digit)
45+
// Accepts digits dot digits if not preceded or followed by a digit or dot. The
46+
// negative lookahed / lookbehind are to prevent matching numbers in semantic
47+
// versions (eg 1.2.3)
48+
const NUMBERS_REGEX = "(?<![.\\d])\\d+\\.\\d+(?![.\\d])";
4649

4750
interface Matcher {
4851
tokenMatcher: RegExp;

0 commit comments

Comments
 (0)