jlelong / vscode-latex-basics

LaTeX grammars for Visual Studio Code
MIT License
19 stars 10 forks source link

Use wordPattern inspired from the markdown extension #19

Closed jlelong closed 2 years ago

jlelong commented 2 years ago

Related to microsoft/vscode/issues/144913

@Yarakashi-Kikohshi Could you test this new wordPattern?

Close #17

Yarakashi-Kikohshi commented 2 years ago

@jlelong

I'm a user of VS Code and LaTeX Workshop, but I don't know how to test this pull request works. I'm sorry, this is my lack of knowledge.

If you can show me a detailed way to test that it works, I can test that it works.


On the other hands, although this is an unusual method, I have made edits wordPattern in ~\.vscode\extensions\james-yu.latex-workshop-8.23.0\syntax\latex-language-configuration.json in currently installed LaTeX Woskrhop (8.23). In this case, the problem discussed in https://github.com/microsoft/vscode/issues/144913 don't seem to arise.

jlelong commented 2 years ago

You can actually directly edit ~\.vscode\extensions\james-yu.latex-workshop-8.23.0\syntax\latex-language-configuration.json as you did but note that the wordPattern used by LaTeX-Workshop and vscode basic LaTeX support are slightly different (in LW, we include ..., __ and ** because they are snippet prefixes)

In you want to directly test this PR,

@Yarakashi-Kikohshi I am pretty convinced that this PR solves https://github.com/microsoft/vscode/issues/144913, but I really want to make sure it does not introduce other problems.

Yarakashi-Kikohshi commented 2 years ago

@jlelong, Thanks for the very clear explanation. I was able to test it successfully. I hope this test will be useful.

I tested with all extensions disabled.

Summary

Test procedure

Note that these tests only consider Ascii characters and Japanese at best. There are numerous languages in the world, but only two have been tested.

  1. I have drawn up lists of "the patterns in which suggestions are displayed" and "the characters immediately preceding the pattern in which suggestions are displayed".
  2. I have tested all the patterns from each of the two lists.
  3. Visually check Suggestion display and Occurrence highlighting.

list of the patterns in which suggestions are displayed

Snippets
```json { "Teacher in Japanese": { "prefix": "せんせい", "body": "先生", "description": "先生: Teacher in Japanese" }, "Teacher in English": { "prefix": "teacher", "body": "TEACHER", "description": "Teacher in English" }, "Tabstop": { "prefix": "tabstop", "body": "test{$1}{$2}$0", "description": "test: Tabstops in snippet" } } ```

list of the characters immediately preceding the pattern in which suggestions are displayed

Complete file for testing
```latex % Snippet of `teacher' % Snippet of `せんせい' %% IntelliSense starting with `\' %% IntelliSense starting with `@' %% IntelliSense starting with `**' %% IntelliSense starting with `__' %% IntelliSense starting with `...' \documentclass{article} \begin{document} {} [] () {} () [] 「」 ' ` " # $ $ % & = ~ ^ | < > ; : , . ! ? / \\ @ + * _ 、 。 , . ! ? # $ % & = ~ ^ | < > ; : ・ ¥ @ _ + * alphabet 123 alphabet 123 ひらがな カタカナ 漢字   \end{document} ```

About LaTeX Workshop's IntelliSense

I have also accidentally tested LaTeX Workshop's IntelliSense, so I am writing alongside it.

LaTeX Workshop's intelligences are as follows:

The results of the suggestion display were in addition to the results above:

jlelong commented 2 years ago

Thank you so much for your very thorough tests and detailed report.

** and __ and ... did not show suggestion in every situation.

This is because we do not use the same wordPattern in vscode-latex-basics and in LaTeX-Workshop. In LaTeX-Workshop, we add (**|__|\.\.\.) to the wordPattern to make sure these snippets show up automatically, see https://github.com/jlelong/LaTeX-Workshop/commit/e0ba934c9e0457861ce463c43a13deb9a34e4577. If you want to test it inside LaTeX-Workshop, the simplest approach is to directly edit ~\.vscode\extensions\james-yu.latex-workshop-8.23.0\syntax\latex-language-configuration.json because running the git version of LaTeX-Workshop requires npm (see https://github.com/James-Yu/LaTeX-Workshop/blob/master/CONTRIBUTING.md)