Bug 325234 - [find/replace] Cursor jumps to the beginning of 'Find' field
Summary: [find/replace] Cursor jumps to the beginning of 'Find' field
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Rajesh CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 325405
Blocks:
  Show dependency tree
 
Reported: 2010-09-14 07:50 EDT by Deepak Azad CLA
Modified: 2010-09-16 01:51 EDT (History)
3 users (show)

See Also:
markus.kell.r: review+


Attachments
Fix (1003 bytes, patch)
2010-09-15 02:57 EDT, Rajesh CLA
no flags Details | Diff
Fix (1.27 KB, patch)
2010-09-15 11:35 EDT, Rajesh CLA
daniel_megert: review-
Details | Diff
Fix (815 bytes, patch)
2010-09-15 12:48 EDT, Dani Megert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2010-09-14 07:50:39 EDT
I20100914-0100

Steps
- Open a text editor
- Ctrl+F
- Type something in the 'Find' field
- Press 'Enter'
=> Cursor moves to the beginning of the 'Find' field - not good.

Seen this bug on GTK and Win XP

Note: it is not reproducible always, but is easy enough to reproduce.
Comment 1 Dani Megert CLA 2010-09-14 10:12:17 EDT
Rajesh, we should fix this for M2.
Comment 2 Rajesh CLA 2010-09-15 02:57:21 EDT
Created attachment 178901 [details]
Fix

Issue: Type/Paste a string in the Findfield that is not in its History list. Then press enter - the cursor will move to the beginning of the field.

Cause: The History for the combo field (findfield) was being updated by clearing both the existing history + the string in the field and then setting both. This causes the cursor location in the field to be lost/reset.

Solution: The history is now being updated without clearing/setting the contents of the field.
Comment 3 Rajesh CLA 2010-09-15 03:03:24 EDT
(In reply to comment #2)
> Created an attachment (id=178901) [details]
> Fix
> 
> Issue: Type/Paste a string in the Findfield that is not in its History list.
> Then press enter - the cursor will move to the beginning of the field.
Also, if the string is in the history list but not the most recent(top) entry, pressing enter will move the cursor to the beginning.
Comment 4 Markus Keller CLA 2010-09-15 07:02:30 EDT
The fix is not good. Steps:
- type 111, Enter
- clear field, type 222, Enter
- open Find combo and select 111
- click Find
=> Find field is empty
Comment 5 Rajesh CLA 2010-09-15 11:35:13 EDT
Created attachment 178954 [details]
Fix

The Combo history code calls methods in org.eclipse.swt.widgets.Combo such as remove, setItem, etc which make the following OS call to delete items in the Combo list. -
int result = (int)/*64*/OS.SendMessage (handle, OS.CB_DELETESTRING, start, 0);

This call causes the Findfield to be cleared if the string in the field matches the string being deleted by the above call.
Comment 6 Dani Megert CLA 2010-09-15 12:47:53 EDT
Comment on attachment 178954 [details]
Fix

Patch is too complicated (at least definitely for M2).
Comment 7 Dani Megert CLA 2010-09-15 12:48:28 EDT
Created attachment 178965 [details]
Fix
Comment 8 Dani Megert CLA 2010-09-15 12:50:24 EDT
Rajesh, please test my fix and review it.
Comment 9 Rajesh CLA 2010-09-15 13:17:20 EDT
(In reply to comment #8)
> Rajesh, please test my fix and review it.

Good simplification :) Tested, works fine.
Comment 10 Markus Keller CLA 2010-09-15 15:56:00 EDT
Dani has released his fix.

Only minor problem is that the caret always ends up at the end of the selection even if it was at the beginning before. But there's no API in SWT to set the selection from right to left (SWT should already have a bug for that).

Rajesh, please post the # of the SWT bug for the unexpected behavior from comment 5 here and make this bug depend on the SWT bug. We should remove the hacks in FindReplaceDialog#updateHistory(Combo, List) once that bug is fixed.
Comment 11 Dani Megert CLA 2010-09-16 01:46:44 EDT
>But there's no API in SWT to set the
>selection from right to left (SWT should already have a bug for that).
Filed bug 325405.
Comment 12 Dani Megert CLA 2010-09-16 01:51:42 EDT
Verified in I20100915-2024.