Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Annotation stay its line or is moved when InsertText with line break is called. It depends on if the current line is empty or not. #498

Open
FilipRychnavsky opened this issue Dec 17, 2020 · 0 comments

Comments

@FilipRychnavsky
Copy link

Hello,
I have observed the following behavior.
I have a line with annotation and I am inserting a text that starts with one or more line breaks.

  1. If I insert the text on the end of an empty line, the annotation will be moved to the last added line.
  2. If I insert the text on the end of a not empty line, the annotation stays on the current line.
m_rScintilla_TextArea.ClearAll();
m_rScintilla_TextArea.InsertText(0, "abc\r\r\rdef");
SetAnnotationOnEachLine();
DebugAnnotations();
Debug.WriteLine("Inserting line break with in the middle of a text (end of second line) on an empty line. Annotation will be moved into new line");
m_rScintilla_TextArea.InsertText(4, "\rnew test");
DebugAnnotations();
/*
// Generates
Line | Annotations | Text
0|This is an Annotation for Line 0.|abc
1|This is an Annotation for Line 1.|
2|This is an Annotation for Line 2.|
3|This is an Annotation for Line 3.|def
Inserting line break with in the middle of a text (end of the second line) on an empty line. The annotation will be moved into the new line
Line | Annotations | Text
0|This is an Annotation for Line 0.|abc
1||
2|This is an Annotation for Line 1.|new test
3|This is an Annotation for Line 2.|
4|This is an Annotation for Line 3.|def
*/

Debug.WriteLine("\n");
m_rScintilla_TextArea.ClearAll();
m_rScintilla_TextArea.InsertText(0, "abc\rSOMETEXT\r\rdef");
SetAnnotationOnEachLine();
DebugAnnotations();
Debug.WriteLine("Inserting line break with in the middle of a text (end of second line) on a non empty line. Annotation will stay on the line of position of insertion.");
m_rScintilla_TextArea.InsertText(12, "\rnew test");
DebugAnnotations();
/*
// Generates
Line | Annotations | Text
0|This is an Annotation for Line 0.|abc
1|This is an Annotation for Line 1.|SOMETEXT
2|This is an Annotation for Line 2.|
3|This is an Annotation for Line 3.|def
Inserting line break with in the middle of a text (end of the second line) on a non-empty line. The annotation will stay on the line of the position of insertion.
Line | Annotations | Text
0|This is an Annotation for Line 0.|abc
1|This is an Annotation for Line 1.|SOMETEXT
2||new test
3|This is an Annotation for Line 2.|
4|This is an Annotation for Line 3.|def
*/

DebugAnnotations() and SetAnnotationOnEachLine() not added because of brevity

Are there any rules that I have to obey by inserting text with new lines concerning annotations?

Thanks & seasonal greetings
Filip, Bremen

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant