| 131 | }; |
| 132 | |
| 133 | int BfDiff::AddEditCommand(int cmdInsertPos, const EditCommand& editCommand) |
| 134 | { |
| 135 | //Log("AddEditCommand Pos:%d Cmd:%d A:%d B:%d Count:%d\n", cmdInsertPos, editCommand.mCmd, editCommand.mAIdx, editCommand.mBIdx, editCommand.mCount); |
| 136 | |
| 137 | if (cmdInsertPos == -1) |
| 138 | cmdInsertPos = (int)mEditCommands.size(); |
| 139 | if ((cmdInsertPos > 0) && (cmdInsertPos - 1 < mEditCommands.size()) && (editCommand.mCount == 1)) |
| 140 | { |
| 141 | EditCommand& prevEditCommand = mEditCommands[cmdInsertPos - 1]; |
| 142 | if ((editCommand.mCmd == EditCommandKind_InsertLine) || (editCommand.mCmd == EditCommandKind_InsertChar)) |
| 143 | { |
| 144 | if ((prevEditCommand.mCmd == editCommand.mCmd) && |
| 145 | (prevEditCommand.mCount < 0x7FFF) && |
| 146 | (editCommand.mAIdx == prevEditCommand.mAIdx) && |
| 147 | (editCommand.mBIdx == prevEditCommand.mBIdx + prevEditCommand.mCount)) |
| 148 | { |
| 149 | prevEditCommand.mCount += editCommand.mCount; |
| 150 | return cmdInsertPos; |
| 151 | } |
| 152 | } |
| 153 | else if ((editCommand.mCmd == EditCommandKind_DeleteLine) || (editCommand.mCmd == EditCommandKind_DeleteChar)) |
| 154 | { |
| 155 | if ((prevEditCommand.mCmd == editCommand.mCmd) && |
| 156 | (prevEditCommand.mCount < 0x7FFF) && |
| 157 | (editCommand.mAIdx == prevEditCommand.mAIdx + prevEditCommand.mCount)) |
| 158 | { |
| 159 | prevEditCommand.mCount += editCommand.mCount; |
| 160 | return cmdInsertPos; |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | mEditCommands.Insert(cmdInsertPos, editCommand); |
| 166 | return cmdInsertPos + 1; |
| 167 | } |
| 168 | |
| 169 | class DiffEngineBase |
| 170 | { |
no test coverage detected