Pulsar-Edit-Highlights / selected

@Pulsar-Edit package for highlighting occurrences of your selection.
https://web.pulsar-edit.dev/packages/highlight-selected
MIT License
248 stars 67 forks source link

Highlight fails on neighbouring words #201

Closed Siguza closed 4 years ago

Siguza commented 5 years ago

Version info

$ atom --version
Atom    : 1.38.2
Electron: 2.0.18
Chrome  : 61.0.3163.100
Node    : 8.9.3
$ apm list | grep lint
$

(Yeah, I have no package containing lint in its name installed - should I?)

Issue

When the word that is supposed to be highlighted appears twice with only a single character in between, only one of them is highlighted:

Screenshot

Test file:

00000000 00000000 00000000
00000000.00000000.00000000
00000000-00000000-00000000

00000000  00000000  00000000
00000000..00000000..00000000
00000000--00000000--00000000

I often sift through hexdumps, so I definitely have a use case for this.

From glancing through the code, it would seem to me that changing nonWordCharacters in search-model.js to be embedded in lookbehind and lookahead groups rather than non-capturing groups might fix the issue, but I neither have a build setup to test this, nor did I want to create a pull request without actually understanding the codebase.

richrace commented 5 years ago

Thanks for this.

I added a lookahead to the second part see this pull request: https://github.com/richrace/highlight-selected/pull/202/files

Can play with it here: Regex with a lookahead(00000000)(%3F%3D%5B%20%5Ct%5C%2F%5C%5C%5C(%5C)%22'%3A%2C%5C.%3B%3C%3E~!%40%23%5C%24%25%5C%5E%26%5C*%5C%7C%5C%2B%3D%5C%5B%5C%5D%5C%7B%5C%7D%60%5C%3F%5C-…%5D%7C%24)%7C%7C%7C%7Cg%7C%7C%7C%7C%5B%22%22%2C%2200000000%2000000000%2000000000%22%2C%2200000000.00000000.00000000%22%2C%2200000000-00000000-00000000%22%2C%22%22%2C%2200000000%20%2000000000%20%2000000000%22%2C%2200000000..00000000..00000000%22%2C%2200000000--00000000--00000000%22%5D)

richrace commented 5 years ago

I can't remember why I had the apm list | grep lint command in the contributing guide. So I've opened #203 as it is a bit out of date. Thanks for following it though.

scsmash3r commented 4 years ago

I can confirm this bug. Is there any fix planned?

richrace commented 4 years ago

This comment https://github.com/richrace/highlight-selected/issues/201#issuecomment-510648062

Links to a PR and an interactive JS regex console. Was looking to see if those changes fix it as I haven’t come across it.

scsmash3r commented 4 years ago

This comment #201 (comment)

Links to a PR and an interactive JS regex console. Was looking to see if those changes fix it as I haven’t come across it.

Okay, I've applied proposed PR and tested it on my local machine. Seems to work just fine now: image

I guess it can be merged into master for new version to have this bug fixed ;) P.S. Thanks for such a lightweight and useful plugin.

richrace commented 4 years ago

Thanks for confirming!