Repository navigation
Fix MaxNumber incrementFileName bug - #50865
Conversation
|
|
||
| export function incrementFileName(name: string, isFolder: boolean): string { | ||
| const separators = '[\\.\\-_]'; | ||
| const maxNumber = 9007199254740991; |
There was a problem hiding this comment.
It looks like TS bindings are not exposing Number.MAX_SAFE_INTEGER (it was added in ES6 as far as I remember)
There was a problem hiding this comment.
Please use this instead of introducing a new maxNumber https://github.com/Microsoft/vscode/blob/master/src/vs/editor/common/core/uint.ts#L40
There was a problem hiding this comment.
Updated
|
|
||
| export function incrementFileName(name: string, isFolder: boolean): string { | ||
| const separators = '[\\.\\-_]'; | ||
| const maxNumber = 9007199254740991; |
There was a problem hiding this comment.
Please use this instead of introducing a new maxNumber https://github.com/Microsoft/vscode/blob/master/src/vs/editor/common/core/uint.ts#L40
| let suffixFileRegex = RegExp('(.*' + separators + ')(\\d+)(\\..*)$'); | ||
| if (!isFolder && name.match(suffixFileRegex)) { | ||
| return name.replace(suffixFileRegex, (match, g1?, g2?, g3?) => { | ||
| return g1 + strings.pad(parseInt(g2) + 1, g2.length) + g3; |
There was a problem hiding this comment.
Can we have a helper method for this?
Since this code seems like it is duplicated 4 times?
There was a problem hiding this comment.
It's bit different for every case since it formats the string in different formats, not sure if there is a sense in trying to extract that to helper function.
| @@ -88,6 +88,18 @@ suite('Files - Increment file name', () => { | |||
| assert.strictEqual(result, 'test_2'); | |||
| }); | |||
|
|
|||
|
Thanks for this PR. I have commented directly in the code. Once that is addressed we can merge this in. Thanks! |
Fix #50822
CC: Isidor Nikolic (@isidorn)