InputState // Defer certain variable initialization processes.

This commit is contained in:
ShikiSuen 2022-06-16 08:41:01 +08:00
parent f4b164b05c
commit ed98a4a7ea
1 changed files with 3 additions and 2 deletions

View File

@ -114,7 +114,8 @@ class InputState {
init(composingBuffer: String, cursorIndex: Int) {
self.composingBuffer = composingBuffer
self.cursorIndex = cursorIndex
super.init()
defer { self.cursorIndex = cursorIndex }
}
var description: String {
@ -223,12 +224,12 @@ class InputState {
private(set) var readings: [String]
init(composingBuffer: String, cursorIndex: Int, markerIndex: Int, readings: [String]) {
self.markerIndex = markerIndex
let begin = min(cursorIndex, markerIndex)
let end = max(cursorIndex, markerIndex)
markedRange = begin..<end
self.readings = readings
super.init(composingBuffer: composingBuffer, cursorIndex: cursorIndex)
defer { self.markerIndex = markerIndex }
}
var attributedString: NSAttributedString {