notepad4 icon indicating copy to clipboard operation
notepad4 copied to clipboard

Long Line screen update bug

Open meteorquake opened this issue 1 year ago • 8 comments

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

meteorquake avatar Mar 28 '24 21:03 meteorquake

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

zufuliu avatar Mar 29 '24 11:03 zufuliu

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?

meteorquake avatar Mar 29 '24 11:03 meteorquake

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

zufuliu avatar Mar 29 '24 11:03 zufuliu

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.)

meteorquake avatar Mar 29 '24 12:03 meteorquake

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

zufuliu avatar Mar 29 '24 12:03 zufuliu

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).

meteorquake avatar Mar 29 '24 12:03 meteorquake

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

zufuliu avatar Mar 31 '24 00:03 zufuliu

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

zufuliu avatar May 25 '24 00:05 zufuliu