| 56 | } |
| 57 | |
| 58 | void BaseHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded) |
| 59 | { |
| 60 | rehighlightWorking = false; |
| 61 | QTextBlock block = doc->findBlock(from); |
| 62 | if (!block.isValid()) |
| 63 | return; |
| 64 | |
| 65 | int endPosition; |
| 66 | QTextBlock lastBlock = doc->findBlock(from + charsAdded + (charsRemoved > 0 ? 1 : 0)); |
| 67 | if (lastBlock.isValid()) |
| 68 | endPosition = lastBlock.position() + lastBlock.length(); |
| 69 | else |
| 70 | endPosition = doc->lastBlock().position() + doc->lastBlock().length(); |
| 71 | |
| 72 | bool forceHighlightOfNextBlock = false; |
| 73 | while (block.isValid() && (block.position() < endPosition || forceHighlightOfNextBlock)) { |
| 74 | const int stateBeforeHighlight = block.userState(); |
| 75 | reformatBlock(block, from, charsRemoved, charsAdded); |
| 76 | forceHighlightOfNextBlock = (block.userState() != stateBeforeHighlight); |
| 77 | block = block.next(); |
| 78 | } |
| 79 | |
| 80 | formatChanges.clear(); |
| 81 | } |
| 82 | |
| 83 | void BaseHighlighterPrivate::reformatBlock(const QTextBlock &block, int from, int charsRemoved, int charsAdded) |
| 84 | { |