Repository: spyder-ide/spyder

Issue:
Code analysis markers are not positioned correctly when code is folded
## Problem Description
WHen I roll up an indentation (for, if, call a function) and try to acces to code analysis or set a red point (don't know the name) it is offbeat of the same numer that lines that are roll up. So I have to put my mouse pointer under the error flag to get infos about it

### What steps reproduce the problem?

1.  role up one or more line
2.  try to acces to code analysis warning

## Versions
* Spyder version: Spyder 4.1.2 
Python 3.7.6 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Linux 4.15.0-96-generic 

### Dependencies
```

# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.3.0 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.13.0 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  0.9.2 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.0 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=0.25                  :  2.4.4 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8 (OK)
qtawesome >=0.5.7              :  0.7.0 (OK)
qtconsole >=4.6.0              :  4.7.1 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.3 (OK)
sphinx >=0.6.6                 :  2.4.0 (OK)
spyder_kernels >=1.9.0;<1.10.0 :  1.9.0 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  18.1.1 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  3.2.1 (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  1.0.3 (OK)
scipy >=0.17.0                 :  1.4.1 (OK)
sympy >=0.7.3                  :  None (OK)
```



Discussion:
I can confirm the breakpoint offset with code folding. 

The errors seem to work aright but they disappear when you fold the code. They should probably be listed in the head of the folded section.

System info: Spyder 4.x dev on Linux

![Debug dot offset](https://user-images.githubusercontent.com/10513354/79251063-e72f5d80-7e3c-11ea-811c-3a595da676d7.gif)

> I can confirm the breakpoint offset with code folding.

What's the problem exactly @bcolsen?
This is just with the mouse position calculations.  The mouse positions on the side bar doesn’t seem to update to the new line numbers when code folding.

I can reproduce the error now too. I need to place the mouse cursor two lines below the error to get the mouse over.

![error mouse offset](https://user-images.githubusercontent.com/10513354/79257972-ab4dc580-7e47-11ea-8402-592860cf7da4.gif)

The error is likely in this section:
https://github.com/spyder-ide/spyder/blob/856a88456a830751600e4c043cb54f32fec352a9/spyder/plugins/editor/widgets/codeeditor.py#L2062-L2077

The folding panel uses it's own mouse events and is working properly.
Thanks for the clarification @bcolsen!

@steff456, please take a look at this one.

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
@@ -2067,13 +2067,12 @@ def get_linenumber_from_mouse_event(self, event):
                                                     self.contentOffset()).top()
         bottom = top + self.blockBoundingRect(block).height()
         folding_panel = self.panels.get(FoldingPanel)
-
         while block.isValid() and top < event.pos().y():
             block = block.next()
             if block.isVisible():  # skip collapsed blocks
                 top = bottom
                 bottom = top + self.blockBoundingRect(block).height()
-                line_number += 1
+            line_number += 1
         return line_number
 
     def select_lines(self, linenumber_pressed, linenumber_released):


Test patch: