diff --git a/CHANGELOG.md b/CHANGELOG.md index 264683d2a..4a41b6c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ develop ### Fixes - Fix an issue where UNIX scripts could fail getting the content of the document. +- Workaround an issue where word suggestion in the Touch Bar cannot insert a word starts with a symbol correctly. - Address an issue where the application could crash on document saving or text replacement. diff --git a/CotEditor/Sources/EditorTextView+TouchBar.swift b/CotEditor/Sources/EditorTextView+TouchBar.swift index e90dacc66..4da66ff47 100644 --- a/CotEditor/Sources/EditorTextView+TouchBar.swift +++ b/CotEditor/Sources/EditorTextView+TouchBar.swift @@ -99,7 +99,12 @@ extension EditorTextViewController { func textView(_ textView: NSTextView, candidatesForSelectedRange selectedRange: NSRange) -> [Any]? { var index = 0 - guard let candidates = textView.completions(forPartialWordRange: textView.rangeForUserCompletion, indexOfSelectedItem: &index), !candidates.isEmpty else { return nil } + guard + let candidates = textView.completions(forPartialWordRange: textView.rangeForUserCompletion, indexOfSelectedItem: &index)? + .filter({ $0.range(of: "^(\\W|_)", options: .regularExpression) == nil }), + !candidates.isEmpty + else { return nil } + // -> remove words start with non-alphabet to workaround a bug: e.g. "__init__" in Python (2017-10 macOS 10.13) return candidates }