Merge pull request #511 from RaiKoHoff/Dev_0601

Changing behavior of removing duplicate lines (ignore EOL/EOF chars)
This commit is contained in:
Derick Payne 2018-06-12 08:34:45 +02:00 committed by GitHub
commit eac671cf50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -287,6 +287,8 @@ void DisplayCmdLineHelp(HWND hwnd)
mbp.lpfnMsgBoxCallback = NULL;
mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL);
hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId());
MessageBoxIndirect(&mbp);
}

View File

@ -3676,7 +3676,7 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines)
if (iSelEnd <= SciCall_PositionFromLine(iEndLine)) { --iEndLine; }
}
else {
iEndLine = SciCall_GetLineCount() - 1; // last line
iEndLine = Sci_GetLastDocLine();
}
if ((iEndLine - iStartLine) <= 1) { return; }
@ -3697,22 +3697,26 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines)
for (DocLn iCurLine = iStartLine; iCurLine < iEndLine; ++iCurLine)
{
const DocPos iCurLnLen = SciCall_GetLine(iCurLine, pCurrentLine);
SciCall_GetLine(iCurLine, pCurrentLine);
const DocPos iCurLnLen = Sci_GetNetLineLength(iCurLine);
pCurrentLine[iCurLnLen] = '\0';
if (bRemoveEmptyLines || (iCurLnLen > iEmptyLnLen)) {
for (DocLn iCompareLine = iCurLine + 1; iCompareLine < iEndLine; ++iCompareLine)
for (DocLn iCompareLine = iCurLine + 1; iCompareLine <= iEndLine; ++iCompareLine)
{
const DocPos iCmpLnLen = SciCall_GetLine(iCompareLine, NULL);
const DocPos iCmpLnLen = Sci_GetNetLineLength(iCompareLine);
if (bRemoveEmptyLines || (iCmpLnLen > iEmptyLnLen)) {
const DocPos iBegCmpLine = SciCall_PositionFromLine(iCompareLine);
const char* pCompareLine = SciCall_GetRangePointer(iBegCmpLine, iCmpLnLen + 2);
const char* pCompareLine = SciCall_GetRangePointer(iBegCmpLine, iCmpLnLen + 1);
if (iCurLnLen == iCmpLnLen) {
if (StringCchCompareNA(pCurrentLine, iCurLnLen, pCompareLine, iCmpLnLen) == 0) {
SciCall_SetTargetRange(iBegCmpLine, iBegCmpLine + iCmpLnLen);
const DocPos iLenToDel = (iCompareLine != Sci_GetLastDocLine() ? SciCall_GetLine(iCompareLine, NULL) : iCmpLnLen);
SciCall_SetTargetRange(iBegCmpLine, iBegCmpLine + iLenToDel);
SciCall_ReplaceTarget(0, "");
--iCompareLine; // proactive preventing progress to avoid comparison line skip
--iEndLine;

View File

@ -358,7 +358,7 @@ BEGIN
MENUITEM "Auto In&dent Text", IDM_VIEW_AUTOINDENTTEXT
MENUITEM "Auto Close &HTML/XML\tCtrl+Shift+H", IDM_VIEW_AUTOCLOSETAGS
MENUITEM "A&uto Complete Words", IDM_VIEW_AUTOCOMPLETEWORDS
MENUITEM "Accelerated Word Navi&gation", IDM_VIEW_ACCELWORDNAV
MENUITEM "Accelerated Word Navi&gation\tCtrl+Alt+A", IDM_VIEW_ACCELWORDNAV
MENUITEM SEPARATOR
MENUITEM "&Reuse Window", IDM_VIEW_REUSEWINDOW
MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS
@ -456,6 +456,7 @@ BEGIN
"A", IDM_EDIT_SELECTALL, VIRTKEY, CONTROL, NOINVERT
"A", IDM_VIEW_MARKOCCUR_ONOFF, VIRTKEY, ALT, NOINVERT
"A", CMD_RECODEANSI, VIRTKEY, SHIFT, CONTROL, NOINVERT
"A", IDM_VIEW_ACCELWORDNAV, VIRTKEY, CONTROL, ALT, NOINVERT
"B", IDM_EDIT_FINDMATCHINGBRACE, VIRTKEY, CONTROL, NOINVERT
"B", IDM_EDIT_PADWITHSPACES, VIRTKEY, ALT, NOINVERT
"B", IDM_EDIT_SELTOMATCHINGBRACE, VIRTKEY, SHIFT, CONTROL, NOINVERT

View File

@ -390,6 +390,7 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool)
#define Sci_GetEOLLen() ((SciCall_GetEOLMode() == SC_EOL_CRLF) ? 2 : 1)
#define Sci_GetCurrentLine() SciCall_LineFromPosition(SciCall_GetCurrentPos())
#define Sci_GetLastDocLine() (SciCall_GetLineCount() - 1)
// length of line w/o line-end chars (full use SciCall_LineLength()
#define Sci_GetNetLineLength(line) (SciCall_GetLineEndPosition(line) - SciCall_PositionFromLine(line))
@ -397,6 +398,7 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool)
///~#define Sci_GetDocEndPosition() (SciCall_GetTextLength() - 1)
#define Sci_GetDocEndPosition() SciCall_GetTextLength()
//=============================================================================
#endif //_NP3_SCICALL_H_