Fix reinterpretation dialog for UTF-8

This commit is contained in:
1024jp 2024-01-08 16:50:31 +09:00
parent f603dc6aa6
commit 43dcaf03fc
2 changed files with 8 additions and 2 deletions

View File

@ -8,6 +8,12 @@
- Suppress displaying the dialog for saving in an incompatible encoding when once allowed.
### Fixes
- Fix an issue that the encoding reinterpretation option dialog is not displayed when the user changes a document encoding to UTF-8.
4.7.2 (625)
--------------------------

View File

@ -700,7 +700,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
// remove wrapped NSError to make RecoverableError work
// cf. [How to use RecoverableError to retry?](https://stackoverflow.com/questions/40352975/how-to-use-recoverableerror-to-retry)
let error = (error as NSError).userInfo[NSUnderlyingErrorKey] as? SavingError ?? error
let error = (error as NSError).underlyingErrors.first ?? error
return super.willPresentError(error)
}
@ -1046,7 +1046,7 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingChanging
guard fileEncoding != self.fileEncoding else { return }
// change encoding immediately if there is nothing to worry about
if self.fileURL == nil || self.textStorage.string.isEmpty || fileEncoding.encoding == .utf8 {
if self.fileURL == nil || self.textStorage.string.isEmpty {
return self.changeEncoding(to: fileEncoding)
}