AvalonEdit icon indicating copy to clipboard operation
AvalonEdit copied to clipboard

VisualLineElementGenerator When the line ending is \t

Open q812143836 opened this issue 3 years ago • 0 comments

When the line ending is \t I want to replace with the specified custom control But it will not take effect when the string is highlighted in the line content I don't know where is the problem, hope you can help me thanks a lot

TEST

`internal class TestElementGenerator : VisualLineElementGenerator { public override VisualLineElement ConstructElement(int offset) { return new InlineObjectElement(0, new TestControl()); }

    public override int GetFirstInterestedOffset(int startOffset)
    {
        DocumentLine endLine = CurrentContext.VisualLine.LastDocumentLine;
        StringSegment relevantText = CurrentContext.GetText(startOffset, endLine.EndOffset - startOffset);
        int count = relevantText.Count;
        if (count > 0)
        {
            if (relevantText.Text[count - 1] == '\t')
            {
                return endLine.EndOffset;
            }
        }
        return -1;
    }
}`

@sandrejev

q812143836 avatar May 29 '22 17:05 q812143836