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

"Replace Selection" Erroneously Removing/Interpreting Escape Sequences #5494

Closed
CAM-Gerlach opened this issue Oct 18, 2017 · 3 comments
Closed

Comments

@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Oct 18, 2017

Description of your problem

When performing a find and replace using the basic Ctrl-R in Spyder, the "Replace Selection" option will remove and parse escape sequences present in the selected portion of the file regardless of the actual find query, silently deleting line continuation ""s and rendering "\n"s, "\r"s etc. as newlines, etc, and likely similar for others. This almost invariably breaks the code and requires careful diagnosis and manual inspection to fix, and there appears to be no obvious workaround other than using "Replace all" or going through result by result, which does not trigger the issue.

I've tested this across multiple machines across various versions of Python and Spyder since installing Anaconda between 1-2 months ago.

What steps will reproduce the problem?
Minimal example code:
test_string = "foo"
long_string = "foo" + "\n" + "bar"
cap_string = long_string\
.capitalize()
print(cap_string)

  1. Select above code
  2. Enter any string that matches something in above, e.g. "string", and any replacement e.g. "str"
  3. Click "Replace Selection" with default settings

What is the expected output? What do you see instead?
Expected:
test_str= "foo"
long_str= "foo" + "\n" + "bar"
cap_str= long_str\
.capitalize()
print(cap_str)

Actual:
test_str= "foo"
long_str= "foo" + "
" + "bar"
cap_str= long_str
.capitalize()
print(cap_str)

Versions and main components

  • Spyder Version: 3.2.3
  • Python Version: 3.6.1 – 3.6.3 x64
  • Qt Version: 5.6.2
  • PyQt Version: 5.6
  • Operating system: Win8.1 Pro x64, Win10 Ent x64

Dependencies

IPython >=4.0 : 5.3.0 (OK)
cython >=0.21 : 0.25.2 (OK)
jedi >=0.9.0 : 0.10.2 (OK)
nbconvert >=4.0 : 5.1.1 (OK)
numpy >=1.7 : 1.12.1 (OK)
pandas >=0.13.1 : 0.20.1 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pyflakes >=0.6.0 : 1.5.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.7.2 (OK)
qtconsole >=4.2.0: 4.3.0 (OK)
rope >=0.9.4 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.5.6 (OK)
sympy >=0.7.3 : 1.0 (OK)

@ccordoba12
Copy link
Member

Thanks for reporting. We'll fix it in one of our next releases.

@rlaverde, please take a look at this one.

@CAM-Gerlach
Copy link
Member Author

Thanks very much. On a related note, I've been consistently bothered with the find and replace dialog that there appears to be no evident way to move between the textbox where one enters the string to search for, and the one to replace it with, i.e. TAB doesn't work as it should (and does everywhere else); again on multiple Windows machines with the above traits. My only recourse is to manually click around with the mouse, and googling and the keyboard shortcuts dialog hasn't revealed any obvious solutions. Is this in fact a bug (the field trapping TAB?), or am I missing something? If the former, I guess I'll open a new issue? Thanks.

@lorenzznerol
Copy link

Hello,

I have this issue again in Spyder 3.3.6, always reproducible, If you use line continuation character,
any "find and replace" that is changing its code drops the line continuation character .

Best regards

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

No branches or pull requests

4 participants