-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix backup storage by looking at the options correctly #13983
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Backup on custom editors is being ignored. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,7 +276,7 @@ export class NativeEditorStorage implements INotebookStorage { | |
// Attempt to read the contents if a viable file | ||
const contents = NativeEditorStorage.isUntitledFile(file) ? possibleContents : await this.fs.readFile(file); | ||
|
||
const skipDirtyContents = typeof options === 'boolean' ? options : !!options; | ||
const skipDirtyContents = typeof options === 'boolean' ? options : !options || options.length === 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not going to lie. I find lines 279 - 282 really hard to read. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's really why this bug happened. The skipDirtyContents and the backupId are both confusing. I think it would have been better to just add another argument to the function instead of having the overload. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel unclean just reading the function signature. I guess it's ok. Maybe we could distinctly split on if the options is a bool or a string and put it in a local variable name that actually makes sense? if (typeof options === 'boolean') { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, @IanMatthewHuff suggestion will improve readability significantly |
||
// Use backupId provided, else use static storage key. | ||
const backupId = | ||
typeof options === 'string' ? options : skipDirtyContents ? undefined : this.getStaticStorageKey(file); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root cause of the problem was the
!!options
was the opposite of what we wanted. This would turn an options into a true, whereas we really wanted any options to turn it into a false.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aahg, the problem was options was an empty array.