-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Column Editor OK button should be disabled if Text-to-Insert is empty #13444
Column Editor OK button should be disabled if Text-to-Insert is empty #13444
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make code simpler and straight forward.
if (toText) | ||
{ | ||
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam; | ||
if (!colEditParam._insertedTextContent.empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be more straight forward to get text from the text field control.
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam; | ||
if (!colEditParam._insertedTextContent.empty()) | ||
{ | ||
::SetDlgItemText(_hSelf, IDC_COL_TEXT_EDIT, colEditParam._insertedTextContent.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this line?
Or there's another bug?
} | ||
else | ||
{ | ||
::EnableWindow(::GetDlgItem(_hSelf, IDOK), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EnableWindow(::GetDlgItem(_hSelf, IDOK), xxx);
should be call only once at the end - xxx is the result of IDC_COL_TEXT_EDIT (empty or not).
I simplified the change based on your comments. |
if (toText) | ||
{ | ||
const int stringSize = 1024; | ||
TCHAR str[stringSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const int stringSize = 1024;
can be replaced with constexpr int stringSize = 1024;
Add initializer to be sure e.g. TCHAR str[stringSize]{};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ozone10
good remark.
Could you add the "best practice" in contribution coding style:
https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/CONTRIBUTING.md#coding-style
Or create a issue for the "best practice" so I can add them in the guideline?
Life is complicated already, let's make our code simpler. |
Fix #13315