Change history markers confusion

57 views
Skip to first unread message

chinh...@gmail.com

unread,
May 15, 2025, 10:35:47 AMMay 15
to scintilla-interest
I'm a little confused by the behavior of the change history markers. I'm seeing a modified and saved marker in situations where I would've expected a reverted to modified marker. I am using only the markers and turned off the indicators.

If I open a file that contains the text

This is a test.

and edit it to

This was a test.

by moving the cursor to the right of the letter i in the word is, and pressing delete to delete the i, the marker in the change history margin turns orange. Typing the letters w, then a continue to make the marker orange. When I save it, the marker turns green. If I undo once, the marker turns green-yellow. If I undo once again, the marker turns cyan as the line is now at its original state. This behaves exactly as expected.

However, if I reopen the file and repeat the edits but after the first undo where the marker turns green-yellow, I add a character and the marker stays green-yellow instead of orange. The documentation states "The margin shows a block indicating the overall state of the line, prioritizing the more consequential modified states." but I still would've expected the line to be considered modified.

Now reopen the file and edit the line to

This as I rest.

by selecting the i in is and typing the letter a to replace the I, then selecting the letter a in the word a and pressing the letter I to replace it, then selecting the letter t in test and replacing it with r, the marker turns orange as expected. Save the file and the marker turns green. However, if undo once, the marker stays green instead of the green-yellow I expected. Undo again and the marker stays green. Why did the marker stay green instead of green-yellow? It appears that you get different marker colors depending on whether you edited from a single position on a saved line versus editing multiple positions on a saved line.

Reopen the file and edit the line to

This 1 is 2 a 3 test.

by inserting the characters and saving results in the same behavior with the marker staying green as you undo each change until you get back to the original state of the line. If you redo all the changes, the marker is green. Undo once and the marker stays green. Now type some text and the marker turns orange as expected but that conflicts with the behavior from my second behavior above where the marker stayed green-yellow after adding some text after an undo.

The documentation for SC_MARKNUM_HISTORY_SAVED (green marker) says "This line was modified and saved. This line is the same as its state on disk." but that's not the behavior that I'm seeing. I looked at Visual Studio and their history markers only have 3 states where there is no reverted to modified, it's just modified. I originally made reverted to modified and modified the same color but a tester got confused by it so I made reverted to modified its own color. I now see what the tester got confused by was the marker actually turning green after an undo instead of orange.

So is this all a bug or is it behaving as expected?

Also, I put the change history markers in its own margin. If I have markers on and indicators off, hiding the change history margin for some reason changes the background color of each line of text to the history marker color of each line.

chinh...@gmail.com

unread,
May 15, 2025, 1:07:37 PMMay 15
to scintilla-interest
changehistory.gif
Here's an animated gif of what I was describing. I changed the green-yellow (revert to modified) to just yellow to make it more distinguishable from the green (saved).

Neil Hodgson

unread,
May 15, 2025, 7:23:54 PMMay 15
to Scintilla mailing list
Chinh:

> I'm a little confused by the behavior of the change history markers. I'm seeing a modified and saved marker in situations where I would've expected a reverted to modified marker. I am using only the markers and turned off the indicators.

The indicators show the detailed state of change history and the markers try to summarize that state for each line. It is easier to understand the markers when the indicators are also visible.

The margin markers for each state present are all drawn so choosing markers that do not overdraw can show all the states on a line.

The prioritization is just the normal order of markers being drawn over each other. This order is REVERTED_TO_ORIGIN, SAVED, MODIFIED, REVERTED_TO_MODIFIED.

> However, if I reopen the file and repeat the edits but after the first undo where the marker turns green-yellow, I add a character and the marker stays green-yellow instead of orange. The documentation states "The margin shows a block indicating the overall state of the line, prioritizing the more consequential modified states." but I still would've expected the line to be considered modified.

The line contains both modified and reverted to modified. Reverted to modified overdraws modified.

> by selecting the i in is and typing the letter a to replace the I, then selecting the letter a in the word a and pressing the letter I to replace it, then selecting the letter t in test and replacing it with r, the marker turns orange as expected. Save the file and the marker turns green. However, if undo once, the marker stays green instead of the green-yellow I expected. Undo again and the marker stays green. Why did the marker stay green instead of green-yellow?

The undo returned that text to its original state so the line contains both saved and reverted to original. Saved draws last.

> The documentation for SC_MARKNUM_HISTORY_SAVED (green marker) says "This line was modified and saved. This line is the same as its state on disk." but that's not the behavior that I'm seeing. I looked at Visual Studio and their history markers only have 3 states where there is no reverted to modified,

Visual Studio has more states that do not have distinct visuals.

> So is this all a bug or is it behaving as expected?

It's likely behaving as expected. A different order of markers (different numbers for the SC_MARKNUM_HISTORY_*) may produce results closer to your expectations but that would not be compatible with existing applications.

I think that the alpha and layer attributes of the markers could be set by the application to change the perceived prioritization.

> Also, I put the change history markers in its own margin. If I have markers on and indicators off, hiding the change history margin for some reason changes the background color of each line of text to the history marker color of each line.

This is the behaviour of all margin markers: if there is no margin displaying a marker, it produces a line background colour change to ensure that it can be seen. This ensures that bookmarks or breakpoints are still visible when the user hides the relevant margin to increase space.

Neil

chinh...@gmail.com

unread,
May 19, 2025, 10:47:42 AMMay 19
to scintilla-interest
Thank you for your reply. I tried reordering the markers but it didn't help as I think the main issue is that the SC_MARKNUM_HISTORY_SAVED behavior (line history can still appear as saved after an undo) just doesn't align with the functionality I'm looking since I don't want to use indicators. I'll just have modified, reverted to modified, and saved markers use the same colors and effectively present just 2 states which is modified and reverted to origin. 
Reply all
Reply to author
Forward
0 new messages