timhor/obsidian-editor-shortcuts

CMD + D Doesn't seem to work in some cases

Closed this issue · 4 comments

For example:

(hello)
(hello)
(hello)

Selecting the first (hello) and hitting cmd + D doesn't select the next one. But just selecting hello works.

Do you think it's maybe that searchText needs to be escaped here?

searchWithinWords ? searchText : `\\b${searchText}\\b`,

Eg. https://www.npmjs.com/package/escape-string-regexp

Yes, good catch! Fix incoming in the next release 😄

Possibly related (bold to denote current selections):

helm help hel

after cmd-D should become

helm help hel

but instead it becomes

helm help hel

selections should match within other words (to make cmd+D work like sublime)

@brandonlilly That was somewhat intentional. When expanding to the next match, Sublime distinguishes between how the initial selection was made:

  • If it was done via Cmd+D (expanding from a cursor selection), it will not match within words
  • If it was done 'by hand' (using a mouse or Shift + arrow keys), it will match within words

I made an initial call to emulate the former, but have since updated it to search within words. I'm hoping to have the logic for both scenarios completed next week.

In the meantime, you can grab the latest copy of master if that's the preferred behaviour for you.

Both fixes have been released in v1.9.0