mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-26 23:34:44 +02:00
Fix SQL Backslash Escape preference not taking effect immediately
Refresh SQL lexer(s) on preference change. With new internal message, able to send the SQL property to the each SQL buffer. Fix #16244, close #16258
This commit is contained in:
parent
e38a0f2ec9
commit
88bc3955e9
@ -4144,6 +4144,44 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case NPPM_INTERNAL_SQLBACKSLASHESCAPE:
|
||||
{
|
||||
// Go through all open files, and if there are any SQL files open, make sure the sql.backslash.escapes propery
|
||||
// is updated for each of the SQL buffers' Scintilla wrapper.
|
||||
// This message will only be called on the rare circumstance when the backslash-is-escape-for-sql preference is toggled, so this loop won't be run very often.
|
||||
const bool kbBackSlash = NppParameters::getInstance().getNppGUI()._backSlashIsEscapeCharacterForSql;
|
||||
Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER);
|
||||
Buffer* oldBuf = _invisibleEditView.getCurrentBuffer();
|
||||
|
||||
DocTabView* pTab[2] = { &_mainDocTab, &_subDocTab };
|
||||
ScintillaEditView* pView[2] = { &_mainEditView, &_subEditView };
|
||||
|
||||
Buffer* pBuf = NULL;
|
||||
for (size_t v = 0; v < 2; ++v)
|
||||
{
|
||||
for (size_t i = 0, len = pTab[v]->nbItem(); i < len; ++i)
|
||||
{
|
||||
pBuf = MainFileManager.getBufferByID(pTab[v]->getBufferByIndex(i));
|
||||
|
||||
if (pBuf->getLangType() == L_SQL)
|
||||
{
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, pBuf->getDocument());
|
||||
_invisibleEditView.setCurrentBuffer(pBuf);
|
||||
|
||||
_invisibleEditView.execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("sql.backslash.escapes"), reinterpret_cast<LPARAM>(kbBackSlash ? "1" : "0"));
|
||||
|
||||
if (pBuf == pView[v]->getCurrentBuffer())
|
||||
{
|
||||
pView[v]->defineDocType(L_SQL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
|
||||
_invisibleEditView.setCurrentBuffer(oldBuf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (message == WDN_NOTIFY)
|
||||
|
@ -3900,6 +3900,8 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
case IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL:
|
||||
{
|
||||
nppGUI._backSlashIsEscapeCharacterForSql = isCheckedOrNot(IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL);
|
||||
HWND hwndNPP = GetParent(_hParent);
|
||||
::SendMessage(hwndNPP, NPPM_INTERNAL_SQLBACKSLASHESCAPE, 0, reinterpret_cast<LPARAM>(hwndNPP));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -747,6 +747,7 @@
|
||||
#define NPPM_INTERNAL_CHECKDOCSTATUS (NOTEPADPLUS_USER_INTERNAL + 106)
|
||||
#define NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS (NOTEPADPLUS_USER_INTERNAL + 107)
|
||||
#define NPPM_INTERNAL_RELOADFUNCTIONLIST (NOTEPADPLUS_USER_INTERNAL + 108)
|
||||
#define NPPM_INTERNAL_SQLBACKSLASHESCAPE (NOTEPADPLUS_USER_INTERNAL + 109)
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user