zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
3.13k stars 203 forks source link

Long Line screen update bug #782

Open meteorquake opened 6 months ago

meteorquake commented 6 months ago

I have a normal JS file, but there's an initiation function at the end containing a 99K string that's used to populate a global variable with keys and values, so that variable appears earlier in the code for usage (after being populated by a call to that end function).

If in word-wrap mode I go to the earlier variable reference and do a Ctrl-F3 to find the next usage, it accordingly jumps to the reference that's immediately after that long string.

The variable and its line accordingly appears and you would want the tail end of that long string to show above it. What actually happens is that the screen part above it where the string tail end should show does not update and so continues to show the code which was showing there prior to the Ctrl-F3 jump. It can also obviously do it using Ctrl-End to get there. However the slightest movement such as an arrow right to move the cursor, causes that part of the screen to update and the string tail end to show. It is slightly layout specific - at a slightly different zoom it may show the tail end correctly, and depending on the starting line when Ctrl-End is pressed it may or may not do it.

I'm not sure how long the long line has to be for this artifact to happen, but it's definitely not acting as it should, and the update that happens when the cursor is moved shows that it's quite capable of showing it correctly.

The long line is of the form (where the dots are characters with few spaces in):

var a='.....................'.split(',');

Notepad2 (64-bit) 4.24.03 r5146 (7c12b835) Compiled on Mar 17 2024 with Visual C++ 19.39.33522.0, Scintilla 5.4.1. Encoding: UTF-8, Windows-1252 Scheme: , JavaScript System: 10.0.19045 x64

bug also present on r5052.

Cheers, David

zufuliu commented 6 months ago

This is due to partial line layout for long line limited the time (250ms) to wrap long line to avoid UI freeze.

meteorquake commented 6 months ago

Thanks, I thought it would be something practical. What is the mechanism behind the line being instantly shown when I then move the cursor a tiny amount - has it by that time worked it out as a background task?

zufuliu commented 6 months ago

Lines are wrapped when editor is idle (250ms a time), Ctrl + End force whole line be wrapped (UI may freeze), go to specific column force the target position + next 4KB bytes on the line be wrapped.

https://github.com/zufuliu/notepad2/blob/065c63a0c948bcf69278a8f235ffc9583000e2f1/scintilla/src/EditView.cxx#L433-L446

meteorquake commented 6 months ago

I suppose this raises the question of whether it should go on to display it when the layout becomes available, or else show some kind of mask-out for the area concerned. I realise it's slightly a niche case although I suspect with anyone viewing long lines of obfuscated JS code it may be less niche than imagined. (In my case it was a slab of data summarising prior years to straddle the fact that my workplace has changed accounting systems and a report needs to include old data from the old system to compare the new data with.)

zufuliu commented 6 months ago

It should display the code folding ellipsis at line end (similar to VSCode) when the line is not whole wrapped. image

https://github.com/zufuliu/notepad2/blob/065c63a0c948bcf69278a8f235ffc9583000e2f1/scintilla/src/EditView.cxx#L1322-L1330

meteorquake commented 6 months ago

In word-wrap mode it's showing code from much earlier in the document (whatever was at the location I had jumped from, as it simply doesn't update the screen).

zufuliu commented 6 months ago

Hi @meteorquake, can you test latest builds from issue-782 branch (e.g. https://github.com/zufuliu/notepad2/actions/runs/8494534394)?

zufuliu commented 4 months ago

deleted issue-782 branch, call Redraw() has no effect due to redrawPendingText is true, see https://sourceforge.net/p/scintilla/bugs/2436/.