Recent

Author Topic: [SOLVED] Parasitic cursor in code editor.  (Read 6759 times)

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
[SOLVED] Parasitic cursor in code editor.
« on: November 16, 2018, 12:39:13 pm »
Win 10

Drag the edit window such as the last line is below the screen area, then use keyboard cursor down repetitively.

A parasitic cursor gets scrolled up the edit window.

Can someone reproduce or is it an artefact of my system ?
« Last Edit: November 19, 2018, 12:04:51 pm by BrunoK »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #1 on: November 16, 2018, 01:06:38 pm »
Does not happen for me. Win10 64bit Lazarus trunk.

Please attach your editor options.
Also check with Lazarus 2.0RC2 there may be caret related changes in there. If it is ok, in 2.0 test with a custom caret color too (color options)
« Last Edit: November 16, 2018, 01:09:39 pm by Martin_fr »

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
Re: Parasitic cursor in code editor.
« Reply #2 on: November 16, 2018, 03:11:06 pm »
If I change in 'IDE Options'/Editor/Display/Colors/Text/Caret :
Color (NotXor) from NotModified to Black or Olive for example, there is not parasitic trail.
When changing back to NotModified the Parasitic trail reappears.

What file (xml ?) does contains this parameter, I didn't manage to track it down.

@Martin_fr, please don't loose any time on that, it is a really a very minor problem.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #3 on: November 16, 2018, 06:46:25 pm »
What file (xml ?) does contains this parameter, I didn't manage to track it down.
In the IDE go to menu: View > Ide Internals > About IDE
Locate the "primare config path"
In that path is a file "EditorOptions.xml"

