fix outline bug in edit mode

Avoid taking the # in code block as a header by mistake.

Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
Le Tan 2016-11-11 22:08:03 +08:00
parent 201d14116f
commit d77b333343

View File

@ -180,7 +180,8 @@ void VEdit::generateEditOutline()
QRegExp headerReg("(#{1,6})\\s*(\\S.*)"); // Need to trim the spaces QRegExp headerReg("(#{1,6})\\s*(\\S.*)"); // Need to trim the spaces
for (QTextBlock block = doc->begin(); block != doc->end(); block = block.next()) { for (QTextBlock block = doc->begin(); block != doc->end(); block = block.next()) {
Q_ASSERT(block.lineCount() == 1); Q_ASSERT(block.lineCount() == 1);
if (headerReg.exactMatch(block.text())) { if ((block.userState() == HighlightBlockState::BlockNormal) &&
headerReg.exactMatch(block.text())) {
VHeader header(headerReg.cap(1).length(), VHeader header(headerReg.cap(1).length(),
headerReg.cap(2).trimmed(), "", block.firstLineNumber()); headerReg.cap(2).trimmed(), "", block.firstLineNumber());
headers.append(header); headers.append(header);