Skip to content
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

add option to refresh auto-complete list instead of jumping #12783

Closed
mathlete2 opened this issue Jan 9, 2023 · 7 comments
Closed

add option to refresh auto-complete list instead of jumping #12783

mathlete2 opened this issue Jan 9, 2023 · 7 comments

Comments

@mathlete2
Copy link

Description of the Issue

When you have the auto-complete number lowered to 1 or 2 (which is often useful), the list of options can get very long, so the current behaviour of jumping to different portions instead of refreshing/trimming the list can be cumbersome (especially since the list is grouped by category).

Steps to Reproduce the Issue

  1. Add the following strings to a fresh file: abcd, abdc, acbd, acdb, adbc, adcb
  2. Set the Auto-Complete number to 1.
  3. Type 'a' to trigger an auto-complete list.
    autocomplete1
  4. Type 'd'.

Current Behavior

The first 4 items remain, and the highlighted entry jumps to the 5th.

autocomplete2

Requested Behavior

The first 4 items are cleared away.

autocomplete3

Current Workaround

Delete the 'd' and retype.

Debug Information

@ArkadiuszMichalski
Copy link
Contributor

ArkadiuszMichalski commented Jan 9, 2023

I asked same question here #12495, but a separate issue is more advisable. Doing this as an option might be rational.

Another question: would not be better if pressing next case will refresh popup list to show only the matching items? Now when we press one char like a we get list of all words started with a, now when press b this list is the same (still show all words started with a) but select ab word.
The problem is when we have AZ1, AZ2, AZ3... and az word and there are a lot of other words started wit a or A between them. Now when on the list az word was selected we don't see (don't know) that words like AZ1, AZ2, AZ3.... exist (we don't see it). If pressing next case will refresh popup list to show only the matching items then this problem would be reduced (even if a scroll appears, it won't be so long).

@mpheath
Copy link
Contributor

mpheath commented Jan 20, 2023

Current Workaround

Delete the 'd' and retype.

Or type a, view the list and if the list is too large, then press Esc to cancel the list and then type d to get the smaller list.

Basically, the change would be like the behaviour of an automatic Esc press when typing another character which will recall the list.

As a opt-in choice, the feature request seems reasonable.

I have created a prototype to test the feature.

Test Results

autoc6

Events with each typing acos:

  1. Function completion
    • List with all keyword names
  2. Function completion + filter
    • List of keyword names matching the 1st character
  3. Function completion + filter + recall
    • List of keyword names matching the current word
  4. Function and word completion
    • List of keyword and word names matching the 1st character
  5. Function and word completion + recall
    • List of keyword and word names matching the current word

Word completion works with recall too.

The autocomplete might look smooth though it actually opens a new autocomplete list which closes the previous autocomplete list on each key press. So could be annoying to those who type fast and it might slow down the editor as the autocomplete functions are called with each key press to create the new list. Normally, if the autocomplete is active, the update function which calls the autocomplete functions returns early as a new list is not needed.

As with changes comes positives and negatives.

  • The autocomplete list becomes more concise with items after each character is typed for the current word.

  • Normally pressing backspace selects a previous item in the active autocomplete list. The new recall option causes the autocomplete list to close on pressing backspace so you need to type another valid character to see the autocomplete list again. If you do not know what character to press, then you may need to backspace some more and retype a character to get a larger list.

  • The old function autocomplete list is all the keyword names from the xml file. No filtering of items is done so cannot reduce items like the other autocomplete lists.

The Function completion list can get huge. Makes me consider a filter the list items option. So added an option. The filter option allows the list to reduce in size.

The 2 new checkbox options:

  • Filter the list items
  • Recall auto-completion on each input

are saved and loaded from config.xml as autoCFilter="no" autoCRecall="no".

This prototype makes "Function completion + filter" and "Word completion" subsets of "Function and word completion". To handle the options, the separate autocomplete function code has been merged into 1 function to eliminate code duplication. The old functions call the new function so that features like auto complete\insert word still work with the existing code.

@mathlete2
Copy link
Author

@mpheath thanks for addressing this request so quickly!

  • Normally pressing backspace selects a previous item in the active autocomplete list. The new recall option causes the autocomplete list to close on pressing backspace so you need to type another valid character to see the autocomplete list again.

Interesting, I can't reproduce this behaviour - I actually used Backspace to "delete" the character in the workaround. Is this perhaps a behaviour when Tab is selected as an insertion key? I have that option untoggled, and I've always used the up/down arrow keys to iterate through the list.

Either way, I also find it interesting that "words" and "functions" have to be refreshed/recalled/filtered separately. Would it make more sense to group these filtering options together? I'm picturing one Filter Auto-Complete List checkbox that enables the 2 other checkboxes when checked.

@mpheath
Copy link
Contributor

mpheath commented Jan 21, 2023

@mathlete2

@mpheath thanks for addressing this request so quickly!

  • Normally pressing backspace selects a previous item in the active autocomplete list. The new recall option causes the autocomplete list to close on pressing backspace so you need to type another valid character to see the autocomplete list again.

Interesting, I can't reproduce this behaviour - I actually used Backspace to "delete" the character in the workaround. Is this perhaps a behaviour when Tab is selected as an insertion key? I have that option untoggled, and I've always used the up/down arrow keys to iterate through the list.

Language tested with is ActionScript.

Testing on unmodified v8.4.8 portable, I type ac and the autocomplete closes even though after a bit of scrolling acos is in the list. I have a PR to fix this ill autocomplete behaviour. One of the top words in the list is ALT. I can type alt and I can backspace back to the a which then closes the autocomplete. So I will correct my description as not to include the 1st character.

