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

Scintilla autocomplete #42

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open

Conversation

vinsworldcom
Copy link

This is just a proof of concept showing it works. Please DO NOT merge this yet. There are still some issues with selection of word to determine autocomplete - it is slow and can lead to over-typing the selection if typing fast. But this does show the concept works.

It would also be nice to have a checkbox ([ ] Use Scintilla Autocomplete) in the settings to enable / disable this feature. You'd have a check of that option in the SCN_CHARADDED:

        case SCN_CHARADDED:
            if (b_UseSciAutoC):
                GTags::SciAutoComplete();
        break;

Fix #41

Cheers.

@pnedev
Copy link
Owner

pnedev commented Dec 7, 2023

Thanks @vinsworldcom ,
I'll check that when I find more free time.

Could you please check my example PoC built from this comment: #41 (comment) ?
Thanks again.

@vinsworldcom
Copy link
Author

Your implementation does not exhibit the word highlighting issue that mine does. I like yours - comments further in #41 (comment)

VinsWorldcom added 5 commits December 8, 2023 08:21
This still causes the selection to be visible which means it must be calling
`getSelection()` still somewhere in the call path for `SciAutoComplete()`
Due to the "Blink the auto-complete word" in 'CmdEngine.cpp'.  Create new
instructions for `AUTOCOMPLETE_SCINTILLA` and `AUTOCOMPLETE_SCINTILLA_SYMBOL`
that do not match that `else if` so no character selection ("blinking")
happens.
If not found, we do not want to `ClearSelection()` as that can remove multi-
caret.  We also want the typed word for autocomplete to be at least 1
character so that `Space` doesn't trigger autocomplete for the full database.
If we're just typing in a file, Scintilla autocomplete is triggered and if
there is no local or global database, we don't want to be prompted to
create one just based on Scintilla trying to autocomplete.
@vinsworldcom
Copy link
Author

vinsworldcom commented Dec 8, 2023

This PR has been updated to a relatively stable working beta that:

  • uses integrated Notepad++ / Scintilla autocomplete so does not conflict with multi-caret and actually supports it!
  • triggers on the 1st typed word-character (this should probably be made configurable)
  • has an autocomplete icon
  • does not prompt to create a non-existent database when typing a document in a directory where one does not exist. This is important because database creation should be triggered when one does a menu Autocomplete or any other plugin menu option, but should not prompt when simply typing characters. Think of new document creation in a new directory - there should be no prompt upon first character typed.
  • does not beep when autocomplete window is visible and typing (though that doesn't really apply, it was an issue with the plugin's autocomplete

Finally, there should probably be an option to disable the feature completely - like checkbox in settings, along with the number of characters to trigger on:

[ ] Use Scintilla autocomplete when typing
[___] Number of characters to type before activating

Cheers.

@vinsworldcom vinsworldcom changed the title First attempt at Scintilla autocomplete [DO NOT USE] First attempt at Scintilla autocomplete Dec 8, 2023
@vinsworldcom vinsworldcom changed the title First attempt at Scintilla autocomplete Scintilla autocomplete Dec 8, 2023
@vinsworldcom vinsworldcom changed the title Scintilla autocomplete Scintilla autocomplete [beta version] Dec 8, 2023
pnedev and others added 5 commits December 9, 2023 19:17
Add icon to results dockable panel
Fix GetFilename() to return the filename without first letter cut-off
This is temporary for testing until a better solution can be added to
Settings window.  The settings dialog should provide:
 + [] enable Scintilla autocomplete
 + [] ignore case
 + [__] from the nth character

The character text box should accept 1-9 as valid characters.  Or it
could use a slider like the Notepad++ one, though that may be harder
to implement.

I think autocomplete ignore case should be different than definition
and reference ignore case.  With Def and Ref, I usually want the
exact case match as I see an object in the code, deliberately
click on it and then find the Def or Refs of that "exact" (i.e.,
case-sensitive) object.  With autocomplete, I'm getting assitance
from the "library" of available objects to help me find what I'm
looking for.  For example, is the "number of characters":
 + .length
 + .len
 + .Length
 + .Len
 + .size
 + is it a property, or does it end in `()` as a method, etc..

Autocomplete should provide more of a "fuzzy-find" (i.e., case-
insensitive) match.  Though others may think otherwise so there
should be an option to make is case-sensitive, but that option
should be different for "autocomplete" vs. "Defs and Refs".
Temporary for testing until adding a proper settings dialog switch.
@vinsworldcom
Copy link
Author

I think next to work on here is to add a group box in the settings dialog titled Scintilla Autocomplete.

----Scintilla Autocomplete-----------------------------------
|                                                           |
|  [ ] Enable   [ ] Ignore case  [___] From nth character   |
|                                                           |
-------------------------------------------------------------

I'll try that later this week if I get time. For now, I'm running with this as my Notepad++ daily driver to see if any other unexpected issues arise. Looking good so far.

Cheers.

VinsWorldcom added 6 commits December 10, 2023 17:52
Still no way to add via Settings dialog, but can manually edit the local
database config file.  Have not yet added the read/write of the integer
characters to act on.
Still no way to update in the Settings dialog, but this completes the
variable settings required for Scintilla Autocomplete.
Use a pulldown combobox populated with values from 1-9.
@vinsworldcom
Copy link
Author

I think next to work on here is to add a group box in the settings dialog titled Scintilla Autocomplete.

@pnedev
Done. I think this is relatively stable and ready for a review. I've been using this version in my daily Notepad++ use with no ill effects so far.

Cheers.

@vinsworldcom vinsworldcom changed the title Scintilla autocomplete [beta version] Scintilla autocomplete Dec 13, 2023
@pnedev
Copy link
Owner

pnedev commented Dec 14, 2023

Nice Vince, thank you. 👍
I don't promise to merge it (at least it won't be soon since I what to check it and think it over first and this is not on my priority list) but I appreciate your time and effort (and I like it that you have managed to alter the behavior to you liking)

