Nikolay Sivov : comctl32/listview: Fix find using partial string logic.

Alexandre Julliard julliard at winehq.org
Mon Nov 23 08:49:53 CST 2009


Module: wine
Branch: master
Commit: b7b7b7113ed74092b5b30cb0e3eb296757299b8c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b7b7b7113ed74092b5b30cb0e3eb296757299b8c

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Sat Nov 21 22:19:54 2009 +0300

comctl32/listview: Fix find using partial string logic.

---

 dlls/comctl32/listview.c       |    7 ++++---
 dlls/comctl32/tests/listview.c |   39 +++++++++++++++++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 24b90bc..448590a 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -5949,12 +5949,13 @@ again:
             else
                 continue;
         }
-	
+
         if (lvItem.mask & LVIF_TEXT)
 	{
             if (lpFindInfo->flags & LVFI_PARTIAL)
             {
-            	if (strstrW(lvItem.pszText, lpFindInfo->psz) == NULL) continue;
+		WCHAR *p = strstrW(lvItem.pszText, lpFindInfo->psz);
+		if (!p || p != lvItem.pszText) continue;
             }
             else
             {
@@ -5963,7 +5964,7 @@ again:
 	}
 
         if (!bNearest) return nItem;
-	
+
 	/* This is very inefficient. To do a good job here,
 	 * we need a sorted array of (x,y) item positions */
 	LISTVIEW_GetItemOrigin(infoPtr, nItem, &Position);
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 7bf2b03..55e7d96 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -4023,7 +4023,7 @@ static void test_LVS_EX_TRANSPARENTBKGND(void)
     DestroyWindow(hwnd);
 }
 
-static void test_ApproximateViewRect(void)
+static void test_approximate_viewrect(void)
 {
     HWND hwnd;
     DWORD ret;
@@ -4097,6 +4097,40 @@ static void test_ApproximateViewRect(void)
     DestroyWindow(hwnd);
 }
 
+static void test_finditem(void)
+{
+    LVFINDINFOA fi;
+    static char f[5];
+    HWND hwnd;
+    DWORD r;
+
+    hwnd = create_listview_control(0);
+    insert_item(hwnd, 0);
+
+    memset(&fi, 0, sizeof(fi));
+
+    /* full string search, inserted text was "foo" */
+    strcpy(f, "foo");
+    fi.flags = LVFI_STRING;
+    fi.psz = f;
+    r = SendMessage(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
+    expect(0, r);
+    /* partial string search, inserted text was "foo" */
+    strcpy(f, "fo");
+    fi.flags = LVFI_STRING | LVFI_PARTIAL;
+    fi.psz = f;
+    r = SendMessage(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
+    expect(0, r);
+    /* partial string search, part after start char */
+    strcpy(f, "oo");
+    fi.flags = LVFI_STRING | LVFI_PARTIAL;
+    fi.psz = f;
+    r = SendMessage(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
+    expect(-1, r);
+
+    DestroyWindow(hwnd);
+}
+
 START_TEST(listview)
 {
     HMODULE hComctl32;
@@ -4154,7 +4188,8 @@ START_TEST(listview)
     test_indentation();
     test_getitemspacing();
     test_getcolumnwidth();
-    test_ApproximateViewRect();
+    test_approximate_viewrect();
+    test_finditem();
 
     if (!load_v6_module(&ctx_cookie, &hCtx))
     {




More information about the wine-cvs mailing list