Please provide this file.
Just so, I can try under identical conditions.

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Parasitic cursor in code editor.
« Reply #4 on: November 16, 2018, 07:27:50 pm »
@Martin, btw why I see 2 carets in recent trunk (don't know when they actually appeared) when code completion window is open and I'm typing ?
eg Self.|Fo|  (typing Self.Fo and code completion window is open), tested with qt4 and qt5 under X11.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #5 on: November 16, 2018, 07:53:47 pm »
I currently only have gtk on linux (Fedora 28). Not using it much, but no problems yet.

"2 carets" => both blinking? But only one responds/types input?
Both exactly the same color, or one slightly fainter?

Cant think of any recent changes...

But please provide a log, compile IDE with:
-dSynCaretDebug -dSYNSCROLLDEBUG -dVerboseSynEditInvalidate -dSynCheckPaintLock -dVerboseFocus -dVerboseKeys

run
lazarus --debug-log=/path/file

Depending on how it goes, I may have to add more debugln....

The VerboseKeys, is so I can match your actions against the log. So please describe when you pressed what key, and what happened.
« Last Edit: November 16, 2018, 08:02:25 pm by Martin_fr »

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Parasitic cursor in code editor.
« Reply #6 on: November 17, 2018, 09:42:10 am »
I currently only have gtk on linux (Fedora 28). Not using it much, but no problems yet.

"2 carets" => both blinking? But only one responds/types input?
Both exactly the same color, or one slightly fainter?

Yes, see attached screenshoot. First caret stays at the beginning where code completion is started, second one after the last typed letter. Both are blinking. Only second one responds to typing in code completion and moving. First one is always at the beginning where code completion window is shown.

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
Re: Parasitic cursor in code editor.
« Reply #7 on: November 17, 2018, 10:27:01 am »
In that path is a file "EditorOptions.xml"

Please provide this file.
File attached.

guest58172

  • Guest
Re: Parasitic cursor in code editor.
« Reply #8 on: November 17, 2018, 11:26:19 am »
Cant think of any recent changes...

r59490 maybe ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #9 on: November 17, 2018, 11:58:25 am »
r59490 maybe ?
Unlikely, the forms (and its parents visibility does not change there). But you could test it, its a small change, and it can be undone, without rolling back anything else.

I think the 1st and 2nd should also be easy to unroll

More likely candidates:
58647 SynEdit: Caret Color (July 2018)
58644 SynEdit: fix default caret painter class (set to system) (July 2018)
58534 SynEdit: Option to have a static (none blinking) persistent caret. Issue 0033653
49115 SynEdit: fix to system caret / Restore system caret as default, if not using multicaret (May 2015)

They are all based on the last one (49115).



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #10 on: November 17, 2018, 05:20:05 pm »
Ok, I can reproduce the issue of BrunoK.

One of the reasons I did not reproduce right away is that on the bottom of my screen is the task bar. And it is not sufficient, to hide the editor's bottom behind the task bar. It really needs to be out of the screen.

The other reason, it does not happen to me (though I had tried without) is that I have a "current line highlight"

As a workaround, it should be possible to set a "current line highlight", specify a background color equal to the editors background.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #11 on: November 17, 2018, 06:26:46 pm »
Any idea where to get the qt5pas for fedora 28?
« Last Edit: November 17, 2018, 09:15:36 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #12 on: November 17, 2018, 08:54:32 pm »
Reproduced the qt issue too (with qt4 on win).

The problem is that LCLIntf.CreateCaret does return false (aka caret failed to be created). So SynEdit does not remove it.

During autocompletion SynEdit uses its own caret, so the system caret remains.

-----
@zeljko

please test
In unit SynEditPointClasses
line approx 2765

Code: Pascal  [Select][+][-]
  1. function TSynEditScreenCaretPainterSystem.CreateCaret(w, h: Integer): Boolean;
  2. begin
  3.   // do not create caret during paint / Issue 0021924
  4.   Result := HandleAllocated and not InPaint;
  5.   if not Result then
  6.     exit;
  7.   inherited CreateCaret(w, h);
  8.   inherited SetCaretPosEx(-1, -1);
  9.   Result := LCLIntf.CreateCaret(Handle, 0, w, h);
  10.   SetCaretRespondToFocus(Handle, False); // Only for GTK
  11.   debugln(['==SYSTEM CARET +++ CREATED ', result]);  // <<<<<<<<<<<<< insert
  12.   if not Result then inherited DestroyCaret;
  13. end;

and get the output
  lazarus --debug-log=file
or run with console.

---
Edit:
https://bugs.freepascal.org/view.php?id=34563

@zeljko, if the above does log false for you, please update/confirm on the issue.

--
A workaround for the QT issue has been applied in r59580
@zeljko, please confirm if this "fixes" it for you => then it can be merged to 2.0
« Last Edit: November 17, 2018, 09:43:54 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #13 on: November 17, 2018, 11:47:35 pm »
@BrunoK

It is actually not an issue with scrolling. It happens whenever the caret is "unpainted" outside the screen.

Place the caret at the bottom of the editor. Move the bottom so it is off screen.
Click the desktop, or otherwise un-focus the editor. This will trigger the editor to hide the caret.
When you activate the editor, do so by clicking in the visible text area, so the caret is re-created at a new position.
Move the editor back into view, and there will be a permanent caret, where the old caret used to be.

I dont have win 7/8, but under Vista this error does not happen...

Still evaluating, what (if) the best way is to deal with it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Parasitic cursor in code editor.
« Reply #14 on: November 18, 2018, 09:01:10 pm »
A fix for the issue has been committed in r59596.

I believe it is an issue in Windows itself. Though it is bound to rather complex conditions, which is why it may not be seen in other apps.

Except a very similar (but maybe different) issue exists in wordpad, where instead of ghost carets, the last line of text (before scrolling start) is repeated over and over, if the bottom of wordpad is off-screen.

To trigger the issue conditions as mentioned below must be present.
Since most editors, will simple invalidate the entire line (gutter, text and all), in those apps the issue never manifests.
SynEdit attempts to be to clever. Yet that it works, if the caret is "on screen", indicates that it is meant to work.

     To reproduce, the editor must have a visible gutter; and must not have "current line" highlight.

     * The conditions to cause this:
     - Caret must be in part of editor that is outside the screen.
     - Caret must be destroyed (maybe only hidden?), or ScrollWindowEx must affect caret
     - Caret must be in a part of the editor for which NO call to "invalidate" was made,
       but which will be repainted. (repaint uses the minimum rect enclosing the combination of *all* invalidates)
       E.g. the gutter, but not the line area received an invalidate, and another line above/below was invalidated
       (can happen through ScrollWindowEx). -> In this case the paint message receives a rect, that contains the caret,
       even though the part containing the caret was never explicitly invalidated.
     If this happens, while the caret is on screen (even if hidden behind another window/taskbar) then all works ok.
     But if the caret was off screen, a permanent image of the caret will remain (once scrolled/moved into the screen area).
     It seem that in this case windows does not update the information, that the caret became "invisible" when paint did paint
     over it. So if the already overpainted caret, is later (by Windows) attempted to be hidden by a final "xor", then it actually
     is made permanently visible.

 

 

TinyPortal © 2005-2018