mgrLM // Handle cases of missing EOF on writing user phrases.

- We always add std::endl prior to new phrase insertion. Reason: the upstream approach of detecting the existence of EOF seems not usable in Swift 5.
This commit is contained in:
ShikiSuen 2022-05-03 16:27:12 +08:00
parent b8c491cef6
commit 11e5c42ec7
1 changed files with 4 additions and 2 deletions

View File

@ -403,13 +403,15 @@ class mgrLangModel: NSObject {
// module shipped in the vChewing Phrase Editor. // module shipped in the vChewing Phrase Editor.
currentMarkedPhrase += "\t#𝙾𝚟𝚎𝚛𝚛𝚒𝚍𝚎" currentMarkedPhrase += "\t#𝙾𝚟𝚎𝚛𝚛𝚒𝚍𝚎"
} }
currentMarkedPhrase += "\n"
if let writeFile = FileHandle(forUpdatingAtPath: path), if let writeFile = FileHandle(forUpdatingAtPath: path),
let data = currentMarkedPhrase.data(using: .utf8) let data = currentMarkedPhrase.data(using: .utf8),
let endl = "\n".data(using: .utf8)
{ {
writeFile.seekToEndOfFile() writeFile.seekToEndOfFile()
writeFile.write(endl)
writeFile.write(data) writeFile.write(data)
writeFile.write(endl)
writeFile.closeFile() writeFile.closeFile()
} else { } else {
return false return false