'use strict';
var getLineFromPos = require('get-line-from-pos');

//test for comments that have todo/fixme + text
var rLineComment = /\/\/\s*(todo|fixme):?\s*([^\r\n]+)+/gi;
var rBlockComment = /\/\*(?:[\s\S]*?)\*\//gmi;
var rInnerBlock = /[\n\r\s]*?(todo|fixme)?:(.+)\s*/gi;

module.exports = function (contents) {
    var comments = [];
    var index;

    //look for line comments
    var match = rLineComment.exec(contents);
    while (match) {
        if (!match || !match.length) {
            return;
        }
        // verify kind and value exists
        if (!match[1] || !match[2]) {
            return;
        }
        index = match.index;
        comments.push({
            kind: match[1],
            value: match[2],
            line: getLineFromPos(contents, index)
        });
        match = rLineComment.exec(contents);
    }

    //look for block comments
    match = rBlockComment.exec(contents);
    while (match) {
        if (!match || !match.length) {
            return;
        }
        //use first match as basis to look into todos/fixmes
        var baseMatch = match[0];
        //find inner matches
        var subMatch = rInnerBlock.exec(baseMatch);
        while (subMatch) {
            if (!subMatch[1] || !subMatch[2]) {
                return;
            }
            index = match.index + subMatch.index;
            comments.push({
                kind: subMatch[1],
                value: subMatch[2],
                line: getLineFromPos(contents, index)
            });
            subMatch = rInnerBlock.exec(baseMatch);
        }
        match = rBlockComment.exec(contents);
    }
    // sort by line number
    comments = comments.sort(function (a, b) {
        return a.line - b.line;
    });

    return comments;
};

@@ -978,38 +978,37 @@
 ) %7B%0A            
+b
 re
-turn
+ak
 ;%0A        %7D%0A    
@@ -1262,38 +1262,37 @@
                 
+b
 re
-turn
+ak
 ;%0A            %7D%0A

fix jsDoc Blocks breaking things