From 5e28b47ff88e9b8b779923de136452a926e5d6d9 Mon Sep 17 00:00:00 2001 From: mere-human <9664141+mere-human@users.noreply.github.com> Date: Tue, 13 Jul 2021 22:02:23 +0300 Subject: [PATCH] Fix corrupted encoding text on status bar Remove the shortcut text from the menu text that is used in status bar. Fix #10146, close #10148 --- PowerEditor/src/Notepad_plus.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 566ae03a1..4ac039121 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2620,15 +2620,19 @@ void Notepad_plus::setUniModeText() int cmdID = em.getIndexFromEncoding(encoding); if (cmdID == -1) { - //printStr(TEXT("Encoding problem. Encoding is not added in encoding_table?")); + assert(!"Encoding problem. Encoding is not added in encoding_table?"); return; } cmdID += IDM_FORMAT_ENCODE; const int itemSize = 64; - TCHAR uniModeText[itemSize]; + TCHAR uniModeText[itemSize] = {}; ::GetMenuString(_mainMenuHandle, cmdID, uniModeText, itemSize, MF_BYCOMMAND); uniModeTextString = uniModeText; + // Remove the shortcut text from the menu text. + const size_t tabPos = uniModeTextString.find_last_of('\t'); + if (tabPos != generic_string::npos) + uniModeTextString.resize(tabPos); } _statusBar.setText(uniModeTextString.c_str(), STATUSBAR_UNICODE_TYPE); }