View Issue Details

IDProjectCategoryView StatusLast Update
0034566LazarusLCLpublic2019-01-03 16:12
ReportersembitAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx64OSWindowsOS Version10
Product Version2.1 (SVN)Product Build59507 
Target VersionFixed in Version 
Summary0034566: Autocompletion in TComboBox for single-letter text does not work.
DescriptionIf the list includes items with a single letter, when you enter the item is not substituted (ItemIndex < 0). I noticed that it appears if the entered letters and a list item in the same register.
Steps To Reproduce1. Run project.
2. Enter one of the list items.
3. Set focus to another component.

For clarity, I am handling the event OnEditingDone.
TagsNo tags attached.
Fixed in Revisionr59651
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • TestComboBox.zip (129,313 bytes)
  • combobox.diff (1,693 bytes)
    Index: lcl/include/customcombobox.inc
    ===================================================================
    --- lcl/include/customcombobox.inc	(revision 59595)
    +++ lcl/include/customcombobox.inc	(working copy)
    @@ -545,6 +545,7 @@
     var
       iSelStart: Integer; // char position
       sCompleteText, sPrefixText, sResultText: string;
    +  Utf8TextLen: Integer;
     begin
       if DroppingDown then
       begin
    @@ -576,7 +577,8 @@
           iSelStart := SelStart;//Capture original cursor position
           //DebugLn(['TCustomComboBox.UTF8KeyPress SelStart=',SelStart,' Text=',Text]);
           //End of line completion
    -      if ((iSelStart < UTF8Length(Text)) and
    +      Utf8TextLen := UTF8Length(Text);
    +      if ((iSelStart < Utf8TextLen) and
              (cbactEndOfLineComplete in FAutoCompleteText)) then
             Exit;
           sPrefixText := UTF8Copy(Text, 1, iSelStart);
    @@ -584,7 +586,7 @@
                                            (cbactSearchCaseSensitive in FAutoCompleteText),
                                            (cbactSearchAscending in FAutoCompleteText), Items);
           //DebugLn(['TCustomComboBox.UTF8KeyPress sCompleteText=',sCompleteText,' Text=',Text]);
    -      if (sCompleteText <> Text) then
    +      if (sCompleteText <> Text) or {Issue 0034566} (Utf8TextLen = 1) then
           begin
             sResultText := sCompleteText;
             if ((cbactEndOfLineComplete in FAutoCompleteText) and
    @@ -593,6 +595,8 @@
               UTF8Delete(sResultText, 1, iSelStart);
               UTF8Insert(sPrefixText, sResultText, 1);
             end;
    +        if Utf8TextLen = 1 then // Issue 0034566
    +          Text := '';
             Text := sResultText;
             SelStart := iSelStart;
             SelLength := UTF8Length(Text);
    
    combobox.diff (1,693 bytes)

Activities

sembit

2018-11-18 07:11

reporter  

TestComboBox.zip (129,313 bytes)

sembit

2018-11-18 07:13

reporter   ~0112031

Sorry, did not clarify that the problem relates to the component TComboBox.

Serge Anvarov

2018-11-18 19:42

reporter  

combobox.diff (1,693 bytes)
Index: lcl/include/customcombobox.inc
===================================================================
--- lcl/include/customcombobox.inc	(revision 59595)
+++ lcl/include/customcombobox.inc	(working copy)
@@ -545,6 +545,7 @@
 var
   iSelStart: Integer; // char position
   sCompleteText, sPrefixText, sResultText: string;
+  Utf8TextLen: Integer;
 begin
   if DroppingDown then
   begin
@@ -576,7 +577,8 @@
       iSelStart := SelStart;//Capture original cursor position
       //DebugLn(['TCustomComboBox.UTF8KeyPress SelStart=',SelStart,' Text=',Text]);
       //End of line completion
-      if ((iSelStart < UTF8Length(Text)) and
+      Utf8TextLen := UTF8Length(Text);
+      if ((iSelStart < Utf8TextLen) and
          (cbactEndOfLineComplete in FAutoCompleteText)) then
         Exit;
       sPrefixText := UTF8Copy(Text, 1, iSelStart);
@@ -584,7 +586,7 @@
                                        (cbactSearchCaseSensitive in FAutoCompleteText),
                                        (cbactSearchAscending in FAutoCompleteText), Items);
       //DebugLn(['TCustomComboBox.UTF8KeyPress sCompleteText=',sCompleteText,' Text=',Text]);
-      if (sCompleteText <> Text) then
+      if (sCompleteText <> Text) or {Issue 0034566} (Utf8TextLen = 1) then
       begin
         sResultText := sCompleteText;
         if ((cbactEndOfLineComplete in FAutoCompleteText) and
@@ -593,6 +595,8 @@
           UTF8Delete(sResultText, 1, iSelStart);
           UTF8Insert(sPrefixText, sResultText, 1);
         end;
+        if Utf8TextLen = 1 then // Issue 0034566
+          Text := '';
         Text := sResultText;
         SelStart := iSelStart;
         SelLength := UTF8Length(Text);
combobox.diff (1,693 bytes)

Serge Anvarov

2018-11-18 19:42

reporter   ~0112052

Add patch

sembit

2018-11-20 17:27

reporter   ~0112084

Thank! I hope the developers will make corrections in the next build.

Juha Manninen

2018-11-25 12:30

developer   ~0112178

Applied with some formatting changes. Thanks.
Usually we don't add the issue IDs into source code. Revisions and their associated issues can be studied using revision control tools.
I guess this is safe to merge into 2.0 branch.

Issue History

Date Modified Username Field Change
2018-11-18 07:11 sembit New Issue
2018-11-18 07:11 sembit File Added: TestComboBox.zip
2018-11-18 07:13 sembit Note Added: 0112031
2018-11-18 11:32 Juha Manninen LazTarget => -
2018-11-18 11:32 Juha Manninen Summary Autocompletion for single-letter text does not work. => Autocompletion in TComboBox for single-letter text does not work.
2018-11-18 19:42 Serge Anvarov File Added: combobox.diff
2018-11-18 19:42 Serge Anvarov Note Added: 0112052
2018-11-20 17:27 sembit Note Added: 0112084
2018-11-25 12:03 Juha Manninen Assigned To => Juha Manninen
2018-11-25 12:03 Juha Manninen Status new => assigned
2018-11-25 12:30 Juha Manninen Fixed in Revision => r59651
2018-11-25 12:30 Juha Manninen Note Added: 0112178
2018-11-25 12:30 Juha Manninen Status assigned => resolved
2018-11-25 12:30 Juha Manninen Resolution open => fixed
2019-01-03 16:12 sembit Status resolved => closed