Skip to content

Commit

Permalink
Restore prev value if tab size is 0 on focus lost
Browse files Browse the repository at this point in the history
  • Loading branch information
ozone10 committed Feb 19, 2023
1 parent cddf6ce commit d774dc6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,43 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
break;
}
}
break;
}

case EN_KILLFOCUS:
{
switch (LOWORD(wParam))
{
case IDC_EDIT_TABSIZEVAL:
{
const auto tabSize = ::GetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, nullptr, FALSE);

if (tabSize < 1)
{
const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE);
const size_t index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
auto prevSize = nppGUI._tabSize;
if (!useDefaultTab && index > 0)
{
Lang* lang = nppParam.getLangFromIndex(index - 1);
if (lang != nullptr && lang->_tabSize > 0)
{
prevSize = lang->_tabSize;
}
}

::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, prevSize, FALSE);
return TRUE;
}
return FALSE;
}

default:
{
break;
}
}
break;
}

default:
Expand Down

0 comments on commit d774dc6

Please sign in to comment.