Skip to content

Commit

Permalink
Merge pull request #808 from youknowone/fix-crash
Browse files Browse the repository at this point in the history
로마자 입력기가 후보 찾기에 반응하는 문제 수정
  • Loading branch information
youknowone committed Apr 27, 2022
2 parents 10a9387 + f85df92 commit 775d859
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions OSXCore/Composer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ extension Composer {
func composerSelected() {}

func candidateSelected(_ candidateString: NSAttributedString) {
assert(delegate != nil)
delegate.candidateSelected(candidateString)
}

func candidateSelectionChanged(_ candidateString: NSAttributedString) {
assert(delegate != nil)
delegate.candidateSelectionChanged(candidateString)
}

Expand Down
3 changes: 3 additions & 0 deletions OSXCore/GureumComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ extension GureumComposer {
}
}

if delegate is SearchComposer {
searchComposer.cancelSearch()
}
switch layout {
case .hangul, .roman:
// 한영전환을 위해 현재 입력 중인 문자 합성 취소
Expand Down
4 changes: 4 additions & 0 deletions OSXCore/RomanComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ final class RomanComposer: Composer {
_commitString = "\(mappedCharacter)"
return .processed
}

func candidateSelected(_: NSAttributedString) {}

func candidateSelectionChanged(_: NSAttributedString) {}
}

// MARK: - RomanComposerType 열거형 확장
Expand Down
18 changes: 9 additions & 9 deletions OSXCore/SearchComposer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ extension SearchComposer {
// 1. 모드 false
showsCandidateWindow = false
// 2. 후보 취소
if !_searchWorkItem.isCancelled {
_searchWorkItem.cancel()
}
cancelSearch()
_searchLock.lock()
candidates = nil
_searchLock.unlock()
Expand Down Expand Up @@ -279,6 +277,12 @@ extension SearchComposer {
return workItem
}

public func cancelSearch() {
if !_searchWorkItem.isCancelled {
_searchWorkItem.cancel()
}
}

/// 한자 입력을 위한 후보를 만든다.
func updateHanjaCandidates() {
assert(delegate != nil)
Expand All @@ -296,9 +300,7 @@ extension SearchComposer {
dlog(DEBUG_SEARCH_COMPOSER, "SearchComposer.updateHanjaCandidates() step3")

let keyword = originalString.trimmingCharacters(in: .whitespaces)
if !_searchWorkItem.isCancelled {
_searchWorkItem.cancel()
}
cancelSearch()
candidates = [NSAttributedString(string: "검색 중...")] // default candidates

guard !keyword.isEmpty else {
Expand Down Expand Up @@ -331,9 +333,7 @@ extension SearchComposer {
let keyword = originalString

dlog(DEBUG_SEARCH_COMPOSER, "Candidates before search, %@", candidates ?? "nil")
if !_searchWorkItem.isCancelled {
_searchWorkItem.cancel()
}
cancelSearch()
candidates = [NSAttributedString(string: "Searching...")] // default candidates
let pool = SearchSourceConst.emoji

Expand Down

0 comments on commit 775d859

Please sign in to comment.