Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Replace Selection changes double backslashes to single backslashes #6416

Closed
Khris777 opened this issue Feb 8, 2018 · 3 comments · Fixed by #9708
Closed

Bug: Replace Selection changes double backslashes to single backslashes #6416

Khris777 opened this issue Feb 8, 2018 · 3 comments · Fixed by #9708

Comments

@Khris777
Copy link

Khris777 commented Feb 8, 2018

Description of your problem

When doing a Replace in a selection that has a string with double backslashes, the Replace command will change the double backslashes to single backslashes even though something completely different is being replaced.

What steps will reproduce the problem?

  1. Example code:
a = 1
b = 2
c = a+b
s = "C:\\Test\\Test2\\output.txt"
  1. Mark the example code and replace selection a with x
  2. The output will be this:
x = 1
b = 2
c = x+b
s = "E:\Test\Test2\output.txt"

What is the expected output?

x = 1
b = 2
c = x+b
s = "E:\\Test\\Test2\\output.txt"

Please provide any additional information below

It only happens on Replace selection, not when doing Replace all.

Versions and main components

  • Spyder Version: 3.2.6
  • Python Version: 3.6.4
  • Qt Version: 5.6.2
  • PyQt Version: 5.6
  • Operating system: Windows 10

Dependencies

IPython >=4.0 : 6.2.1 (OK)
cython >=0.21 : 0.27.3 (OK)
jedi >=0.9.0 : 0.11.1 (OK)
nbconvert >=4.0 : 5.3.1 (OK)
numpy >=1.7 : 1.13.3 (OK)
pandas >=0.13.1 : 0.22.0 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pyflakes >=0.6.0 : 1.6.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.8.1 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
rope >=0.9.4 : 0.10.7 (OK)
sphinx >=0.6.6 : 1.6.6 (OK)
sympy >=0.7.3 : 1.1.1 (OK)

@ccordoba12
Copy link
Member

Thanks for reporting. We'll take a look at this in a future release.

@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Feb 9, 2018

@ccordoba12 Likely related to #5494 and the associated #5555 ; that apparently fixes other escaped cases but not escaping the escape char itself.

@ccordoba12 ccordoba12 modified the milestones: v3.2.8, v3.2.9 Mar 3, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3, v3.3.1 Jun 2, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3.1, v3.3.2 Jul 15, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3.2, v3.3.3 Aug 18, 2018
@ccordoba12 ccordoba12 modified the milestones: v3.3.3, not sorted Jan 7, 2019
@oscargus
Copy link
Contributor

oscargus commented Jun 27, 2019

This becomes even more of a problem considering raw strings. While adding \ to the current reg-exp would solve this particular issue, it will still break on lines like:

b = r'\a\v\b'

Now, one may think that since all the escaped characters in the reg-exp are non-letters one can simply add all letters (and numbers). However, in e.g. SymPy, there is LaTeX printing, so a line in the editor may very well look like

r'\{7 \& 8\}'

If it wasn't for the word option, one could simply use subs instead for queries that are not regular expressions. Right now, I do not really have any idea how to deal with it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants