andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 39 forks source link

After clicking, scrolling jumps up. #396

Closed vi closed 8 years ago

vi commented 8 years ago

Suppose viewport is at about 50% and I'm scrolling down (52%, 55% ...). At 60% I stop scrolling and click at some line. After that I continue scrolling down. But instead of going further down it "jumps" up, for example, at 40% before proceeding down. It does not happen with Ctrl+up/down scrolling.

Also, despite of being usual C file, Enki does not display Navigator and syntax highlight looks very partial (void, #include, static, for, // TODO, int is highlighted, but not struct, int16_t, unsigned)

andreikop commented 8 years ago

I can't reproduce this problems. main.c is highlighted fine for me, and file is not scrolled automatically. Could you make a video and a screenshot?

vi commented 8 years ago

http://vi-server.org/pub/enki_issue_396.mkv

Shows both bugs. Looks like the one with scrolling is also reproducible on other opened files (on testdemod.c it jumps down instead of up).

andreikop commented 8 years ago

Now I see the bugs but still can not reproduce. Which Qt version do you have? Are you sure you are using the latest Enki master and Qutepart master? Could you post minimal text file where struct is not highlighted with bold?

vi commented 8 years ago

libqt5gui5 is 5.3.2+dfsg-4+deb8u1 qutepart is dcccf5b5b42cc17e6995f7687d194c7b7646ddcb enki is 13092303409e6b2560cd2be247b580af2e7cb51f


Copying mod.c to qwerty.c and opening it in the same Enki instance using Locator's ./qwerty.c reveals correctly working file (with Navigator and with correct highlight, although still incorrect scrolling)

Maybe the problem was in detection of syntax highlight mode when mod.c was opened for the first time (when it was still little). How do I explicitly display current syntax mode?

andreikop commented 8 years ago

Update Qutepart, do ./editor -l mod.c

vi commented 8 years ago

For current version of the file it prints Language: C. I didn't saved early enough version file although.

I suspect that if I close and reopen the file in that Enki instance, it will become allright. Shall I try this or shall I keep it in the wrong state for a change to gather some data?

andreikop commented 8 years ago

There are no data to capture. And I don't have an idea why the file was recognized incorrectly. Was there some special header. I.e. python shebang in the first line?

vi commented 8 years ago

No. Maybe it was empty, maybe there was some #include or #if.

How do I dump syntax language from currently running Enki?

andreikop commented 8 years ago

No way

vi commented 8 years ago

The annoyance continues (unrelated to syntax, now it's in Rust file). Now it doesn't always happen, but happens sporadically: sometimes viewport position jumps on scroll after clicking, sometimes after searching.

Shall I consider temporarily downgrading to pre-Py3-Qt5 version?

bjones1 commented 8 years ago

Is the Preview window open with CodeChat enabled?

vi commented 8 years ago

What is CodeChat?

It's just Opened Files pane on the left and editor (without Preview or Navigator) in main area.

bjones1 commented 8 years ago

CodeChat transforms source code to a web page, interpreting comments as reStructuredText. See https://pythonhosted.org/CodeChat/README.html for details. If that's enabled, I was wondering if the preview sync was causing problems. But, given the Preview window isn't open, that's not the cause.

andreikop commented 8 years ago

I don't have an idea why this happens and how to fix this. Seems like Qt bug. I don't have this bug on Linux Mint 17.3 Qt 5.2.1 and up to date Qt (something like 5.5.x) Closing the issue because there is nothing to do about it. @vi, try to update or downgrade your Qt. I hope you'll stay on Enki master, it has many improvements compared with previous version.

vi commented 8 years ago

My current Qt:

libqt5gui5:
  Installed: 5.3.2+dfsg-4+deb8u1
vi commented 8 years ago

Where shall I look to try debugging the issue on my side?

Can you prepare, for example, a branch with verbose logging regarding to scrolling and viewport changes?

andreikop commented 8 years ago

I don't have an idea why this happens. Check if the bug reproduces on editor.py from Qutepart. If it does - check pure QPlainTextEdit.

vi commented 8 years ago

Reproducible with editor.py:


Qutepart is fdc29c79eb6f3228897cfb713e047bf1d9a48198

vi commented 8 years ago

Reproduced also with QPlainTextEdit (copied editor.py changed qpart = QPlainTextEdit() and removed extras)

vi commented 8 years ago

Hacky workaround:

class MyPTE(QPlainTextEdit):
    def wheelEvent(self, ev):
        import time
        t = time.time()
        try:
            if t - self.lastScrollEventTime < 0.2:
                super().wheelEvent(ev)
        except AttributeError:
            pass
        self.lastScrollEventTime = t

Where to insert it to QutePart?

andreikop commented 8 years ago

qutepart/init.py Qutepart class 25 марта 2016 г. 13:02 пользователь "Vitaly Shukela" < notifications@github.com> написал:

Hacky workaround:

class MyPTE(QPlainTextEdit): def wheelEvent(self, ev): import time t = time.time() try: if t - self.lastScrollEventTime < 0.2: super().wheelEvent(ev) except AttributeError: pass self.lastScrollEventTime = t

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/hlamer/enki/issues/396#issuecomment-201225788

vi commented 8 years ago

Applied workaroud, now Enki scrolls well.