MCPcopy Create free account
hub / github.com/WinMerge/winmerge / CopyMultiplePartialList

Method CopyMultiplePartialList

Src/MergeDocDiffCopy.cpp:157–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void CMergeDoc::CopyMultiplePartialList(int srcPane, int dstPane, int activePane,
158 int firstDiff, int lastDiff, const CEPoint& ptStart, const CEPoint& ptEnd, bool bCharacter)
159{
160 lastDiff = (std::min)(m_diffList.GetSize() - 1, lastDiff);
161 firstDiff = (std::max)(0, firstDiff);
162 if (firstDiff > lastDiff)
163 return;
164 const int firstLineDiff = ptStart.y;
165 const int lastLineDiff = ptEnd.x == 0 ? ptEnd.y - 1 : ptEnd.y;
166
167 RescanSuppress suppressRescan(*this);
168
169 bool bGroupWithPrevious = false;
170 if (firstLineDiff <= 0 && lastLineDiff == -1)
171 {
172 if (!ListCopy(srcPane, dstPane, -1, bGroupWithPrevious, true))
173 return; // sync failure
174 }
175 else
176 {
177 if (!bCharacter)
178 {
179 if (!LineListCopy(srcPane, dstPane, lastDiff,
180 (firstDiff == lastDiff) ? firstLineDiff : 0, lastLineDiff, bGroupWithPrevious, true))
181 return; // sync failure
182 }
183 else
184 {
185 if (!CharacterListCopy(srcPane, dstPane, activePane, lastDiff,
186 ptStart, ptEnd, bGroupWithPrevious, true))
187 return; // sync failure
188 }
189 }
190
191 SetEditedAfterRescan(dstPane);
192
193 int nGroup = GetActiveMergeView()->m_nThisGroup;
194 CMergeEditView* pViewDst = m_pView[nGroup][dstPane];
195 CEPoint currentPosDst{ 0, pViewDst->GetCursorPos().y };
196
197 CEPoint pt(0, 0);
198 pViewDst->SetCursorPos(pt);
199 pViewDst->SetNewSelection(pt, pt, false);
200 pViewDst->SetNewAnchor(pt);
201
202 // copy from bottom up is more efficient
203 for (int i = lastDiff - 1; i >= firstDiff; --i)
204 {
205 if (m_diffList.IsDiffSignificant(i))
206 {
207 SetCurrentDiff(i);
208 const DIFFRANGE* pdi = m_diffList.DiffRangeAt(i);
209 if (currentPosDst.y > pdi->dend)
210 {
211 if (pdi->blank[dstPane] >= 0)
212 currentPosDst.y -= pdi->dend - pdi->blank[dstPane] + 1;
213 else if (pdi->blank[srcPane] >= 0)
214 currentPosDst.y -= pdi->dend - pdi->blank[srcPane] + 1;

Callers 1

OnX2YMethod · 0.80

Calls 5

IsDiffSignificantMethod · 0.80
DiffRangeAtMethod · 0.80
CEPointClass · 0.70
GetSizeMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected