sublimehq/sublime_text

The `word_separators` settings does not work as expected.

absop opened this issue ยท 7 comments

absop commented

Description

I use the below word_separators setting for some languages,

"word_separators": "|`'#[]{,}()\"\n"

to make identifiers can be recognized correctly. But this setting dose not work very well.

For example, with this setting, placing the cursor inside any profile-counter-count, then, pressing down alt+f3 should work as shown in the following image
image
instead of
image

In the first image, Only profile-counter-counts are selected and highlighted, it is what we expected.

The second image shows how ST dose, profile-counter-counts and part of profile-counter-count-set!s' are selected and highlighted, -s and other punctuation characters still be recognized as word separators.

Environment

  • Build: 41116
  • Operating system and version: Windows 10
absop commented

This is the code used above.

(module ()
  (include "types.ss")

  (set-who! $dynamic-closure-counts
    (lambda ()
      (vector
        (profile-counter-count #{raw-ref-count bhowt6w0coxl0s2y-1})
        (profile-counter-count #{raw-create-count bhowt6w0coxl0s2y-2})
        (profile-counter-count #{raw-alloc-count bhowt6w0coxl0s2y-3})
        (profile-counter-count #{ref-count bhowt6w0coxl0s2y-4})
        (profile-counter-count #{pair-create-count bhowt6w0coxl0s2y-5})
        (profile-counter-count #{vector-create-count bhowt6w0coxl0s2y-6})
        (profile-counter-count #{vector-alloc-count bhowt6w0coxl0s2y-8})
        (profile-counter-count #{padded-vector-alloc-count bhowt6w0coxl0s2y-11})
        (profile-counter-count #{closure-create-count bhowt6w0coxl0s2y-7})
        (profile-counter-count #{closure-alloc-count bhowt6w0coxl0s2y-9})
        (profile-counter-count #{padded-closure-alloc-count bhowt6w0coxl0s2y-10}))))

  (set-who! $clear-dynamic-closure-counts
    (lambda ()
      (profile-counter-count-set! #{raw-ref-count bhowt6w0coxl0s2y-1} 0)
      (profile-counter-count-set! #{raw-create-count bhowt6w0coxl0s2y-2} 0)
      (profile-counter-count-set! #{raw-alloc-count bhowt6w0coxl0s2y-3} 0)
      (profile-counter-count-set! #{ref-count bhowt6w0coxl0s2y-4} 0)
      (profile-counter-count-set! #{pair-create-count bhowt6w0coxl0s2y-5} 0)
      (profile-counter-count-set! #{vector-create-count bhowt6w0coxl0s2y-6} 0)
      (profile-counter-count-set! #{vector-alloc-count bhowt6w0coxl0s2y-8} 0)
      (profile-counter-count-set! #{padded-vector-alloc-count bhowt6w0coxl0s2y-11} 0)
      (profile-counter-count-set! #{closure-create-count bhowt6w0coxl0s2y-7} 0)
      (profile-counter-count-set! #{closure-alloc-count bhowt6w0coxl0s2y-9} 0)
      (profile-counter-count-set! #{padded-closure-alloc-count bhowt6w0coxl0s2y-10} 0))))

And there is another problem of selecting word with alt+f3, as shown below
image

That is, if I dose not add some characters into the "word_separators", I can't select some words with alt+f3.

Tried to associate some issues suffering from word_completions not being respected to illustrate significance of that topic.

The developer just tell you to use LSP-R language engine, which is cumbersome to setup. I am still using ST3 for this very reason.

I don't think situation is noticible better in ST3 with regards to how and where word_completions are taken into account.

I think the behavior with word separators can be classified into a couple sub-problems because behavior that respects the setting is expected in different areas:

  1. find-under-caret or highlighting duplicate selections: uses boost regular expressions (most likely) and the respective \b anchor whose behavior is hard-coded
  2. completion triggers
  3. selection operations on "word" level, e.g. ctrl+left/right, double-clicking or the respective API methods View.classify, View.find_by_class, View.expand_by_class, View.word
    Note that this works as expected.
  • selection operations on "word" level, e.g. ctrl+left/right, double-clicking or the respective API methods View.classify, View.find_by_class, View.expand_by_class

I think the Go-To is different from the selection behavior. I have had success with removing - from word_separators for a language and double-click now selects the whole hyphenated string (e.g. sublime-syntax context names). If you know of counter-examples, feel free to link them.

I think the Go-To is different from the selection behavior.

Correct, I edited my comment to clarify that this is already working as expected (and verified this for View.word and View.expand_by_class).