icsharpcode / AvalonEdit

The WPF-based text editor component used in SharpDevelop
http://avalonedit.net/
MIT License
1.86k stars 470 forks source link

VisualLineElementGenerator When the line ending is \t #350

Closed q812143836 closed 2 years ago

q812143836 commented 2 years ago

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