You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Searching for some strings containing backslash finds nothing #5428
However I am not sure why this was implemented the way it is
It is following the way JavaScript/C strings work (with less supported escapes) where unrecognized escapes just result in the escaped character (i.e. "\i" == "i").
There's no well-defined user expectation here — the current behavior was added because people wanted to be able to use \n, but disappoints the expectation of being able to insert backslashes the simple way. Your patch would probably cause this to be less surprising, so if you want to submit a pull request that'd be great.
Activity
gorhill commentedon Jul 7, 2019
The fix is trivial in practice, which is to slightly rewrite
parseStringin https://github.com/codemirror/CodeMirror/blob/c9892c85b02e448370798edd374d6cbc9bb41272/addon/search/search.js#L80-L86 to:Essentially, eat the backslash only for specific characters, and use backslash literally for all other characters.
However I am not sure why this was implemented the way it is, so I am unsure whether such change would be accepted.
marijnh commentedon Jul 7, 2019
It is following the way JavaScript/C strings work (with less supported escapes) where unrecognized escapes just result in the escaped character (i.e.
"\i" == "i").There's no well-defined user expectation here — the current behavior was added because people wanted to be able to use
\n, but disappoints the expectation of being able to insert backslashes the simple way. Your patch would probably cause this to be less surprising, so if you want to submit a pull request that'd be great.[search addon] Escape sequence only for \n, \r, \t and \\
[search addon] Escape sequence only for \n, \r, \t and \\
Update from master (#1)