marco alves
marco alves

Reputation: 1717

NSTextView: auto-completion for "."-prefix words

I want to provide auto-completion for "words" like .abc as well as def.abc and abc as way to refer to significant tokens in a NSTextView.

I'm able to get the def.abc and the abc cases working, but the "."-prefixed .abc is not working. I'm using textView(_:completions:forPartialWordRange:indexOfSelectedItem:) delegate method of NSTextViewDelegate.

In the .abc case, the auto-completion mechanism in NSTextView inserts the ".abc" completion after the "." and results in ..abc -- which is impractical.

I've looked at the documentation of NSTextView and NSTextViewDelegate and can not find a way to make the auto-completion work in such .abc case, avoiding the ..abc result — e.g. replacing the initial "." by "" by hooking into a didSelectCompletion delegate method.

Any hints?

Upvotes: 2

Views: 464

Answers (1)

1024jp
1024jp

Reputation: 2208

How about overriding rangeForUserCompletion in NSTextView to expand range so that . is included?

Upvotes: 2

Related Questions