Conditions in Geany
Steps to reproduce
1: open Geany
2: open two different txt-documents, both very long, so that only two tabs exist
3: close Geany
4: reopen Geany (result: the txt-document what is in focus is shown correctly)
5: switch to the other tab where the other txt-document is located
Result
The problem is that this happens not often, and one need to scroll to look for double lines (I did all the steps above about 20 times and during the 20 times I switched sometimes to Firefox to surfed around):
The txt-document is not shown correctly. Some lines of the document are shown twice. What is also strange is that the cursor is stretched over two lines. Once I saw multiple lines, I think it was 4x. Here two examples:
https://github.com/geany/geany/issues/3271
https://github.com/xiota/geany/issues/2#issuecomment-1226190192
Remark
I thought that it was caused by the plugin Geany Preview or by using Geany 1.39 by PPA (https://github.com/xiota/geany/issues/2 and https://github.com/xiota/geany/issues/3). But yesterday I reinstalled Lubuntu 22.04, I installed Geany 1.38 (not the PPA-version), I installed geany-plugins (without activating a plugin), I installed some software for kvantum for having the dark mode, and I used Sleepy Pastel as colorschemes in Geany. And then the issue was there again. I can't remember that I saw this issue in Geany 1.37.
The issue disappears when during the Geany session View>Show Line Numbers will be activated in the menu. By deactivating it again, the issue does not appear any more in the Geany session. Same for wrapped lines: In the moment where long lines are not wrapped any more, the issue disappears. By activating wrapped lines again in the menu, the issue does not appear any more in the Geany session. The issue occurs in documents with txt-format and html-format, but maybe also in other formats. The issue appears in some lines: If a line is not wrapped, or the last line of wrapped lines. Maybe those hints can help to figure out where the problem is. When I was using Geany 1.39 by PPA with the plugin Geany Preview and two lua-scripts, I could reproduce the steps from above (Steps to reproduce) every time. I don't know how to install Geany git version or latest Scite for making tests.
I have seen this rarely. A possibility is that buffered drawing is on and that an error in the drawing code causes return to the by-line loop without any new drawing into the buffer bitmap. Then the previous line's image is drawn onto the new line. You could turn off buffered drawing (SCI_SETBUFFEREDDRAW) if it is on to check this - I don't know if Geany supports changing this setting.
Another possibility is that there is a bug in the line wrap positions so that the same subline is present twice.
And how should it be determined if it is a bug or not?
Run the application inside a debugger. When the problem occurs, break into the debugger and examine the state of the line wrap positions.
In the editor FeatherPad I replaced in
src/editor.cthis codeby this code:
Then I saved the document. I closed the document in the editor.
In the terminal I did:
The issue is not there any more.
A check could be added to
LineLayout::AddLineStartto see if the line starts are unexpected:The change should abort with a message if there is a problem. This patch is based on current Scintilla and Geany may be using an old version that doesn't have
AddLineStartbut there'll be some similar code that adds line starts.Another possibility is that there is a difference with the number of screen lines for a document line between the
LineLayoutobject for the line and theContractionStatefor that line. These could be unsynchronized if background wrapping code isn't run.It may be possible to check for this with this assertion.
To your last two posts:
I'm not a software developer, I'm just a software user. I can just program simple HTML-code. I have no idea how to install or use a debugger. But I already asked for help ( https://github.com/geany/geany/issues/3271#issuecomment-1237248610 ).
Last edit: Neil Hodgson 2022-09-05
First I would like to mention this:
When buffered drawing is turned off, then the issue is not there any more, but then there are two disadvantages:
The disadvantages occur only if an other tab with a txt-document is right away in focus after a restart of Geany. In other words: If the tab of the corresponding txt-document is right away in focus after a restart of Geany, then there are no disadvantages.
The disadvantages occur only if "Line Wrapping" is activated. By deactivating and reactivating the disadvantages disappear.
I think that all the problems are because the line stops at the right border.
Last edit: Rudolph 2022-09-05
If this is the case for all occurrences then it is a significant clue.
Before I turned off buffered drawing, here a picture of the issue with the stretched cursor over two lines.
In which document should I look for it? Or is a debugger necessary?
scintilla/src/PositionCache.cxxRun the application from a command prompt and the assertion message should show there when the failure occurs. Running inside a debugger helps examine the context and possibly continue from the assertion.
For someone that isn't a software developer the priority should be finding a 100% reproducible case that shows the bug. If I can't make the bug happen then its very unlikely I can work out why it is occurring then fix it. If a reproducible case can't be found then evidence about the conditions under which the bug occurs can help others investigate the bug.
From a command prompt, an assertion failure looks like this running SciTE (I use SciTE, so am am set up to build and run it):
The above had the assertion added but with the check inverted to provoke a failure to illustrate.
Running inside the common
gdbdebugger whererunthen back tracebtare the most commonly useful things to do:The bug occurs at the moment on a 22-inch-FHD-display. I could try to reproduce it on a 15.6-inch-FHD-notebook on Lubuntu-Live-ISO with Geany installed by PPA (that uses geany-git from last Sunday), with two txt-documents. I could then upload the two txt-documents so that you could see the bug and work on it. What you think about that and do you have a 15.6-inch-FHD-notebook (I could try maybe on 11-inch-FHD-notebook)? Or do you have an other suggestion?
Last edit: Rudolph 2022-09-06
I only use Linux in a virtual machine through VirtualBox on Windows, so hardware form factor won't match.
You should upload the text documents that have shown the effect as there could be something unusual about them.
Why running Lubuntu-Live-ISO with Geany installed by PPA (that uses geany-git from last Sunday) is not possible?
I don't think that you will see the bug, but who knows. Just follow the description. Please tell me if you see the bug.
scintilla_bug.txtappears to be a recipe for producing the actual file. Just upload the actual file.Lubuntu 22.04as mentioned above, does not seem to have a simple download link from https://lubuntu.net/ which mentions various 19.x versions."Geany installed by PPA" is unclear: provide shell commands to do this.
If you go on en.wikipedia.org and type Lubuntu, then the answer will be lubuntu.me as webpage and not lubuntu.net.
I would give a very clear step-by-step-description. But I think that the bug depends on the display-size and the resolution: For testing your display must be Full HD.
Is your display Full HD?
Which kind of display-size (in inch) do you use for testing (examples: 11´´ or 15.6´´ or 22´´ or 24´´) (the best for me would be 22´´ or second best 15.6)?
Please answer both questions and then I will try to reproduce the issue on Lubuntu ISO on a computer with the corresponding display size.
Last edit: Rudolph 2022-09-07
Last edit: Rudolph 2022-09-07
The issue exists already in Geany 1.38. Is that OK for you if I try to reproduce the issue in live ISO Lubuntu 22.04 in Geany 1.38 or you prefer the Geany nightly tarball by PPA from last Sunday?
Geany 1.38 would be easier because it is only the command sudo apt install geany.
Last edit: Rudolph 2022-09-07
step-by-step-description how to see the bug
1: run the ISO of Lubuntu 22.04.1 from lubuntu.me
2: open Main menu, System Tools, Qterminal
3: sudo apt install geany
4: open Geany by terminal: geany
5: maximize the Geany-window
6: open the two txt-documents scintilla_restart.txt and scintilla_bug_long.txt
7: follow the instructions of scintilla_bug_long.txt
I could not reproduce the bug on Xubuntu 22.04.1, neither on a 15.6´´display (notebook) nor on a 22´´ display (desktop PC).
I could reproduce the bug on ISO of Lubuntu 22.04.1, sometimes on a 15.6´´display (notebook) and always on a 22´´ display (desktop PC).
Can you confirm the bug on the ISO of Lubuntu 22.04.1?
Last edit: Rudolph 2022-09-08
I have reproduced the bug. It doesn't occur in many similar situations (like a 1,000 line file) so its likely to be caused by particular sequences of operations. That will make it more difficult to understand and fix.
This occurs because the widget (and file) is active while hidden as an unselected tab. At this point, it is not a real (mapped, realized) window but already has a file loaded and is trying to wrap the file's text. It wraps a portion of the text and is then resized to be 7 pixels wider (I don't know why). This takes line 15 from requiring 2 lines to all fitting on one line. Because the resize occurs while the widget doesn't have a window, it doesn't run some code including invalidating the wrap information for lines already wrapped. There was a deliberate choice in [20a8ad] to ignore size changes before the widget is mapped.
The check for mapped window could be removed by inverting the above change set, calling
ChangeSize(inscintilla/gtk/ScintillaGTK.cxxScintillaGTK::Resize) even when the widget is unmapped. This seemed to work, but I don't know what the change was protecting against - perhaps it is no longer an issue but it could also cause new problems. For example, scrollbars are manipulated insideChangeSizeand perhaps they aren't ready so will fail or will fail under particular window systems or GTK versions.Try removing the
GTK_WIDGET_MAPPEDcheck. It could be changed in Geany if it works but its more dangerous for Scintilla which runs on older versions of GTK than are supported by Geany. SciTE, for example, runs on GTK 2.x and won't see the bug as it maps Scintilla widgets before loading files.Checking for changes in size in more places and clearing cached wrapping data could fix this but there are issues here with data consistency. There could be unnecessary work when resize events with no actual change in size occur which is common.
Related
Commit: [20a8ad]