spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.33k stars 1.61k forks source link

Spyder editing window frequently jumps when focus is lost #19939

Open juliangilbey opened 2 years ago

juliangilbey commented 2 years ago

Issue Report Checklist

Problem Description

Sometimes, in the Editor Window, I scroll a file I am editing to see another part of the file using the scroll bar (and the cursor retains its location in the file). I then change focus to another window on my screen (for example to an xterm window or to a web browser). Often, but not every time, at the point when Spyder loses the focus, in the Editor Window, the file jumps back to the last place I had my cursor (completely undoing the effect of my scrolling). (I hope that makes some sense!)

I cannot find a way of reliably reproducing this behaviour, unfortunately; it happens sporadically. It occurs (sporadically) even when I remove the Spyder preferences entirely before starting Spyder as if it's a clean install.

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0                   :  1.4.1 (OK)
chardet >=2.0.0                        :  4.0.0 (OK)
cloudpickle >=0.5.0                    :  2.0.0 (OK)
cookiecutter >=1.6.0                   :  1.7.3 (OK)
diff_match_patch >=20181111            :  20200713 (OK)
intervaltree >=3.0.2                   :  3.0.2 (OK)
IPython >=7.31.1                       :  8.5.0 (OK)
jedi >=0.17.2;<0.19.0                  :  0.18.0 (OK)
jellyfish >=0.7                        :  0.8.9 (OK)
jsonschema >=3.2.0                     :  4.7.2 (OK)
keyring >=17.0.0                       :  23.9.3 (OK)
nbconvert >=4.0                        :  6.4.4 (OK)
numpydoc >=0.6.0                       :  1.5.0 (OK)
parso >=0.7.0;<0.9.0                   :  0.8.1 (OK)
pexpect >=4.4.0                        :  4.8.0 (OK)
pickleshare >=0.4                      :  0.7.5 (OK)
psutil >=5.3                           :  5.9.2 (OK)
pygments >=2.0                         :  2.12.0 (OK)
pylint >=2.5.0;<3.0                    :  2.15.5 (OK)
pyls_spyder >=0.4.0                    :  0.4.0 (OK)
pylsp >=1.5.0;<1.6.0                   :  1.5.0 (OK)
pylsp_black >=1.2.0                    :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0              :  3.0.3 (OK)
qstylizer >=0.1.10                     :  0.2.2 (OK)
qtawesome >=1.0.2                      :  1.1.1 (OK)
qtconsole >=5.3.2;<5.4.0               :  5.3.2 (OK)
qtpy >=2.1.0                           :  2.2.0 (OK)
rtree >=0.9.7                          :  1.0.1 (OK)
setuptools >=49.6.0                    :  65.5.0 (OK)
sphinx >=0.6.6                         :  4.5.0 (OK)
spyder_kernels >=2.3.3;<2.4.0          :  2.3.3 (OK)
textdistance >=4.2.0                   :  4.5.0 (OK)
three_merge >=0.1.1                    :  0.1.1 (OK)
watchdog >=0.10.3                      :  2.1.9 (OK)
xdg >=0.26                             :  0.27 (OK)
zmq >=22.1.0                           :  23.2.1 (OK)

# Optional:
cython >=0.21                          :  0.29.32 (OK)
matplotlib >=3.0.0                     :  3.5.2 (OK)
numpy >=1.7                            :  1.21.5 (OK)
pandas >=1.1.1                         :  1.3.5 (OK)
scipy >=0.17.0                         :  1.8.1 (OK)
sympy >=0.7.3                          :  1.10.1 (OK)

# Spyder plugins:
spyder_boilerplate.spyder.plugin 0.0.1 :  0.0.1 (OK)
spyder_unittest.unittestplugin 0.5.1   :  0.5.1 (OK)
dalthviz commented 2 years ago

Hi @juliangilbey thanks for the feedback! So what you are experiencing is a reset in the scrollbar position to the place where the cursor in the Editor is placed? And this happens just sometimes when you change the focus from Spyder to other application and back again to Spyder, right?

Something like this?:

focus

To do this, after I give again the focus to Spyder, I clicked my spacebar but maybe in your case some other input source acts in the application focus change trying to input something causing the focus to be restore to the Editor cursor position?

Any other info in order to better understand what is happening here is greatly appreciated!

juliangilbey commented 2 years ago

Hi @dalthviz, I'm not sure I fully understand what you have done. I just reproduced the behaviour as follows and managed to capture the issue in a screencast! (Took lots of attempts before it actually happened, mind you.) Here's what I did, as captured in the attached screencast:

Spyder-screencast

I hope this helps explain what I'm experiencing.

dalthviz commented 2 years ago

Thanks for the new info @juliangilbey ! Then I think Spyder is detecting the Alt keystroke (maybe also other key modifiers?) and then because of that putting the focus on the cursor Editor. In my example, I tried to replicate the scroll jump by pressing my keyboard spacebar. So I guess the problem is that this scroll jump behavior is happening by pressing not only keys that input things in the Edior (like spacebar, letters or numbers) but also keys like Alt

We will check it in a future release 👍🏼

ccordoba12 commented 1 year ago

@juliangilbey, I was reviewing this bug and I can't reproduce it with the latest 5.x. Could you check again by running Spyder from a git clone and let us know if the problem persists for you?

juliangilbey commented 1 year ago

Hi @ccordoba12, I'll happily do that, but it may take a little while; Debian's introduced Python 3.11 which is causing me no end of trouble right now....

ccordoba12 commented 1 year ago

Ok, no problem, there's no rush because this is not a critical issue. Moving it to 5.4.2 then.

juliangilbey commented 1 year ago

I just checked with 5.4.2 - I still observe this behaviour.