Skip to content

Commit

Permalink
[BUG_FIXED] Fix wrong result returned by NPPM_GETLANGUAGENAME.
Browse files Browse the repository at this point in the history
- Notepad-plus svn trunk @ 777
  • Loading branch information
donho committed Jun 18, 2011
1 parent e15fed5 commit 2286eef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,13 +1542,13 @@ void Notepad_plus::checkLangsMenu(int id) const
::CheckMenuRadioItem(_mainMenuHandle, IDM_LANG_C, IDM_LANG_USER_LIMIT, id, MF_BYCOMMAND);
}

generic_string Notepad_plus::getLangDesc(LangType langType, bool shortDesc)
generic_string Notepad_plus::getLangDesc(LangType langType, bool getName)
{

if ((langType >= L_EXTERNAL) && (langType < NppParameters::getInstance()->L_END))
{
ExternalLangContainer & elc = NppParameters::getInstance()->getELCFromIndex(langType - L_EXTERNAL);
if (shortDesc)
if (getName)
return generic_string(elc._name);
else
return generic_string(elc._desc);
Expand All @@ -1557,7 +1557,11 @@ generic_string Notepad_plus::getLangDesc(LangType langType, bool shortDesc)
if (langType > L_EXTERNAL)
langType = L_TEXT;

generic_string str2Show = ScintillaEditView::langNames[langType].longName;
generic_string str2Show;
if (getName)
str2Show = ScintillaEditView::langNames[langType].shortName;
else
str2Show = ScintillaEditView::langNames[langType].longName;

if (langType == L_USER)
{
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/Notepad_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ friend class Notepad_plus_Window;
void enableConvertMenuItems(formatType f) const;
void checkUnicodeMenuItems() const;

generic_string getLangDesc(LangType langType, bool shortDesc = false);
generic_string getLangDesc(LangType langType, bool getName = false);

void setLangStatus(LangType langType){
_statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE);
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/NppBigSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,15 +1772,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa

case NPPM_GETLANGUAGENAME:
{
generic_string langName = getLangDesc((LangType)wParam, false);
generic_string langName = getLangDesc((LangType)wParam, true);
if (lParam)
lstrcpy((LPTSTR)lParam, langName.c_str());
return langName.length();
}

case NPPM_GETLANGUAGEDESC:
{
generic_string langDesc = getLangDesc((LangType)wParam, true);
generic_string langDesc = getLangDesc((LangType)wParam, false);
if (lParam)
lstrcpy((LPTSTR)lParam, langDesc.c_str());
return langDesc.length();
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/NppIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ int Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg, int langType)
const TCHAR *filters = stringFilters.c_str();
if (filters[0])
{
fDlg.setExtsFilter(getLangDesc(lid, true).c_str(), filters);
fDlg.setExtsFilter(getLangDesc(lid, false).c_str(), filters);

//
// Get index of lang type to find
Expand Down

0 comments on commit 2286eef

Please sign in to comment.