BR and Happy holidays!

@vinsworldcom
Copy link
Author

I don't promise to merge it (at least it won't be soon since I what to check it and think it over first and this is not on my priority list)

No worries, understood. I'm happy you have a very straightforward build process as I'm able to compile and test my fixes locally. I'm happy to keep running with my altered version now and if you never merge it, I can always pull your changes to get updates, recompile my Scintilla Autocomplete changes locally and run with that.

Thank you for the support, keeping Notepad++ plugins alive and well! Happy holidays to you too!

Cheers.

VinsWorldcom added 24 commits December 14, 2023 11:23
This still causes the selection to be visible which means it must be calling
`getSelection()` still somewhere in the call path for `SciAutoComplete()`
Due to the "Blink the auto-complete word" in 'CmdEngine.cpp'.  Create new
instructions for `AUTOCOMPLETE_SCINTILLA` and `AUTOCOMPLETE_SCINTILLA_SYMBOL`
that do not match that `else if` so no character selection ("blinking")
happens.
If not found, we do not want to `ClearSelection()` as that can remove multi-
caret.  We also want the typed word for autocomplete to be at least 1
character so that `Space` doesn't trigger autocomplete for the full database.
If we're just typing in a file, Scintilla autocomplete is triggered and if
there is no local or global database, we don't want to be prompted to
create one just based on Scintilla trying to autocomplete.
This is temporary for testing until a better solution can be added to
Settings window.  The settings dialog should provide:
 + [] enable Scintilla autocomplete
 + [] ignore case
 + [__] from the nth character

The character text box should accept 1-9 as valid characters.  Or it
could use a slider like the Notepad++ one, though that may be harder
to implement.

I think autocomplete ignore case should be different than definition
and reference ignore case.  With Def and Ref, I usually want the
exact case match as I see an object in the code, deliberately
click on it and then find the Def or Refs of that "exact" (i.e.,
case-sensitive) object.  With autocomplete, I'm getting assitance
from the "library" of available objects to help me find what I'm
looking for.  For example, is the "number of characters":
 + .length
 + .len
 + .Length
 + .Len
 + .size
 + is it a property, or does it end in `()` as a method, etc..

Autocomplete should provide more of a "fuzzy-find" (i.e., case-
insensitive) match.  Though others may think otherwise so there
should be an option to make is case-sensitive, but that option
should be different for "autocomplete" vs. "Defs and Refs".
Temporary for testing until adding a proper settings dialog switch.
Still no way to add via Settings dialog, but can manually edit the local
database config file.  Have not yet added the read/write of the integer
characters to act on.
Still no way to update in the Settings dialog, but this completes the
variable settings required for Scintilla Autocomplete.
Use a pulldown combobox populated with values from 1-9.
The `SCIAUTOCLIST_LONG` is a the long length of the Scintilla auto-complete
string where if the string is shorter, we do not query the database
anymore and just keep reusing the existing string (optimization) until
autocomplete is done (used or cancelled).
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 this pull request may close these issues.

Consider adding native Scintilla Autocomplete
2 participants