From 177869fd0035ab09703e5e9c1801e1d628c5aa56 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Thu, 5 Sep 2019 14:36:37 +0200 Subject: [PATCH] + fix: Ctrl+Shift-C/X and Paste behaviour + chg: Ctrl+Alt+Enter AutoCompletion behaviour --- Versions/build.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/Edit.c | 16 +++++----- src/Edit.h | 2 +- src/Notepad3.c | 30 +++++++++++-------- src/VersionEx.h | 4 +-- .../StyleLexers/styleLexTOML/TOML.toml | 1 + 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index 2c79e46eb..baa8d02fe 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2617 +2618 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 3c0bbbf61..6c1b3521b 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 BETA diff --git a/src/Edit.c b/src/Edit.c index c85378331..080273e70 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -6893,7 +6893,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) return false; } - DocPos const iMinWdChCnt = 2; // min number of typed chars before AutoC + DocPos const iMinWdChCnt = autoInsert ? 0 : 2; // min number of typed chars before AutoC char const* const pchAllowdWordChars = ((Globals.bIsCJKInputCodePage || Globals.bUseLimitedAutoCCharSet) ? AutoCompleteWordCharSet : @@ -6907,11 +6907,10 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) DocPos const iPosBefore = SciCall_PositionBefore(iCurrentPos); DocPos const iWordStartPos = SciCall_WordStartPosition(iPosBefore, true); - if ((iWordStartPos == iPosBefore) || (iCol < iMinWdChCnt) || ((iCurrentPos - iWordStartPos) < iMinWdChCnt)) { + if (((iPosBefore - iWordStartPos) < iMinWdChCnt) || (iCol < iMinWdChCnt) || ((iCurrentPos - iWordStartPos) < iMinWdChCnt)) { EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); return true; } - DocPos iPos = iWordStartPos; bool bWordAllNumbers = true; while ((iPos < iCurrentPos) && bWordAllNumbers && (iPos <= iDocEndPos)) { @@ -6921,12 +6920,11 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) } iPos = SciCall_PositionAfter(iPos); } - if (bWordAllNumbers) { + if (!autoInsert && bWordAllNumbers) { EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); return true; } - char pRoot[_MAX_AUTOC_WORD_LEN]; DocPos const iRootLen = (iCurrentPos - iWordStartPos); StringCchCopyNA(pRoot, COUNTOF(pRoot), SciCall_GetRangePointer(iWordStartPos, iRootLen), (size_t)iRootLen); @@ -6936,7 +6934,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) PWLIST pListHead = NULL; - if (Settings.AutoCompleteWords) + if (Settings.AutoCompleteWords || autoInsert) { struct Sci_TextToFind ft = { { 0, 0 }, 0, { 0, 0 } }; ft.lpstrText = pRoot; @@ -6979,7 +6977,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) if (pwlNewWord) { FreeMem(pwlNewWord); pwlNewWord = NULL; } } // -------------------------------------------------------------------------- - if (Settings.AutoCLexerKeyWords) + if (Settings.AutoCLexerKeyWords || autoInsert) // -------------------------------------------------------------------------- { PKEYWORDLIST const pKeyWordList = Style_GetCurrentLexerPtr()->pKeyWords; @@ -7043,7 +7041,6 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) LL_DELETE(pListHead, pWLItem); FreeMem(pWLItem); } - SciCall_AutoCShow(iRootLen, (pList + 1)); FreeMem(pList); } @@ -8122,8 +8119,9 @@ void EditSetAccelWordNav(HWND hwnd,bool bAccelWordNav) SciCall_SetWhitespaceChars(WhiteSpaceCharsAccelerated); SciCall_SetPunctuationChars(PunctuationCharsAccelerated); } - else + else { SciCall_SetCharsDefault(); + } } diff --git a/src/Edit.h b/src/Edit.h index 892d7d512..ddd12aa25 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -110,7 +110,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos void EditFinalizeStyling(HWND hwnd, DocPos iEndPos); void EditUpdateIndicators(HWND hwnd, DocPos startPos, DocPos endPos, bool bClearOnly); void EditSetAccelWordNav(HWND hwnd,bool); -bool EditAutoCompleteWord(HWND hwnd,bool); +bool EditAutoCompleteWord(HWND hwnd, bool autoInsert); bool EditCheckNewLineInACFillUps(); void EditShowZeroLengthCallTip(HWND hwnd, DocPos iPosition); void EditGetBookmarkList(HWND hwnd,LPWSTR pszBookMarks,int cchLength); diff --git a/src/Notepad3.c b/src/Notepad3.c index cb8f8d5bf..2055a5c18 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -3861,6 +3861,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } break; + case IDM_EDIT_REDO: if (SciCall_CanRedo()) { SciCall_Redo(); @@ -3907,13 +3908,18 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (s_flagPasteBoard) { s_bLastCopyFromMe = true; } - if (!SciCall_IsSelectionEmpty() || - !HandleHotSpotURLClicked(SciCall_GetCurrentPos(), COPY_HYPERLINK)) - { - _BEGIN_UNDO_ACTION_ - SciCall_CopyAllowLine(); - _END_UNDO_ACTION_ + _BEGIN_UNDO_ACTION_ + if (SciCall_IsSelectionEmpty()) { + if (!HandleHotSpotURLClicked(SciCall_GetCurrentPos(), COPY_HYPERLINK)) + { + // VisualStudio behavior + SciCall_CopyAllowLine(); + } } + else { + SciCall_Copy(); + } + _END_UNDO_ACTION_ UpdateToolbar(); } break; @@ -3925,13 +3931,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) s_bLastCopyFromMe = true; } _BEGIN_UNDO_ACTION_ - if (SciCall_IsSelectionEmpty()) { - SciCall_CopyAllowLine(); - } - else { - SciCall_CopyRange(SciCall_PositionFromLine(SciCall_LineFromPosition(SciCall_GetSelectionStart())), - SciCall_GetLineEndPosition(SciCall_LineFromPosition(SciCall_GetSelectionEnd()))); - } + DocPos const iSelLnStart = SciCall_PositionFromLine(SciCall_LineFromPosition(SciCall_GetSelectionStart())); + DocPos const iLineSelLast = SciCall_LineFromPosition(SciCall_GetSelectionEnd()); + // copy incl last line-breaks + DocPos const iSelLnEnd = SciCall_PositionFromLine(iLineSelLast) + SciCall_LineLength(iLineSelLast); + SciCall_CopyRange(iSelLnStart, iSelLnEnd); _END_UNDO_ACTION_ } break; diff --git a/src/VersionEx.h b/src/VersionEx.h index 3e6913711..b4d62f5f3 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -7,8 +7,8 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 19 -#define VERSION_REV 904 -#define VERSION_BUILD 2617 +#define VERSION_REV 905 +#define VERSION_BUILD 2618 #define SCINTILLA_VER 420 #define ONIGURUMA_REGEX_VER 6.9.3 #define UCHARDET_VER 2018.09.27 diff --git a/test/test_files/StyleLexers/styleLexTOML/TOML.toml b/test/test_files/StyleLexers/styleLexTOML/TOML.toml index 2cb9f5733..7fd02c550 100644 --- a/test/test_files/StyleLexers/styleLexTOML/TOML.toml +++ b/test/test_files/StyleLexers/styleLexTOML/TOML.toml @@ -1,4 +1,5 @@ # This is a TOML document. - encoding:UTF-8 +# Notepad3\test\test_files\StyleLexers\styleLexTOML\TOML.toml # https://github.com/toml-lang/toml #