diff --git a/src/Notepad3.c b/src/Notepad3.c index 717c54e4a..f85f09522 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -6274,9 +6274,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) return true; case STATUS_2ND_DEF: - if (!Style_IsCurLexerStandard()) { - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDM_VIEW_USE2NDDEFAULT, 1), 0); - } + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDM_VIEW_USE2NDDEFAULT, 1), 0); return true; case STATUS_LEXER: @@ -8119,25 +8117,16 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) } // ------------------------------------------------------ - static int s_iUse2ndDefault = -1; - int iUse2ndDefault = Style_IsCurLexerStandard() ? 0 : (Style_GetUse2ndDefault() ? 2 : 1); - - if (s_iUse2ndDefault != iUse2ndDefault) { - switch (iUse2ndDefault) { - case 0: - StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s", g_mxStatusBarPrefix[STATUS_2ND_DEF]); - break; - case 1: - StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sSTD", g_mxStatusBarPrefix[STATUS_2ND_DEF]); - break; - case 2: + static bool s_bUse2ndDefault = -1; + bool const bUse2ndDefault = Style_GetUse2ndDefault(); + if (s_bUse2ndDefault != bUse2ndDefault) + { + if (bUse2ndDefault) StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s2ND", g_mxStatusBarPrefix[STATUS_2ND_DEF]); - break; - default: - StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sXXX", g_mxStatusBarPrefix[STATUS_2ND_DEF]); - break; - } - s_iUse2ndDefault = iUse2ndDefault; + else + StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sSTD", g_mxStatusBarPrefix[STATUS_2ND_DEF]); + + s_bUse2ndDefault = bUse2ndDefault; bIsUpdateNeeded = true; } // ------------------------------------------------------ diff --git a/src/Styles.c b/src/Styles.c index a8bb05948..e10dd18dc 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -3371,11 +3371,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // first set standard lexer's default values if (IsLexerStandard(pLexNew)) { g_pLexCurrent = pLexNew; - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_USE2NDDEFAULT, false); + Style_SetUse2ndDefault(g_pLexCurrent == &lexStandard2nd); // sync } else { g_pLexCurrent = GetCurrentStdLexer(); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_USE2NDDEFAULT, true); } const WCHAR* const wchStandardStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue; @@ -4488,6 +4487,9 @@ void Style_ToggleUse2ndDefault(HWND hwnd) { bool const use2ndDefStyle = Style_GetUse2ndDefault(); Style_SetUse2ndDefault(use2ndDefStyle ? false : true); // swap + if (IsLexerStandard(g_pLexCurrent)) { + g_pLexCurrent = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard; // sync + } Style_SetLexer(hwnd,g_pLexCurrent); }