Closed 01-Scripts closed 11 years ago
Im unable to reproduce the problem you are describing.
I made a short video that is illustrating the problem: http://screencast.com/t/qcj3ttq8YZ
Thanks, that makes sense now to me.
This is a bug.Changing the line of the regular expression to:
search = '(?<![\\w])'+re.escape(string).replace("\\'", "'")+'(?<![\w])'
makes the bug disappear, but I'm not sure if this is correct. Opinion please! @adzenith
Thanks!
So change this: search = '(?<![\w])'+re.escape(string)+'\b' To this: search = '(?<![\w])'+re.escape(string).replace("\'", "'")+'(?<![\w])' ?
So re.escape doesn't work right with whatever regex library ST2 uses? That's sad :(
Interestingly, when I first wrote this plugin, I wrote my own escape function. Someone asked me why I didn't use re.escape, and I vaguely remembered trying it and finding it to be broken, but I couldn't for the life of me remember why, so I moved over.
Maybe we should figure out all of the characters that get escaped that shouldn't be.
\" works just like "... strange.
whoops hit the wrong button.
Hi, thanks, is not just the escaping of the RegExp, also the change at the end of \b to (?<![\w]) matters. I don't understand these regexp :O
It was me that requested to change the string.replace for a re.escape, I was unable to find a situation on which some of these fail.
Works when preceded with a backslash: !"#$%&()*+,-./:;=?@[]^_{|}~ Doesn't work in ST2, but works in Python: '<>` So that's four characters I guess we need to "unescape".
@tito I'll check out the ending change as well. And I do think that using re.escape is much better than whatever I was trying to do; I'm just sad that Sublime Text seems to be choking on these regexes.
(?<![\w]) (which could probably be rewritten without the square brackets) is a negative lookbehind assertion:
(?<! # The preceding must not be \w # a word character. )
This prevents dub from matching inside of indubitably. We used to use \b instead of (?<!\w), but I believe we stopped because it sometimes broke when punctuation was involved; here we could be seeing the same problem.
Tito, Could you look over this and pull if it looks good? I tried it out and it seems to work great. Thanks!
P.S. Thanks for taking the time to figure out why it wasn't working!
Have been testing, looks pretty good, Thanks to you!
Sweet thanks! I'll pull it then.
Hello,
I'm new to Sublime and have installed your Plugin. Now I ran into the following problem and I'm not sure if it is a bug or a feature:
I changed the sublime preference from
word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}
~?",to:
"word_separators": "./\()\"-:,.;<>~!@%^&*|+=}~?",
in my user preferencesNow if I doubleclick on
$array['name']
everything from $ until ] is selected bot the Highlighting of same Arrays isn't working.Can you confirm this behaviour?
Regards, Michael