ATM, in the source view (eg in the preamble), the last character before a comment (ie percent sign) is greyed out as if part of the comment. The attached patch should fix this behavior.
Bernhard Reiter
Index: src/frontends/qt4/LaTeXHighlighter.cpp =================================================================== --- src/frontends/qt4/LaTeXHighlighter.cpp (Revision 21664) +++ src/frontends/qt4/LaTeXHighlighter.cpp (Arbeitskopie) @@ -85,13 +85,20 @@ setFormat(index, length, keywordFormat); index = text.indexOf(exprKeyword, index + length); } - // comment - static const QRegExp exprComment("(^|[^\\\\])%.*$"); - index = text.indexOf(exprComment); + // %comment + // If QRegExp supported look-behind, we'd get the right + // index by using an analogue construct as above with + // QRegExp exprComment"(?<!\\\\)%.*$"); + // and wouldn't need the following special magic. + QRegExp exprComment("(?:^|[^\\\\])(%).*$"); + text.indexOf(exprComment); + index = exprComment.pos(1); while (index >= 0) { - int const length = exprComment.matchedLength(); + int const length = exprComment.matchedLength() + - (index - exprComment.pos(0)); setFormat(index, length, commentFormat); - index = text.indexOf(exprComment, index + length); + text.indexOf(exprComment, index + length); + index = exprComment.pos(1); } }