ashthespy / Atom-LaTeX

The only LaTeX package you need for typesetting with Atom.
https://atom.io/packages/atom-latex
MIT License
22 stars 9 forks source link

Autocomplete reference duplicates label #186

Closed dpo closed 5 years ago

dpo commented 5 years ago

For a little while now I've been observing the following autocomplete behavior. I set my labels in the form eq:my-equation for equations, fig:my-figure for figures, etc.

If I type \eqref{, the autocomplete dropdown shows up, I then type eq (without typing a colon), select a label, hit tab, and I get the correct completion.

However, if I type eq: with a colon and select the label I'm interested in (say eq:my-equation), the completion ends up being \eqref{eq:eq:my-equation} instead of just \eqref{eq:my-equation}.

The moment I type :, the autocomplete pulldown visibly shifts to the right, so it seems like something is happening.

Has anyone else observed this? I only have official autocomplete packages installed and no other autocomplete package related to LaTeX.

Thanks!

atom-latex

dpo commented 5 years ago

Bump. Can anyone reproduce this? I opened a Discourse discussion here, which may contain leads to resolve the problem: https://discuss.atom.io/t/autocomplete-reference-duplicates-label-in-latex-documents/62015

Thanks!

ashthespy commented 5 years ago

@dpo I typed out a response back then but apparently dind't hit comment!

I too have the same issue, but after a (not through) investigation pinned the blame on the upstream Atom's own autocomplete-plus package that we use via the provider API. At the time, I skimmed through the autocomplete-plus issues but didn't find anything striking. I will investigate more, and maybe open up an issue in their repo for guidance.

EDIT: I might have found the issue, give me a few hours to get home and fix it :-)

dpo commented 5 years ago

Great news! Thanks!

ashthespy commented 5 years ago

@dpo It does look like an issue with the nonWordCharacters - but will take some more investigation. Will keep you posted.

ashthespy commented 5 years ago

@dpo Try adding : to the Extra Word Characters setting found under autocomplte-plus package settings. That should fix the issue. I wonder if there a more specific way to solve this.

dpo commented 5 years ago

I have tried that already. It doesn't fix the problem for me. Does it fix it for you?

ashthespy commented 5 years ago

Yep - just to confirm - this is not the editor Non Word Characters. Before: autocomplete_ After: autocomplete

EDIT: looking at the gif, looks like this might break the suggestions - I see a few repeats. I will look into in in more detail soon!

dpo commented 5 years ago

Well, unfortunately, that doesn't work for me. I'm not sure what's happening.

dpo commented 5 years ago

I tried your suggestion on two computers (both macOS), and it didn't fix the issue on either. Perhaps things are different on other platforms?!

ashthespy commented 5 years ago

The issue is being tracked in upstream in autocomplete-plus as the from our side we are(99.99%) setting the right parameters for replacement.

I tried your suggestion on two computers (both macOS), and it didn't fix the issue on either. Perhaps things are different on other platforms?!

The workaround I mentioned also requires bumping up the provider version to 4.0.0 in package.json - but I would rather wait for something from the autocomplete-plus guys before pushing the workaround as a fix.

dpo commented 5 years ago

Great, thank you!

dpo commented 5 years ago

Just wondering if there are any news here.

ashthespy commented 5 years ago

Not really https://github.com/atom/autocomplete-plus/issues/1020#issuecomment-471125376

BambOoxX commented 5 years ago

Not sure if this is the same issue, but when typing \includegraphics{some/path} I get the same (wrong) behavior. This is quite annoying...

ashthespy commented 5 years ago

It's quite irritating I agree, but don't have the time to debug upstream issues at the moment. So unless there is some action over at atom/autocomplete-plus#1020 not much I can do for now.

ashthespy commented 5 years ago

@dpo @BambOoxX Managed to fix this with the following patch

diff --git a/package.json b/package.json
index 7f0fbec..fe7b306 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
   "providedServices": {
     "autocomplete.provider": {
       "versions": {
-        "2.0.0": "provide"
+        "4.0.0": "provide"
       }
     }
   },
diff --git a/settings/language-latex.cson b/settings/language-latex.cson
index 9645e98..3c4ebf2 100644
--- a/settings/language-latex.cson
+++ b/settings/language-latex.cson
@@ -4,6 +4,8 @@
     'tabLength': 2
     'softWrap': true
     'commentStart': '% '
+  'autocomplete-plus':
+    'extraWordCharacters': ':_/'
   'bracket-matcher':
     'autocompleteCharacters': [
       '$$',

Should find its way into the next release - don't want to push two on the same day ;-)

dpo commented 5 years ago

Oh please, please please ;-). That bug bothers me every single day.

dpo commented 5 years ago

I have labels with multiple : and - characters, e.g., alg:my-algorithm. If I type alg:my and hit TAB, the name is now completed correctly. Thank you!

However, if I type alg:my- and hit TAB, the same problem as before occurs; the entire label is pasted after what I typed. I tried adding - to the list of extra non-word characters in settings/language-latex.cson but no success... Any ideas?

ashthespy commented 5 years ago

@dpo Sorry my notifications are whack these days, but for your case try:

# This works
'extraWordCharacters': '-:_/'
# This doesn't ¯\_(ツ)_/¯
'extraWordCharacters': ':_/-'
dpo commented 5 years ago

Finally!!! Thank you!!!

dpo commented 5 years ago

Ps: perhaps there should be a setting for extraWordCharacters?!