Comments (27)
Added option 'fuzzy_search'. test it from git.
from cudatext.
From #5511
I looked at the code and realized case_split
is only being used for ACP words, which is a bug, it should also apply to words collected from document.
Also, it should be improved to not require user to write in proper case. Currently, I need to type qS
to get the suggestion querySelector
. Other inputs qs
, QS
and QS
don't suggest the word, but they should because I use case_sens=0
.
Other issue is that qA
doesn't work to suggest querySelectorAll
, only qSA
, so I can't skip typing any upper case (in this case, I shouldn't need to type S
for selector, qA
should be enough).
from cudatext.
mentioning @ildarkhasanshin because he did some fixes, maybe he wants to work here?
from cudatext.
I looked at the code and realized case_split is only being used for ACP words, which is a bug, it should also apply to words collected from document.
Yes, I confirm it. How to change the code to fix it? I forgot the code so pls help.
from cudatext.
Did you turn on these options?
Yes, I said about them in the initial comment you moved to this issue.
from cudatext.
Yes, I confirm it. How to change the code to fix it? I forgot the code so pls help.
option_case_split
is only used in is_text_with_begin
function, which is only called by get_acp_words
function.
https://github.com/CudaText-addons/cuda_complete_from_text/blob/master/__init__.py
The fix is currently out of my range as I don't know Python.
from cudatext.
Try my fixes!
git branch in plugin's repo
https://github.com/CudaText-addons/cuda_complete_from_text/tree/fixes_for_words_match
from cudatext.
Thanks. Now the options are working for non-acp words.
But reminding there are still two issues that I already reported here:
case_sens
is not being followed. Its value being0
,qs
should findquerySelector
.qa
(andqA
) should findquerySelectorAll
. Currently I need to typeqSA
.
from cudatext.
We should make fix here somewhere
if option_case_split or option_underscore_split:
if option_case_split and s[0] == begin[0]:
searchwords = re.findall('.[^A-Z]*', begin)
wordwords = re.findall('.[^A-Z]*', s)
swl = len(searchwords)
wwl = len(wordwords)
if swl <= wwl:
for i in range(swl):
if not wordwords[i].startswith(searchwords[i]):
break
else:
return True
it's not my code, I don't get idea here. yet.
from cudatext.
I read somewhere that startswith
is case sensitive. Don't know if this is related, because I'm asking to follow case_sens
option, so for me it would be case insensitive.
from cudatext.
Problem is different. It is here
searchwords = re.findall('.[^A-Z]*', begin)
wordwords = re.findall('.[^A-Z]*', s)
it is splitting of word (begin
or s
) by upcase-letters. so upcase letters are required in your typing!
from cudatext.
I understand. This should be fixed, The screenshots examples I posted in the other issue confirms every other editor (at least the three ones I tested, VSCode, ST and Kate) supports lower case, so qs
matches querySelector
and qa
matches querySelectorAll
.
from cudatext.
I can make QUICK fix for 'qa' matching 'qqqqSsssAaaa' but my fix will break things on longer typing words: 'qqaa' WONT match qqqqSsssAaaa
.
from cudatext.
I just tested more and all the tree editors do the simple fuzzy search. So, for instance, qcl
also matches querySelectorAll
. This is way easier to implement and would fix the issue. But the "smart fuzzy" I proposed is the best fix.
from cudatext.
OK, so we need simple fuzzy search, and so remove options 'case_split' / 'underscore_split' , but add 'fuzzy' option. maybe ok idea.
from cudatext.
If you think what I proposed is too hard, I suggest adding an option to both Complete_from_text and for LSP: "fuzzy_search". I suggest to enable it by default, because that's how other editors work.
from cudatext.
and so remove options 'case_split' / 'underscore_split'?
from cudatext.
These are a good step to the "smart fuzzy" I proposed, just not perfect yet. I will surely use fuzzy if it's the only fix applied, but I can imagine some users that don't like the full fuzzy and think current case_split/underscore_split is better. So, unless if you think code gets too bloated, I suggest to keep these.
from cudatext.
Just saying, if you don't remember, this issue is the same thing I asked here.
from cudatext.
Good, to do for me: add 'fuzzy_search' opt. Later maybe in LSP too.
from cudatext.
Thanks. Just saying, imo, this is way more important/useful than #5509. Because for command pallete there's no harm in needing to type space. But the difference in needing to type querySelectorA
and qa
, for instance, is huuuge. In this example alone are 12 chars less for each time I type this method.
from cudatext.
Unless if I'm missing something, fuzzy search is very simple, you just add .*
between every char of the word. At least in Javascript, .*
means "0 or more chars of anything".
In fuzzy search, searching for qa
would match any word having q
followed by a
, no matter how many chars are in between.
So you just split every char of the word and join .*
between them to generate the regex.
So qsa
, for instance, becomes q.*s.*a
.
The example in the link, from what I see, is more to calc the relevance of the match to sort the results. I guess Cuda doesn't need that.
from cudatext.
Q: must i use 'case_sens' option inside fuzzy mathcing function?
from cudatext.
Now it's just add the same for LSP.
from cudatext.
Q: must i use 'case_sens' option inside fuzzy mathcing function?
Hmm... supposing you'll keep case_split
, no. I can only think of user using case_sens
for case_split
, not for fuzzy.
from cudatext.
Is it solved now?
from cudatext.
Yes, thanks.
from cudatext.
Related Issues (20)
- Bad parsing of JavaScript comment HOT 18
- `Indent selection` shouldn't add spaces/tab to empty lines HOT 3
- After dbclicking a word, holding and expanding to the left, Shift+arrow runs at wrong direction HOT 6
- Autocomplete shouldn't eat next word when there's no space HOT 15
- lexer 'Todo.txt' cannot be uninstalled from AddonsManager (shown as 'Todo' in uninstall menu)
- Cuda restores old tab scroll position on drop HOT 3
- cuda_complete_from_text and option_min_len HOT 1
- "New file" button is missing with 1.215.5.0 HOT 4
- Autocomplete inserts suggestion before caret left content instead of replacing it HOT 11
- activating of ui-tab in single instance bug (on Windows)
- Clarify download location in docs HOT 1
- [img] reopen HOT 1
- CudaText pollutes $HOME/.config with CudaTextrc files HOT 5
- Cannot assign find_hotkey_replace_dlg to "Ctrl+H" HOT 4
- "Open URL" in context menu shouldn't require selection HOT 4
- Cuda shouldn't scroll tab bar on tab mousedown HOT 8
- Tabs-bar: improvement for drag-drop of tabs HOT 8
- Cuda fails to highlight brackets in JSON file HOT 1
- CSS: Cuda is using different colors for `!important`, but it should be always the same HOT 4
- last update + hotspot plugin… HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cudatext.