I usually scroll the list and usually type Return to enter the selection. I use Tab in a console to autocomplete. Those are my habits.


Either way, I also find it interesting that "words" and "functions" have to be refreshed/recalled/filtered separately. Would it make more sense to group these filtering options together? I'm picturing one Filter Auto-Complete List checkbox that enables the 2 other checkboxes when checked.

"Words" are searched in the document by the current word so is always filtered. All the autocomplete options are filtered except for "Function completion" which just reads all keywords from the xml file which is stored in a variable named _keyWords as a space separated string. When the function completion is called, it passes _keyWords whole to be shown in the autocomplete.

Changing the current autocomplete options could upset users, so adding some more options gives a choice. If the "Function completion" radio button is checked, then both "Filter the list items" and "Recall auto-completion on each input" are unchecked. That is as far as I wanna go to setting a default. I tried checking and unchecking based on what is checked and it gets complicated and may go against what the user wants. Checking "Function completion", unchecking "Filter the list items" and checking "Recall auto-completion on each input" I consider as a poor setting as recalling an autocomplete that does not filter the list seems unuseful as the list is not going to be reduced in size, though that is my opinion and I should not push my opinion on to others if I can avoid it.

What you picture and what someone else pictures of a good default may not always line up. My decisions are for the good of all users, even if it negates my own personal preferences. If you consider that I made bad judgement, then let me know and I will reconsider.

Thanks for the feedback. It looks like an interesting feature.

@mathlete2
Copy link
Author

@mpheath

Changing the current autocomplete options could upset users, so adding some more options gives a choice.

Agreed, which is why I requested this as an option (though the section names in my original post are a bit misleading about that). The default settings should have filtering/recalling turned off to maintain consistency with previous versions.

recalling an autocomplete that does not filter the list seems unuseful as the list is not going to be reduced in size

Hmm, when I read your first response, I was under the impression that "recalling" and "filtering" were effectively the same thing, but for different portions of the list:

If I understand things correctly, both processes reduce the visible Auto-Complete list when a new character is typed. If so, that's why I suggested grouping the options for "functions" and "words" together in the Preferences window; they do the same sort of thing to the same object, so it's reasonable to position the checkboxes side by side.

This positioning would also ensure that the same terminology is used for the options; I think some users will be confused if we use two different terms to describe the same behaviour, but perhaps I'm misunderstanding the two workflows. Assuming that they are in fact the same, I personally like "filter" more than "refresh" or "recall".

@mpheath
Copy link
Contributor

mpheath commented Jan 25, 2023

@mathlete2

The options "filter" and "recall" are quite different operations. They can work together or separately. Recall code is like if (not recall and autoc is active) then do not show the autocomplete. Filtering reduces the list to matching items which is quite a bit more code to explain.

Your request is for "recall" (or as you described as "refresh"). The autocomplete cannot be refreshed using standard Scintilla functions, as in update the initial list in the same popup window. The next possible action is to recall the autocomplete to show a more filtered list based on the more characters typed. I chose the "recall" word as that is actually what it is does with recalling the autocomplete function to show a new autocomplete popup window. Each character typed will create a new popup window when the "recall" option is checked rather then use the existing autocomplete popup window.

When a is typed, an autocomplete may popup with filtered items that only starts with a. Not starting with b, c... though not the original "function autocompletion" as no filtering is done with it. The option of filtering "Function autocompletion" allows the "recall" option to work with it to reduce the list.

If this layout is applied...

[ ] Enable auto-completion on each input
    ( ) Function autocompletion
    ( ) Word autocompletion
    ( ) Function and Word autocompletion
[ ] Filter the list items
[ ] Recall autocompletion on each input

users might consider that "Filter the list items" applies to all the radio buttons as it is positioned in a global area. It only applies to the 1st radio button of "Function autocompletion". So, "Filter the list items" was moved to be right below "Function autocompletion" to bind with it. The "Filter the list items" checkbox is unchecked and disabled if "Function autocompletion" is not checked. This positioning of a checkbox under a radio button can be seen in the "New Document" section where the "UTF-8" radio button is followed by the "Apply to opened ANSI files" checkbox. This is where I copied the amount of pixels for the checkbox indentation.

This is the current layout:

[ ] Enable auto-completion on each input
    ( ) Function autocompletion
        [ ] Filter the list items
    ( ) Word autocompletion
    ( ) Function and Word autocompletion
[ ] Recall autocompletion on each input

Do you consider that the 1st layout is better than the current layout? If other, please describe like I have so can visually see it.

If the "Filter..." is not added to lessen the options, then "Recall..." would only properly work with "Word completion" and "Function and Word autocompletion" and then that could still lead to some confusion with the users. Recalling an unfiltered "Function autocompletion" would not achieve anything useful as the list would remain the same and as a negative cause extra processing for no gain and can lose the current word selection in the list.

@mathlete2
Copy link
Author

mathlete2 commented Jan 26, 2023

@mpheath thanks for the explanations. I think I see where we are misunderstanding each other.

Even though the actual "filtering" and "recalling" operations are very different from a coding perspective, I was only asking about the checkboxes in the Preferences window; their labels and layout don't have a direct impact on the code. It's good to document connections to the code, but such information is better suited for the user manual.

Labels certainly need to be informative, but they don't need to reflect the underlying code: they just need to describe the effects that the user will see. They also need to be concise, but not so brief that they suppress information. Here's an alternative setup to consider (note that, instead of "Filter", you can use something like "Reduce", "Update", etc.):

[ ] Enable auto-completion on each input
    ( ) Function autocompletion
    ( ) Word autocompletion
    ( ) Function and Word autocompletion
Filter the list items on each input:
    [ ] Functions
    [ ] Words

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants