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

Shifting multiple lines of code with ctrl + cmd + down-arrow-key doesn't work properly after first shift #4754

Closed
ghost opened this issue Jul 17, 2017 · 7 comments

Comments

@ghost
Copy link

ghost commented Jul 17, 2017

When using ctrl + cmd + down-arrow-key to shift multiple lines of code, entire code block moves once as expected, but is then automatically deselected. Strangely, ctrl + cmd + up-arrow-key works as expected.

What steps will reproduce the problem?

  1. Select multiple lines.
  2. Move using ctrl + cmd + down-arrow-key.
  3. Lines will be deselected.

Versions and main components

  • Spyder Version: 3.1.4
  • Python Version: 3.6.1
  • Qt Version: 5.6.2
  • PyQt Version: 5.6.0
  • Operating system: OS X El Capitan 10.11.6

Dependencies

jedi >=0.9.0 : 0.10.2 (OK)
matplotlib >=1.0 : 2.0.2 (OK)
nbconvert >=4.0 : 5.2.1 (OK)
numpy >=1.7 : 1.13.1 (OK)
pandas >=0.13.1 : 0.20.2 (OK)
pep8 >=0.6 : 1.7.0 (OK)
psutil >=0.3 : 5.2.2 (OK)
pyflakes >=0.6.0 : 1.5.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.6.4 (OK)
qtconsole >=4.2.0: 4.3.0 (OK)
rope >=0.9.4 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.6.2 (OK)
sympy >=0.7.3 : 1.1 (OK)

@ccordoba12
Copy link
Member

Thanks for reporting. We'll take a look at this one after we release Spyder 3.2

@jnsebgosselin
Copy link
Member

@ccordoba12
Commenting lines 885 to 892 in base.py solves this issue for me in branch 3.1.x. and 3.x

if len(text) == 0:
    #If the next line is blank
    sel_text = sel_text[0:-1]
    sel_text = os.linesep + sel_text
if not text:
    cursor.insertText(sel_text)
    cursor.endEditBlock()
    return

I've tried to understand why those lines were necessary in the first place and could not find any reason... The rest of the code seems to handle pretty well the empty-line and end-of-file cases without the need for this block of code. So... I'm probably missing something here, but it is a start in the good direction to solve this issue.

@goanpeca
Copy link
Member

@rlaverde maybe you know?

@goanpeca
Copy link
Member

@jnsebgosselin I invited you to the gitter chat room, there we can chat less asynchronously in case you have questions. Thanks for all the work you are doing :-)

You can download an app https://gitter.im/apps, or use the web interface https://gitter.im/spyder-ide/public

@rlaverde
Copy link
Member

rlaverde commented Jul 19, 2017

maybe you know?

No, I haven't changed that behavior, looking at the history that changes was introduced in #3817 and #2382 for fixing errors with blanks lines and in the end of the file

@jnsebgosselin
Copy link
Member

@rlaverde thanks, this explains a lot. I will look again into this issue taking into consideration the PR you just linked.

@jnsebgosselin
Copy link
Member

jnsebgosselin commented Jul 20, 2017

@rlaverde Ok, I found what was causing the problem. if len(text) == 0 and if not text all return True when the line below is empty.

While trying to fix this issue, I found other minor behavioural bugs. While trying to fix all these little issues, I ended up rewriting most of the code. Please, see if this is acceptable. Otherwise, I can try to make changes to fix the issue with less modification to better preserve the initial code structure.

@ccordoba12 ccordoba12 modified the milestones: v3.2.1, v3.2.2 Jul 28, 2017
@ccordoba12 ccordoba12 changed the title Shifting multiple lines of code with ctrl + cmd + down-arrow-key doesn't work properly after first shift. Lines are deselected. Shifting multiple lines of code with ctrl + cmd + down-arrow-key doesn't work properly after first shift Aug 4, 2017
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