Add a function to the Charset API that checks if a character or string belongs to a Charset

Hi! :wave:

I’ve started working on an extension that emulates Kakoune (think Vim) keybindings, and to do that properly I need to be able to find word boundaries.

What I’m doing right now is to use very simple regexes to detect whether a given character is alphanumeric, or a punctuation mark/symbol.

While looking for word boundaries, however, I use the built-in Scanner API, which relies on Charsets.

I could see this creating a bit of a discrepancy between the scanner and the regexes. Having the Charsets makes me wonder whether it wouldn’t be easier to make this a function of the Charsets themselves?

I think being able to do something like Charset.alphanumeric.contains( "a" ), or even Charset.alphanumeric.contains( "some type of string" ) , to check if the given character/string is in the Charset would be really helpful.

I guess another solution to the problem would be to add an API to Nova that can find surrounding word boundaries given some range, but that seems less flexible. Something along the lines of editor.getWordBoundary( new Range( 12, 24 ) ) wouldn’t be bad, but seems extremely specific to just this use case :thinking:.

This sounds like a good suggestion. We will consider this as a feature request.

1 Like