Repository: spyder-ide/spyder

Issue:
AttributeError when updating folding
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

-plz solvre this problem as soon as ppsssible i am not able to work properly

### Traceback
```python-traceback
Traceback (most recent call last):
  File "C:\Users\91771\AppData\Local\Programs\Spyder\pkgs\spyder\plugins\editor\widgets\codeeditor.py", line 2000, in finish_code_folding
    folding_panel.update_folding(self._folding_info)
AttributeError: 'CodeEditor' object has no attribute '_folding_info'
```

## Versions

* Spyder version: 5.3.3  (standalone)
* Python version: 3.8.10 64-bit
* Qt version: 5.15.2
* PyQt5 version: 5.15.7
* Operating System: Windows 10

### Dependencies

```
# Mandatory:
atomicwrites >=1.2.0                 :  1.4.1 (OK)
chardet >=2.0.0                      :  5.0.0 (OK)
cloudpickle >=0.5.0                  :  2.1.0 (OK)
cookiecutter >=1.6.0                 :  2.1.1 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree                         :  None (OK)
IPython >=7.31.1;<8.0.0              :  7.34.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.14.0 (OK)
keyring >=17.0.0                     :  23.8.2 (OK)
nbconvert >=4.0                      :  7.0.0 (OK)
numpydoc >=0.6.0                     :  1.4.0 (OK)
paramiko >=2.4.0                     :  2.11.0 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.1 (OK)
pygments >=2.0                       :  2.13.0 (OK)
pylint >=2.5.0;<3.0                  :  2.15.0 (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.1 (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.0 (OK)
setuptools >=49.6.0                  :  65.3.0 (OK)
sphinx >=0.6.6                       :  5.1.1 (OK)
spyder_kernels >=2.3.3;<2.4.0        :  2.3.3 (OK)
textdistance >=4.2.0                 :  None (NOK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog                             :  2.1.9 (OK)
zmq >=22.1.0                         :  23.2.1 (OK)

# Optional:
cython >=0.21                        :  0.29.32 (OK)
matplotlib >=3.0.0                   :  None (NOK)
numpy >=1.7                          :  None (NOK)
pandas >=1.1.1                       :  None (NOK)
scipy >=0.17.0                       :  None (NOK)
sympy >=0.7.3                        :  1.11 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)
```



Discussion:
Hey @jasneek5440, thanks for reporting and sorry for the inconvenience. We'll fix this error in our next version (5.4.0), to be released next month.

In the meantime, you can prevent Spyder from showing this error by checking the option called `Hide all future errors during this session` in our report errors dialog:

![image](https://user-images.githubusercontent.com/365293/191165049-ec3435a3-c36e-4084-a9cc-407d24e40bf1.png)

Resolving patch:
diff --git a/spyder/plugins/editor/widgets/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor.py
--- a/spyder/plugins/editor/widgets/codeeditor.py
+++ b/spyder/plugins/editor/widgets/codeeditor.py
@@ -573,6 +573,7 @@ def __init__(self, parent=None):
         self.formatting_characters = []
         self.completion_args = None
         self.folding_supported = False
+        self._folding_info = None
         self.is_cloned = False
         self.operation_in_progress = False
         self.formatting_in_progress = False
@@ -1997,7 +1998,12 @@ def update_and_merge_folding(self, extended_ranges):
     def finish_code_folding(self):
         """Finish processing code folding."""
         folding_panel = self.panels.get(FoldingPanel)
-        folding_panel.update_folding(self._folding_info)
+
+        # Check if we actually have folding info to update before trying to do
+        # it.
+        # Fixes spyder-ide/spyder#19514
+        if self._folding_info is not None:
+            folding_panel.update_folding(self._folding_info)
 
         # Update indent guides, which depend on folding
         if self.indent_guides._enabled and len(self.patch) > 0:


Test patch: