@@ -8,13 +8,13 @@ const sanitizeFilePath = (filePath: string) =>
8
8
const diffCacheKey = ( filePath : string , staged : boolean ) : string =>
9
9
JSON . stringify ( [ path . resolve ( filePath ) , staged ] ) ;
10
10
11
+ const diffCache = new Map < string , string > ( ) ;
11
12
const setCachedDiff = ( filePath : string , staged : boolean , diff : string ) : void =>
12
13
void diffCache . set ( diffCacheKey ( filePath , staged ) , diff ) ;
13
14
14
15
const getCachedDiff = ( filePath : string , staged : boolean ) =>
15
16
diffCache . get ( diffCacheKey ( filePath , staged ) ) ;
16
17
17
- const diffCache = new Map < string , string > ( ) ;
18
18
const getDiffForFile = ( filePath : string , staged = false ) : string => {
19
19
let diff = getCachedDiff ( filePath , staged ) ;
20
20
if ( diff === undefined ) {
@@ -103,7 +103,7 @@ const hasCleanIndex = (filePath: string): boolean => {
103
103
} ;
104
104
105
105
const isHunkHeader = ( input : string ) => {
106
- const hunkHeaderRE = new RegExp ( / ^ @ @ [ ^ @ ] * @ @ / ) ;
106
+ const hunkHeaderRE = / ^ @ @ [ ^ @ ] * @ @ / u ;
107
107
return hunkHeaderRE . exec ( input ) ;
108
108
} ;
109
109
@@ -115,9 +115,8 @@ const getRangeForChangedLines = (line: string) => {
115
115
* linesCountDelimiter: ',2',
116
116
* linesCount: '2',
117
117
*/
118
- const rangeRE = new RegExp (
119
- / ^ @ @ .* \+ (?< start > \d + ) (?< linesCountDelimiter > , (?< linesCount > \d + ) ) ? @ @ /
120
- ) ;
118
+ const rangeRE =
119
+ / ^ @ @ .* \+ (?< start > \d + ) (?< linesCountDelimiter > , (?< linesCount > \d + ) ) ? @ @ / u;
121
120
const range = rangeRE . exec ( line ) ;
122
121
if ( range === null ) {
123
122
throw Error ( `Couldn't match regex with line '${ line } '` ) ;
0 commit comments