| 331 | } |
| 332 | |
| 333 | std::vector<WordDiff> |
| 334 | CMergeDoc::GetWordDiffArrayInRange(const int begin[3], const int end[3], bool ignoreDiffOptions/*=false*/, int pane1/*=-1*/, int pane2/*=-1*/) |
| 335 | { |
| 336 | DIFFOPTIONS diffOptions = {0}; |
| 337 | m_diffWrapper.GetOptions(&diffOptions); |
| 338 | String str[3]; |
| 339 | std::unique_ptr<int[]> nOffsets[3]; |
| 340 | std::vector<WordDiff> worddiffs; |
| 341 | std::vector<int> panes; |
| 342 | if (pane1 == -1 && pane2 == -1) |
| 343 | panes = (m_nBuffers == 2) ? std::vector<int>{0, 1} : std::vector<int>{ 0, 1, 2 }; |
| 344 | else |
| 345 | panes = std::vector<int>{ pane1, pane2 }; |
| 346 | for (size_t i = 0; i < panes.size(); ++i) |
| 347 | { |
| 348 | int file = panes[i]; |
| 349 | int nLineBegin = begin[file]; |
| 350 | int nLineEnd = end[file]; |
| 351 | if (nLineEnd >= m_ptBuf[file]->GetLineCount()) |
| 352 | return worddiffs; |
| 353 | nOffsets[file].reset(new int[nLineEnd - nLineBegin + 1]); |
| 354 | String strText; |
| 355 | if (nLineBegin <= nLineEnd) |
| 356 | { |
| 357 | if (nLineBegin != nLineEnd || m_ptBuf[file]->GetLineLength(nLineEnd) > 0) |
| 358 | m_ptBuf[file]->GetTextWithoutEmptys(nLineBegin, 0, nLineEnd, m_ptBuf[file]->GetLineLength(nLineEnd), strText); |
| 359 | strText += m_ptBuf[file]->GetLineEol(nLineEnd); |
| 360 | nOffsets[file][0] = 0; |
| 361 | } |
| 362 | str[i] = std::move(strText); |
| 363 | for (int nLine = nLineBegin; nLine < nLineEnd; nLine++) |
| 364 | nOffsets[file][nLine-nLineBegin+1] = nOffsets[file][nLine-nLineBegin] + m_ptBuf[file]->GetFullLineLength(nLine); |
| 365 | } |
| 366 | |
| 367 | // Options that affect comparison |
| 368 | bool casitive = ignoreDiffOptions ? false : !diffOptions.bIgnoreCase; |
| 369 | strdiff::EolCompareMode eolMode = diffOptions.bIgnoreLineBreaks ? strdiff::EOL_AS_SPACE : |
| 370 | diffOptions.bIgnoreEol ? strdiff::EOL_IGNORE : strdiff::EOL_STRICT; |
| 371 | bool eolSensitive = ignoreDiffOptions ? true : !diffOptions.bIgnoreEol; |
| 372 | int xwhite = ignoreDiffOptions ? 0 : diffOptions.nIgnoreWhitespace; |
| 373 | int breakType = GetBreakType(); // whitespace only or include punctuation |
| 374 | bool byteColoring = GetByteColoringOption(); |
| 375 | |
| 376 | // Make the call to stringdiffs, which does all the hard & tedious computations |
| 377 | std::vector<strdiff::wdiff> wdiffs = |
| 378 | strdiff::ComputeWordDiffs(static_cast<int>(panes.size()), str, casitive, eolMode, xwhite, diffOptions.bIgnoreNumbers, breakType, byteColoring); |
| 379 | |
| 380 | std::vector<strdiff::wdiff>::iterator it; |
| 381 | for (it = wdiffs.begin(); it != wdiffs.end(); ++it) |
| 382 | { |
| 383 | WordDiff wd; |
| 384 | for (size_t i = 0; i < panes.size(); ++i) |
| 385 | { |
| 386 | int file = panes[i]; |
| 387 | int nLineBegin = begin[file]; |
| 388 | int nLineEnd = end[file]; |
| 389 | int nLine; |
| 390 | for (nLine = nLineBegin; nLine < nLineEnd; nLine++) |
nothing calls this directly
no test coverage detected