[PATCH 1/2] comctl32/edit: Move the call to EDIT_EM_SetSel outside the block

Gabriel Ivăncescu gabrielopcode at gmail.com
Thu Aug 23 05:48:44 CDT 2018


On Thu, Aug 23, 2018 at 12:03 AM, Nikolay Sivov <nsivov at codeweavers.com> wrote:
> On 08/22/2018 11:50 PM, Gabriel Ivăncescu wrote:
>
>> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
>> ---
>>
>> It's called in every block anyway including the else block.
>>
>>   dlls/comctl32/edit.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c
>> index 10ff5fb..c0904cb 100644
>> --- a/dlls/comctl32/edit.c
>> +++ b/dlls/comctl32/edit.c
>> @@ -3308,19 +3308,17 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT
>> key)
>>                                 else
>>                                         EDIT_WM_Clear(es);
>>                         } else {
>> +                               EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
>>                                 if (shift) {
>>                                         /* delete character left of caret
>> */
>> -                                       EDIT_EM_SetSel(es, (UINT)-1, 0,
>> FALSE);
>>                                         EDIT_MoveBackward(es, TRUE);
>>                                         EDIT_WM_Clear(es);
>>                                 } else if (control) {
>>                                         /* delete to end of line */
>> -                                       EDIT_EM_SetSel(es, (UINT)-1, 0,
>> FALSE);
>>                                         EDIT_MoveEnd(es, TRUE, FALSE);
>>                                         EDIT_WM_Clear(es);
>>                                 } else {
>>                                         /* delete character right of caret
>> */
>> -                                       EDIT_EM_SetSel(es, (UINT)-1, 0,
>> FALSE);
>>                                         EDIT_MoveForward(es, TRUE);
>>                                         EDIT_WM_Clear(es);
>>                                 }
>
>
> It probably makes sense to move EDIT_WM_Clear() too in the same patch. Also
> I think it's better to use ~0u if we're making the change.
>
>

Yes you are right, I have no idea how I missed that...

Also, I will replace the (UINT)-1 with ~0, it should be better than
~0u since it's guaranteed to be all 1s (at least on two's complement)
due to sign extension if the underlying type is larger than int, and
conversion from signed to unsigned is done implicitly by the language
anyway. I know that the type is UINT, so this doesn't make a
difference now... but anyway.



More information about the wine-devel mailing list