Todo Comment Shows Twice In ToDo Window

Answered

In my plugin I am getting todo comments appearing twice in the view for the same item.

Once without the closing comment marker and once with it.

I am stumped on why it happens. I tried to figure it out but to no avail. It must be collected from two different places.

In the past I had some changes to the spell checker clobber ToDo items in the view but cannot remember if it was spellchecker extension or lexer related issues.

I have spellchecker.supportextension and a lang.commenterextension and a todoIndexerextension which looks like this:

public class MdFilterLexer extends BaseFilterLexer {
    public MdFilterLexer(final Lexer originalLexer, final OccurrenceConsumer table) {
        super(originalLexer, table);
    }

    @Override
    public void advance() {
        final IElementType tokenType = myDelegate.getTokenType();
        if (tokenType == MdTypes.COMMENT) {
            scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
            advanceTodoItemCountsInToken();
        }
        myDelegate.advance();
    }
}

Any insight or suggestions where to look would be greatly appreciated.

 

2 comments
Comment actions Permalink

Update, I found that the todoIndexerextension is causing the issue. If I remove theadvanceTodoItemCountsInTokenthen only the comment processed shows up.

When is does a plugin need to provide a todoIndexerextension?

0
Comment actions Permalink

Finally figured it out. The cause was language injections. A comment by itself is an HTML Block in markdown so it was marked as such.

HTML blocks get automatically injected with HTML language in my plugin.

That was the source of the problem. The comment was in the injected HTML processed by that language and it also had a token for Markdown comment as its contents. Hence it was included twice for each language.

Removing inner comments from HTML blocks if they get language injection solved the problem.

The clue was having the trailing comment close in one of the occurrences. HTML todo does not have the trailing comment close, markdown did.

0

Please sign in to leave a comment.