mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Fix UInt conversion
This commit is contained in:
parent
d44179acae
commit
566fdfea44
@ -11,6 +11,7 @@ develop
|
||||
- Fix an issue where new syntax style could't be created.
|
||||
- Fix an issue where new value of last edited text field in preferences was occasionally discarded.
|
||||
- Fix a possible crash on application termination.
|
||||
- Fix a possible crash on opening document.
|
||||
- Fix error message of syntax style valitation.
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ extension UserDefaults {
|
||||
|
||||
subscript(key: DefaultKey<UInt>) -> UInt {
|
||||
|
||||
get { return UInt(self.integer(forKey: key.rawValue)) }
|
||||
get { return UInt(exactly: self.integer(forKey: key.rawValue)) ?? 0 }
|
||||
set { self.set(newValue, forKey: key.rawValue) }
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,8 @@ final class Document: NSDocument, AdditionalDocumentPreparing, EncodingHolder {
|
||||
let uuid = UUID().uuidString
|
||||
self.autosaveIdentifier = uuid.substring(to: uuid.index(uuid.startIndex, offsetBy: UniqueFileIDLength))
|
||||
|
||||
self.encoding = String.Encoding(rawValue: Defaults[.encodingInNew])
|
||||
let encoding = String.Encoding(rawValue: Defaults[.encodingInNew])
|
||||
self.encoding = String.availableStringEncodings.contains(encoding) ? encoding : .utf8
|
||||
if self.encoding == .utf8 {
|
||||
self.hasUTF8BOM = Defaults[.saveUTF8BOM]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user