From 7e274bc23a4946ab69538235f64229aa893f02e7 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sun, 11 Feb 2018 16:22:18 +0900 Subject: [PATCH] GhostTextBuffer.cpp: if the last line in selection to be deleted is a ghost line, the EOL of last real line in selection should not be deleted. Otherwise, a line with no EOL will appear. --- Src/GhostTextBuffer.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Src/GhostTextBuffer.cpp b/Src/GhostTextBuffer.cpp index c41cfec08..975ec416e 100644 --- a/Src/GhostTextBuffer.cpp +++ b/Src/GhostTextBuffer.cpp @@ -384,10 +384,36 @@ bool CGhostTextBuffer:: DeleteText2 (CCrystalTextView * pSource, int nStartLine, int nStartChar, int nEndLine, int nEndChar, int nAction, bool bHistory /*=true*/) { - if (!CCrystalTextBuffer::DeleteText2 (pSource, nStartLine, nStartChar, - nEndLine, nEndChar, nAction, bHistory)) + if ((GetLineFlags(nEndLine) & LF_GHOST) == 0) { - return false; + if (!CCrystalTextBuffer::DeleteText2(pSource, nStartLine, nStartChar, + nEndLine, nEndChar, nAction, bHistory)) + { + return false; + } + } + else + { + // if the last line in selection to be deleted is a ghost line, + // the EOL of last real line in selection should not be deleted. + // Otherwise, a line with no EOL will appear. + int nEndLine2 = nEndLine; + int nEndChar2 = nEndChar; + for (; nEndLine2 >= nStartLine; --nEndLine2) + { + nEndChar2 = GetLineLength(nEndLine2); + if ((GetLineFlags(nEndLine2) & LF_GHOST) == 0) + break; + } + if (nStartLine <= nEndLine2) + { + if (!CCrystalTextBuffer::DeleteText2(pSource, nStartLine, nStartChar, + nEndLine2, nEndChar2, nAction, bHistory)) + { + return false; + } + } + InternalDeleteGhostLine(pSource, nEndLine2 + 1, nEndLine - (nEndLine2 + 1) + 1); } if (nStartChar != 0 || nEndChar != 0) -- 2.11.0