Created
April 4, 2020 07:09
-
-
Save jsbain/9edea18951d296ca46aca8868791e04e to your computer and use it in GitHub Desktop.
customMenuItem.py
I remember I met the same problem when I wrote a script for Japanese emoji in a TextField. Perhaps we could enter an issue for Pythonista editor module.
str(tv.text().substringWithRange_(tv.selectedRange())) seems like it migt work
str(tv.text().substringWithRange_(tv.selectedRange())) seems like it migt work
Seems ok, I'll change my code
Thanks
Perhaps you should also change your code, and I'm sorry but I don't know (or I forgot) how to send you a request to modify
# if selected text contains long unicode characters, erroneous range
# thus we use other way
#txt=str(editorView.textView().text())
#start=editorView.textView().selectedTextRange().start().index()
#end=editorView.textView().selectedTextRange().end().index()
#selected_text=txt[start:end]
tv = editorView.textView()
rge = tv.selectedRange()
start = rge.location
end = start + rge.length
selected_text = str(tv.text().substringWithRange_(rge))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yeah, i noticed that too (my original example used an emoji for the Apple search menu item, and i got an off by one error).
I think this is also a problem with editor.get_selection? I remember some discussion in the forums a while back -- there may be a workaround using some nsstring or uitextview methods.