Improve the sql.backslash.escapes propagation

(no longer has to activate every buffer, unlike the first implementation for the PR)
This commit is contained in:
PeterCJ 2025-03-10 14:14:04 -07:00
parent 69af89d910
commit 551ac72fb9

View File

@ -4158,24 +4158,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
static_cast<int>(::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<int>(::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<WPARAM>(view_idx), static_cast<LPARAM>(buf_idx));
int langType = -1;
LRESULT retval = ::SendMessage(hwndNPP, NPPM_GETCURRENTLANGTYPE, 0, reinterpret_cast<LPARAM>(&langType));
if (retval && langType == L_SQL) {
WPARAM bufferID = ::SendMessage(hwndNPP, NPPM_GETBUFFERIDFROMPOS, static_cast<WPARAM>(buf_idx), static_cast<LPARAM>(view_idx));
int langType = static_cast<int>(::SendMessage(hwndNPP, NPPM_GETBUFFERLANGTYPE, bufferID, 0));
if (langType == L_SQL) {
::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast<WPARAM>(view_idx), static_cast<LPARAM>(buf_idx));
thisScintView->execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("sql.backslash.escapes"), reinterpret_cast<LPARAM>(kbBackSlash ? "1" : "0"));
::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast<WPARAM>(currentView), static_cast<LPARAM>(currentDoc[currentView]));
}
}
// since the buffer loop activated different buffers, return to orignally-active buffer
::SendMessage(hwndNPP, NPPM_ACTIVATEDOC, static_cast<WPARAM>(currentView), static_cast<LPARAM>(currentDoc[currentView]));
}
return TRUE;
}