code: function() {
          var line = cleanText(self.history.textAfter(self.line).slice(self.offset));
          var match = (self.caseFold ? line.toLowerCase() : line).indexOf(string);
          if (match > -1)
            return {from: {node: self.line, offset: self.offset + match},
                    to: {node: self.line, offset: self.offset + match + string.length}};
        }
docs: For one-line strings, searching can be done simply by calling indexOf on the current line.