Spyder: Code Folding Occasionally Breaks

Created on 20 Jan 2020  Â·  19Comments  Â·  Source: spyder-ide/spyder

Description

What steps will reproduce the problem?

The problem is that, occasionally, the arrow for code folding collapse and expansion disappears. This renders the code there inaccessible from the editor. The editor still grays out the function name, but it will not be expandable. The arrow only seems to disappear after collapsing a code block/function/class. This doesn't happen everytime that I collapse the code block. I don't know the exact order of clicks and where those clicks take place that make this issue manifest.

Versions

  • Spyder version: 4.0.1
  • Python version: 3.7.1
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Windows 10

Dependencies

atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.2.2 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.11.1 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
numpydoc >=0.6.0             :  0.9.2 (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.7 (OK)
pygments >=2.0               :  2.5.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.2 (OK)
zmq >=17                     :  18.1.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
sphinx >=0.6.6               :  2.3.1 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  None (NOK)
matplotlib >=2.0.0           :  3.1.1 (OK)
numpy >=1.7                  :  1.18.1 (OK)
pandas >=0.13.1              :  None (NOK)
scipy >=0.17.0               :  1.3.2 (OK)
sympy >=0.7.3                :  None (NOK)
Editor Bug

All 19 comments

Could you please provide a video/animation of this with Licecap?

I will try to do this. I won’t be able to demonstrate the process of it breaking, but I can demonstrate it’s broken state once it happens again.

Sent from my iPhone

On Jan 20, 2020, at 2:21 PM, Gonzalo Peña-Castellanos notifications@github.com wrote:


Could you please provide a video/animation of this with Licecap?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

it’s broken state once it happens again.

Please do! thanks

I just wanted to come here to double down on this bug report. I'm having the identical issue.

It happened to me multiple times within 30 minutes. I was writing functions, each with their own multi-line doc strings, and I would collapse the doc strings in on themselves. Then I would flesh out the function and collapse it when I moved onto the next func.

Spyder seems to indicate a collapsed code block by "graying out" the first line of the fold but I was having all sorts of issues with this feature.

  1. Sometimes the lines would regain their color and show that they aren't collapsed.
  2. Sometimes it wouldn't offer me the option to collapse AT the doc string -- only above or below.
  3. Sometimes, as detailed above, entire folds will be lost to the aether.

I'll pay a bit more attention when I sit down to code today and monitor the exact input before any instance of this bug, should it arise. I've got a hunch it doesn't play well with the alt+up / alt+down shortcut for shifting sections of code up and down to different rows. But I'm currently lacking documentation. Just wanted to, at the very least, share that this isn't an isolated incident.

Could you please provide a video/animation of this with Licecap and/or screenshots?

Could you please provide a video/animation of this with Licecap and/or screenshots?

documentation

Took a screenshot. This process can be reliably replicated.

@andfoy could you take a look a t this one?

I think the "errors" are due to our syntax error-based folding, it makes best effort folding detection, rather than provide a full solution for such cases. Therefore, we cannot do much besides asking users to have correct syntax code

@andfoy, that's not the problem. The problem is that when the user has folded regions in the editor and introduces new changes to it, it's not possible to correctly unfold those regions afterwards.

We haven't considered this case before and I think it requires to maintain in sync what's folded in the editor and new folding info coming from the PyLS.

I think it requires to maintain in sync what's folded in the editor and new folding info coming from the PyLS.

Actually, that's the case in https://github.com/spyder-ide/spyder/blob/48540b37fd2a27fbbbdd73b3ab8b1000b9c68e20/spyder/plugins/editor/panels/codefolding.py#L207

@GeraldWiseman, please upload a video because I don't understand why in your third screenshot func_B is in line 2, while in your second one is present on line 13.

@ccordoba12

I left a comment at the bottom of each screenshot explaining what I did. In that particular instance, funcB _was_ on 13 but I simply moved it above funcA with the alt+up command specifically to show that it forces what it passes through -- in this case funcA and its contents -- to become dislocated from its collapse arrow.

The specific lines were just happenstance. I could have placed it at any line above 6. Just happened to stop at 2.

I hope this clears things up. If you're still unsure of my reasonings, I left doc line at the bottom of each screenshot detailing the shot itself. As far as uploading a video, I'd have to download some capture software. If you still feel like a video is absolutely necessary I will download & report back with a video but I was hoping those images would be sufficient. Let me know.

I would like to point out that this doesn’t persist after restarting Spyder. At least, it didn’t for me. I don’t know if that means anything in the context of error handling.

Sent from my iPhone

On Jan 21, 2020, at 5:00 PM, Edgar Andrés Margffoy Tuay notifications@github.com wrote:


I think the "errors" are due to our syntax error-based folding, it makes best effort folding detection, rather than provide a full solution for such cases

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

I tried to use LiceCap, but windows couldn't find the file that LiceCap
saved. Only LiceCap could find the file that it saved.

Here is a screenshot of my issue.

Additionally, as it is probably associated with this problem, sometimes the
folds continue to exist but are shifted down a line.

On Tue, Jan 21, 2020 at 6:22 PM Michael Vander Wal vandermwal@gmail.com
wrote:

I would like to point out that this doesn’t persist after restarting
Spyder. At least, it didn’t for me. I don’t know if that means anything in
the context of error handling.

Sent from my iPhone

On Jan 21, 2020, at 5:00 PM, Edgar Andrés Margffoy Tuay <
[email protected]> wrote:



I think the "errors" are due to our syntax error-based folding, it makes
best effort folding detection, rather than provide a full solution for such
cases

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/11360?email_source=notifications&email_token=AELYJOFECQG7CSNQPGTRWETQ65WAPA5CNFSM4KJH2WPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJRNSMQ#issuecomment-576903474,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AELYJODX6OFMDG2P2BKU6ALQ65WAPANCNFSM4KJH2WPA
.

@EnderWiggin14, screenshots can't be send via email. You need to post them here directly.

@dalthviz please try to reproduce this issue. Thanks!

@ccordoba12 @andfoy a gif of the error (it involves the use of the option to move a line up in the Editor):

cf

it involves the use of the option to move a line up in the Editor

This is really cool to know. Thanks a lot @dalthviz!

Hi I am also facing problems with code fold.

Every time we remove line it does not follow the command that could demand code folding.

image

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yogu220172 picture yogu220172  Â·  3Comments

dalthviz picture dalthviz  Â·  3Comments

goanpeca picture goanpeca  Â·  3Comments

marianux picture marianux  Â·  3Comments

danieltomasz picture danieltomasz  Â·  3Comments