UI: macOS: Fix UTF-8 and UTF-16 conversions in highlighter code

NSString uses UTF-16 internally, while String uses UTF-8 in Swift 5.

Signed-off-by: Andrej Mihajlov <and@mullvad.net>
This commit is contained in:
Andrej Mihajlov
2020-12-15 18:26:55 +01:00
committed by Jason A. Donenfeld
parent 403ee63615
commit 9269c7c1c1
2 changed files with 25 additions and 9 deletions
@@ -70,7 +70,7 @@ class ConfTextView: NSTextView {
}
func setConfText(_ text: String) {
let fullTextRange = NSRange(location: 0, length: (string as NSString).length)
let fullTextRange = NSRange(..<string.endIndex, in: string)
if shouldChangeText(in: fullTextRange, replacementString: text) {
replaceCharacters(in: fullTextRange, with: text)
didChangeText()