SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 364 forks source link

Backslash fuzzy-match conflicts with the capitalisation of the first letter in new lines(#1217) #1444

Closed Jieli12 closed 4 years ago

Jieli12 commented 4 years ago

I want to insert the uppercase letter after . or the beginning of line. I followed the instructions: #1217. It did work.

However, I confronted one problem. When I typed backslash at the beginning of newline, the fuzzy match(auto-completion) did not work, but it works well except the beginning of newline. I think it is due to the regex { "key": "preceding_text", "operator": "regex_contains", "operand": "(?:^|\\.)\\s*$" },

the "^" restricts the fuzzy-match when one types the backslash at the start of newline.

Please contact me if anyone has an idea to solve this conflict.

Many thanks

Jieli12 commented 4 years ago

I tried to replace the "^" with "\\r", "\\n" and "\\r|\\n". Unfortunatly, it still does not work. I use MacOs 15 Cantalina, the sublime version is 3.2.2, build 3211, and the packages: latextool, latexyz, latex-cwl.

I also solved the conflict in math environment using { "key": "selector", "operator": "not_equal", "operand": "meta.environment.math, string.other.math", "match_all": true },

I also found that typing backslash at the beginning of a newline wouldn't show the fuzzy-match panel automatically, however when I press 'control+space', it forces the panel appear.

What I exactly wanted is: when typing one letter at the beginning of a newline, the letter was capitalised automatically. and when typing the backslash at the beginning of this newline, the fuzzy-match panel should pop-up automatically without using 'control+space'.

Would you please give me some suggestions?

Best wishes

r-stein commented 4 years ago

I think the easiest workaround is to just call the auto_complete function inside insert_uppercase:

import sublime_plugin

class InsertUppercaseCommand(sublime_plugin.TextCommand):
    def run(self, edit, character=""):
        self.view.run_command("insert", {"characters": character.upper()})
        if character == "\\":
            self.view.window().run_command("auto_complete")
Jieli12 commented 4 years ago

Dear Richard,

You are brilliant. Thank you very much! It works perfectly.

Best regards

Jie