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

TAB-completion inside a string (inside quotes) is different from normal #717

Closed
KronosTheLate opened this issue Nov 26, 2020 · 13 comments · Fixed by #727
Closed

TAB-completion inside a string (inside quotes) is different from normal #717

KronosTheLate opened this issue Nov 26, 2020 · 13 comments · Fixed by #727
Labels

Comments

@KronosTheLate
Copy link

When writing a string, e.g. with the cursor where the star is in md"my_text* ", the autocompletion is different compared to when not in a string. When trying to autocomplete \omega to get the greek symbol, it is autocompleted to \Documents and Settings\\.

This is annoying in general, but especially when defining a unit like Ohm. I then have to close the string macro with an extra ", write \Omega<TAB>, and erase the extra ". It is not a major problem at all, but annoying. Anyone else experiencing this, and does anyone know of a way to fix it?

@fonsp
Copy link
Owner

fonsp commented Nov 26, 2020

Thank you for the report!

This is supposed to be a 'feature' of Julia: autocompleting paths inside strings, but I'm not sure that I agree with this feature. Especially because (in the future) I want to motivate authors to write notebooks that are standalone, i.e. do not depend on local files.

@aviatesk What do you think? Can/Should we disable path autocomplete inside strings?

FYI it's designed for this situation:

my_text = read("em<TAB>

will autocomplete to

my_text = read("emma.txt

@aviatesk
Copy link
Contributor

aviatesk commented Nov 26, 2020

Can/Should we disable path autocomplete inside strings?

you can filter our path completions:

results, loc, found = completions(query, pos, workspace)
if endswith(query, '.')
# we are autocompleting a module, and we want to see its fields alphabetically
sort!(results; by=(r -> completion_text(r)))
else
filter!((0) my_score, results) # too many candiates otherwise
end

with something like

filter!(!Base.Fix2(isa, FuzzyCompletions.PathCompletion), result)

And query parameter there allows further fine tunings like filtering path completions only within string-macro scope, etc:

# suppress path completions only within string-macro scope
x = Meta.parse(query)
if isa(x, Expr) && x.head === :macrocall
     filter!(!Base.Fix2(isa, FuzzyCompletions.PathCompletion), result)
end

Well, I'm not sure if we should disable path completions or not. Even within a notebook context, it's sometimes useful imho e.g. when we want to load local CSV data when using Pluto in a data science context.

@aviatesk
Copy link
Contributor

I then have to close the string macro with an extra ", write \Omega, and erase the extra "

Well, separate from the path completion discussion, FuzzyCompletions somehow doesn't seem to provide latex completions within a string scope. I will dug into this this weekend or so.

@KronosTheLate
Copy link
Author

I then have to close the string macro with an extra ", write \Omega, and erase the extra "

Well, separate from the path completion discussion, FuzzyCompletions somehow doesn't seem to provide latex completions within a string scope. I will dug into this this weekend or so.

Amazing, thanks a lot <3. This package and team are amazing - I have recently swiched to Pluto as my main IDE/place to do programming ^_^

@aviatesk
Copy link
Contributor

aviatesk commented Nov 28, 2020

FuzzyCompletion@0.4.0 will fix this issue.

@fonsp
Copy link
Owner

fonsp commented Nov 28, 2020

Can you make a PR? Is there a breaking change?

@aviatesk
Copy link
Contributor

Nothing breaking, but here is: #727

@fonsp
Copy link
Owner

fonsp commented Nov 28, 2020

Thanks! Next time, you could register it as a patch (0.4.0 -> 0.4.1) instead of a breaking release (0.4.0 -> 0.5.0). This means that Atom and Pluto get the latest FuzzyCompletion features without doing anything :)

@aviatesk
Copy link
Contributor

I hesitated to do patch release and silently fix this issue , but yeah, it certainly doesn't follow the semantic versioning..

@icweaver
Copy link
Contributor

Hi, sorry if this is the wrong place to ask this. Has the file completion for paths already started to be removed? I think I am still able to complete paths if I type a character that is present:

"em<TAB>

completes to:

"emma.txt

but attempting to complete from nothing just inserts the tab:

"<TAB>

completes to:

"    |<-- cursor now here

I totally see your point about trying to nudge people towards writing standalone notebooks, but I personally happen to fall in the data science context brought up by @aviatesk:

Well, I'm not sure if we should disable path completions or not. Even within a notebook context, it's sometimes useful imho e.g. when we want to load local CSV data when using Pluto in a data science context.

and would absolutely love to retain this feature if it's not too late

@fonsp
Copy link
Owner

fonsp commented Jan 26, 2021

@icweaver Does "./<TAB>" still work? Then we'll leave it at that

@icweaver
Copy link
Contributor

Hey Fons, thanks for getting back to me so quickly! Unfortunately not. It seems to just insert a single space instead

@icweaver
Copy link
Contributor

Oh, but doing it without the forward slash does the trick! I'm happy to just stick with that =]

@icweaver icweaver mentioned this issue May 27, 2021
5 tasks
@fonsp fonsp added the autocomplete <TAB> label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants