Skip to content

Commit cf70ad0

Browse files
Updated increments/decrement number regex with better handling for underscores (#3194)
1 parent d2c3100 commit cf70ad0

3 files changed

Lines changed: 101 additions & 1 deletion

File tree

‎data/fixtures/recorded/actions/incrementDecrement/decrementFile3.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ initialState:
1717
10_000.0_10
1818
010_000.0
1919
0_0.0_1
20+
a_b, 1
21+
1
22+
1_2
23+
1_
24+
_1
25+
1_2_3.4_5_6
26+
_
2027
selections:
2128
- anchor: {line: 0, character: 0}
2229
active: {line: 0, character: 0}
@@ -28,6 +35,13 @@ finalState:
2835
9_999.0_10
2936
009_999.0
3037
-0_0.0_9
38+
a_b, 0
39+
0
40+
1_1
41+
0_
42+
_0
43+
1_2_2.4_5_6
44+
_
3145
selections:
3246
- anchor: {line: 0, character: 0}
3347
active: {line: 0, character: 0}
@@ -62,3 +76,39 @@ finalState:
6276
end: {line: 4, character: 8}
6377
isReversed: false
6478
hasExplicitRange: true
79+
- type: UntypedTarget
80+
contentRange:
81+
start: {line: 5, character: 5}
82+
end: {line: 5, character: 6}
83+
isReversed: false
84+
hasExplicitRange: true
85+
- type: UntypedTarget
86+
contentRange:
87+
start: {line: 6, character: 0}
88+
end: {line: 6, character: 1}
89+
isReversed: false
90+
hasExplicitRange: true
91+
- type: UntypedTarget
92+
contentRange:
93+
start: {line: 7, character: 0}
94+
end: {line: 7, character: 3}
95+
isReversed: false
96+
hasExplicitRange: true
97+
- type: UntypedTarget
98+
contentRange:
99+
start: {line: 8, character: 0}
100+
end: {line: 8, character: 1}
101+
isReversed: false
102+
hasExplicitRange: true
103+
- type: UntypedTarget
104+
contentRange:
105+
start: {line: 9, character: 1}
106+
end: {line: 9, character: 2}
107+
isReversed: false
108+
hasExplicitRange: true
109+
- type: UntypedTarget
110+
contentRange:
111+
start: {line: 10, character: 0}
112+
end: {line: 10, character: 11}
113+
isReversed: false
114+
hasExplicitRange: true

‎data/fixtures/recorded/actions/incrementDecrement/incrementFile3.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ initialState:
1717
10_000.0_10
1818
010_000.0
1919
0_0.0_1
20+
a_b, 1
21+
1
22+
1_2
23+
1_
24+
_1
25+
1_2_3.4_5_6
26+
_
2027
selections:
2128
- anchor: {line: 0, character: 0}
2229
active: {line: 0, character: 0}
@@ -28,6 +35,13 @@ finalState:
2835
10_001.0_10
2936
010_001.0
3037
0_0.1_1
38+
a_b, 2
39+
2
40+
1_3
41+
2_
42+
_2
43+
1_2_4.4_5_6
44+
_
3145
selections:
3246
- anchor: {line: 0, character: 0}
3347
active: {line: 0, character: 0}
@@ -62,3 +76,39 @@ finalState:
6276
end: {line: 4, character: 7}
6377
isReversed: false
6478
hasExplicitRange: true
79+
- type: UntypedTarget
80+
contentRange:
81+
start: {line: 5, character: 5}
82+
end: {line: 5, character: 6}
83+
isReversed: false
84+
hasExplicitRange: true
85+
- type: UntypedTarget
86+
contentRange:
87+
start: {line: 6, character: 0}
88+
end: {line: 6, character: 1}
89+
isReversed: false
90+
hasExplicitRange: true
91+
- type: UntypedTarget
92+
contentRange:
93+
start: {line: 7, character: 0}
94+
end: {line: 7, character: 3}
95+
isReversed: false
96+
hasExplicitRange: true
97+
- type: UntypedTarget
98+
contentRange:
99+
start: {line: 8, character: 0}
100+
end: {line: 8, character: 1}
101+
isReversed: false
102+
hasExplicitRange: true
103+
- type: UntypedTarget
104+
contentRange:
105+
start: {line: 9, character: 1}
106+
end: {line: 9, character: 2}
107+
isReversed: false
108+
hasExplicitRange: true
109+
- type: UntypedTarget
110+
contentRange:
111+
start: {line: 10, character: 0}
112+
end: {line: 10, character: 11}
113+
isReversed: false
114+
hasExplicitRange: true

‎packages/cursorless-engine/src/actions/incrementDecrement.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { runForEachEditor } from "../util/targetUtils";
77
import type { Actions } from "./Actions";
88
import type { ActionReturnValue } from "./actions.types";
99

10-
const REGEX = /-?[\d_]+(\.[\d_]+)?/g;
10+
const REGEX = /-?\d+(?:_?\d+)*(\.\d+(?:_?\d+)*)?/g;
1111

1212
class IncrementDecrement {
1313
constructor(

0 commit comments

Comments
 (0)