From 551ac72fb94246c06290024c36d36b04fb854dc8 Mon Sep 17 00:00:00 2001 From: PeterCJ Date: Mon, 10 Mar 2025 14:14:04 -0700 Subject: [PATCH] Improve the sql.backslash.escapes propagation (no longer has to activate every buffer, unlike the first implementation for the PR) --- PowerEditor/src/NppBigSwitch.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index efbb17253..ed94fcb01 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -4158,24 +4158,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa static_cast(::SendMessage(hwndNPP, NPPM_GETCURRENTDOCINDEX, 0, 1)) }; - // loop through all buffers in each view, get it's language type, and if it is SQL then update its property + // loop through all buffers in each view, get it's language type, and if it is SQL then update the sql.backslash.escapes property for (int view_idx = 0; view_idx < 2; view_idx++) { ScintillaEditView* thisScintView = currentView == view_idx ? _pEditView : _pNonEditView; int nOpenInThisView = static_cast(::SendMessage(hwndNPP, NPPM_GETNBOPENFILES, 0, view_idx + 1)); // this command uses 0 for both, 1 for main, 2 for second for (int buf_idx = 0; buf_idx < nOpenInThisView; buf_idx++) { - ::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast(view_idx), static_cast(buf_idx)); - int langType = -1; - LRESULT retval = ::SendMessage(hwndNPP, NPPM_GETCURRENTLANGTYPE, 0, reinterpret_cast(&langType)); - if (retval && langType == L_SQL) { + WPARAM bufferID = ::SendMessage(hwndNPP, NPPM_GETBUFFERIDFROMPOS, static_cast(buf_idx), static_cast(view_idx)); + int langType = static_cast(::SendMessage(hwndNPP, NPPM_GETBUFFERLANGTYPE, bufferID, 0)); + if (langType == L_SQL) { + ::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast(view_idx), static_cast(buf_idx)); thisScintView->execute(SCI_SETPROPERTY, reinterpret_cast("sql.backslash.escapes"), reinterpret_cast(kbBackSlash ? "1" : "0")); + ::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast(currentView), static_cast(currentDoc[currentView])); } } - - // since the buffer loop activated different buffers, return to orignally-active buffer - ::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast(currentView), static_cast(currentDoc[currentView])); } - return TRUE; }