mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Fix lossy
option in convert
command by scripting
This commit is contained in:
parent
8a3a9d7cea
commit
3f38e728c2
@ -18,6 +18,7 @@ develop
|
||||
- Fix an issue where the application could crash after lossy encoding change if line endings are CR/LF.
|
||||
- Fix an issue where incompatible charaters highlight could highlight wrong characters if line endings are CR/LF.
|
||||
- Fix an issue where the zoomed characer in the characer inspector was flipped when the popover is detached.
|
||||
- Fix an issue where `lossy` option in `convert` command by AppleScript scripting was ignored.
|
||||
- Fix an issue on the AppleScript scripting where `range` property of `document` contents could be wrong if document line endings are not LF. (thanks to Kaito Udagawa!).
|
||||
|
||||
|
||||
|
@ -210,7 +210,7 @@ extension Document {
|
||||
return .yes
|
||||
}
|
||||
|
||||
let lossy = (arguments?["Lossy"] as? Bool) ?? false
|
||||
let lossy = (arguments?["lossy"] as? Bool) ?? false
|
||||
|
||||
return self.changeEncoding(to: encoding, withUTF8BOM: false, askLossy: false, lossy: lossy) ? .yes : .no
|
||||
}
|
||||
|
@ -867,12 +867,15 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
|
||||
|
||||
let encodingName = String.localizedName(of: encoding, withUTF8BOM: withUTF8BOM)
|
||||
|
||||
// ask lossy
|
||||
if askLossy {
|
||||
guard self.string.canBeConverted(to: encoding) else {
|
||||
// check if conversion is lossy
|
||||
if !self.string.canBeConverted(to: encoding) {
|
||||
if askLossy {
|
||||
let error = EncodingError(kind: .lossyEncodingConversion, encoding: encoding, withUTF8BOM: withUTF8BOM, attempter: self)
|
||||
self.presentErrorAsSheet(error)
|
||||
return false
|
||||
|
||||
} else if !lossy {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user