delete paired synchronization points in other editor pane.
fixes #45
{
return (m_aUndoBuf.size() != 0 && m_aUndoBuf[0].m_dwFlags&UNDO_BEGINGROUP);
}
+
+bool CDiffTextBuffer::
+DeleteText2(CCrystalTextView * pSource, int nStartLine, int nStartChar,
+ int nEndLine, int nEndChar, int nAction, bool bHistory /*=true*/)
+{
+ for (auto syncpnt : m_pOwnerDoc->GetSyncPointList())
+ {
+ const int nLineSyncPoint = syncpnt[m_nThisPane];
+ if (((nStartChar == 0 && nStartLine == nLineSyncPoint) || nStartLine < nLineSyncPoint) &&
+ nLineSyncPoint < nEndLine)
+ m_pOwnerDoc->DeleteSyncPoint(m_nThisPane, nLineSyncPoint, false);
+ }
+ return CGhostTextBuffer::DeleteText2(pSource, nStartLine, nStartChar, nEndLine, nEndChar, nAction, bHistory);
+}
void prepareForRescan();
virtual void OnNotifyLineHasBeenEdited(int nLine);
bool IsInitialized() const;
+ virtual bool DeleteText2 (CCrystalTextView * pSource, int nStartLine,
+ int nStartPos, int nEndLine, int nEndPos,
+ int nAction = CE_ACTION_UNKNOWN, bool bHistory =true);
};
GetTextWithoutEmptys (apparent_ptStartPos.y, apparent_ptStartPos.x, apparent_ptEndPos.y, apparent_ptEndPos.x, text, CRLF_STYLE_AUTOMATIC, false);
if (text.GetLength() == ur.GetTextLength() && memcmp(text, ur.GetText(), text.GetLength() * sizeof(TCHAR)) == 0)
{
- VERIFY (CCrystalTextBuffer::DeleteText (pSource,
+ VERIFY (DeleteText (pSource,
apparent_ptStartPos.y, apparent_ptStartPos.x, apparent_ptEndPos.y, apparent_ptEndPos.x,
0, false, false));
ptCursorPos = apparent_ptStartPos;
else
{
int nEndLine, nEndChar;
- VERIFY(CCrystalTextBuffer::InsertText (pSource,
+ VERIFY(InsertText (pSource,
apparent_ptStartPos.y, apparent_ptStartPos.x, ur.GetText (), ur.GetTextLength (), nEndLine, nEndChar,
0, false));
ptCursorPos = m_ptLastChange;
nEndChar2 = 0;
nEndLine2++;
}
- if (!CGhostTextBuffer::DeleteText2 (pSource, nStartLine2, nStartChar2, nEndLine2, nEndChar2, nAction, bHistory))
+ if (!DeleteText2 (pSource, nStartLine2, nStartChar2, nEndLine2, nEndChar2, nAction, bHistory))
return false;
}
}
}
else
{
- if (!CGhostTextBuffer::DeleteText2 (pSource, nStartLine, nStartChar, nEndLine, nEndChar, nAction, bHistory))
+ if (!DeleteText2 (pSource, nStartLine, nStartChar, nEndLine, nEndChar, nAction, bHistory))
return false;
}
void CMergeDoc::AddSyncPoint()
{
int nLine[3];
- bool bRemovePreviousFromLine = false;
for (int nBuffer = 0; nBuffer < m_nBuffers; ++nBuffer)
{
int tmp = m_pView[nBuffer]->GetCursorPos().y;
nLine[nBuffer] = m_ptBuf[nBuffer]->ComputeApparentLine(m_ptBuf[nBuffer]->ComputeRealLine(tmp));
if (m_ptBuf[nBuffer]->GetLineFlags(nLine[nBuffer]) & LF_INVALID_BREAKPOINT)
- bRemovePreviousFromLine = true;
+ DeleteSyncPoint(nBuffer, nLine[nBuffer], false);
}
for (int nBuffer = 0; nBuffer < m_nBuffers; ++nBuffer)
- m_ptBuf[nBuffer]->SetLineFlag(nLine[nBuffer], LF_INVALID_BREAKPOINT, true, bRemovePreviousFromLine);
+ m_ptBuf[nBuffer]->SetLineFlag(nLine[nBuffer], LF_INVALID_BREAKPOINT, true, false);
m_bHasSyncPoints = true;
}
/**
+ * @brief Delete a synchronization point
+ */
+bool CMergeDoc::DeleteSyncPoint(int pane, int nLine, bool bRescan)
+{
+ const auto syncpoints = GetSyncPointList();
+ for (auto syncpnt : syncpoints)
+ {
+ if (syncpnt[pane] == nLine)
+ {
+ for (int nBuffer = 0; nBuffer < m_nBuffers; ++nBuffer)
+ m_ptBuf[nBuffer]->SetLineFlag(syncpnt[nBuffer], LF_INVALID_BREAKPOINT, false, false);
+ }
+ }
+
+ if (syncpoints.size() == 1)
+ m_bHasSyncPoints = false;
+
+ if (bRescan)
+ FlushAndRescan(true);
+ return true;
+}
+
+/**
* @brief Clear Synchronization points
*/
void CMergeDoc::ClearSyncPoints()
std::vector<std::vector<int> > CMergeDoc::GetSyncPointList()
{
std::vector<std::vector<int> > list;
+ if (!m_bHasSyncPoints)
+ return list;
int idx[3] = {-1, -1, -1};
std::vector<int> points(m_nBuffers);
for (int nBuffer = 0; nBuffer < m_nBuffers; ++nBuffer)
- points[nBuffer] = m_ptBuf[nBuffer]->GetLineCount() - 1;
+ points[nBuffer] = m_ptBuf[nBuffer]->GetLineCount() - 1;
for (int nBuffer = 0; nBuffer < m_nBuffers; ++nBuffer)
{
int nLineCount = m_ptBuf[nBuffer]->GetLineCount();
CChildFrame * GetParentFrame();
void AddSyncPoint();
+ bool DeleteSyncPoint(int pane, int nLine, bool bRescan = true);
void ClearSyncPoints();
bool HasSyncPoints();
std::vector<std::vector<int> > CMergeDoc::GetSyncPointList();