Match Latex-like syntax for unicode characters base on the name of the character. This does ``\\GREEK SMALL LETTER ETA`` -> ``η`` Works only on valid python 3 identifier, or on combining characters that will combine to form a valid identifier.
(self, context: CompletionContext)
| 3139 | |
| 3140 | @context_matcher() |
| 3141 | def unicode_name_matcher(self, context: CompletionContext) -> SimpleMatcherResult: |
| 3142 | """Match Latex-like syntax for unicode characters base |
| 3143 | on the name of the character. |
| 3144 | |
| 3145 | This does ``\\GREEK SMALL LETTER ETA`` -> ``η`` |
| 3146 | |
| 3147 | Works only on valid python 3 identifier, or on combining characters that |
| 3148 | will combine to form a valid identifier. |
| 3149 | """ |
| 3150 | |
| 3151 | text = context.text_until_cursor |
| 3152 | |
| 3153 | slashpos = text.rfind('\\') |
| 3154 | if slashpos > -1: |
| 3155 | s = text[slashpos+1:] |
| 3156 | try : |
| 3157 | unic = unicodedata.lookup(s) |
| 3158 | # allow combining chars |
| 3159 | if ('a'+unic).isidentifier(): |
| 3160 | return { |
| 3161 | "completions": [SimpleCompletion(text=unic, type="unicode")], |
| 3162 | "suppress": True, |
| 3163 | "matched_fragment": "\\" + s, |
| 3164 | } |
| 3165 | except KeyError: |
| 3166 | pass |
| 3167 | return { |
| 3168 | "completions": [], |
| 3169 | "suppress": False, |
| 3170 | } |
| 3171 | |
| 3172 | @context_matcher() |
| 3173 | def latex_name_matcher(self, context: CompletionContext): |
nothing calls this directly
no test coverage detected