sgryjp / japanese-word-handler

Better Japanese word handling on Visual Studio Code.
zlib License
46 stars 7 forks source link

Is there better way to handle double click selection? #4

Open tyru opened 5 years ago

tyru commented 5 years ago

This is question issue.

I want to fix selection range when double click. I tried to fix this using registerHoverProvider() + onDidChangeTextEditorSelection(). https://github.com/sgryjp/japanese-word-handler/compare/master...tyru:handle-double-click?expand=1

But that has the problem: registerHoverProvider() handler is not called so frequently, it doesn't update mouse position when moving mouse quickly.

And question is: I wonder if event has a mouse position, or any other better workaround for this 🤔 Do you know that?

Screenshot

Screencast 2019-08-07 13 46 02

sgryjp commented 5 years ago

Well, my honest short answer is: No

But actually I have never seriously investigated a way to resolve mouse selection problem since the first release. 2.5 years have been passed since then... I will take a look too so wait for a moment please.

tyru commented 5 years ago

thanks! I want this by default, however this plugin provides natural multibyte support. thanks for creating :pray:

sgryjp commented 5 years ago

@tyru I investigated current API set but no luck to find a way around. But I found a new issue on VSCode's repository which is directly related to this problem: https://github.com/microsoft/vscode/issues/50045#issuecomment-456502664 In the discussion, an insider clearly states that they are working on it. So, I think we should wait and see 🙂

tyru commented 5 years ago

Thanks for investigating! very glad to hear that :raised_hands:

sgryjp commented 4 months ago

As of VSCode v1.91.1 (#203605), it silently (?) supports editor.wordSegmenterLocales setting which utilizes Web browser's word segmentation feature. Try setting ja-JP as the value and you can select a Japanese word by double clicking.

Note that editor.wordSegmenterLocales uses Intl.Segmenter JavaScript API for word segmentation so it separates words different position from Japanese Word Handler. You may feel the incompatibility is annoying... in that case, I recommend you to stop using Japanese Word Handler and rely solely on editor.wordSegmenterLocales.

keisuke-nakata commented 2 weeks ago

"editor.wordSegmenterLocales": "ja-JP" seems to contain the feature offered by the solution: https://qiita.com/aosho235/items/0e1f0a525c8e3e7027d9#%E8%A7%A3%E6%B1%BA%E7%AD%96 . (double-clicking an alphabetical text next to a Japanese text without space selects the alphabetical text only.)

As sgryjp said, editor.wordSegmenterLocales separates Japanese text differently from Japanese Word Handler, but it does not matter in my usage.