These are chat archives for ensime/ensime-sublime

10th
Jul 2017
Vishesh Chauhan
@VC1995
Jul 10 2017 07:49
Hello all
I was working on the add import feature and needed advice
I wanted to enable it only there wasn't already an existing import
how should I do that?
For example, if I run add import on a symbol that already had an import, it'll reappear
Did we make some check in the old sublime plugin
I can't locate it
Currently I am doing something very simple
class EnsimeAddImport(EnsimeTextCommand):
    def run(self, edit, target=None):
        env = getEnvironment(self.view.window())
        if env and env.is_connected():
            pos = int(target or self.view.sel()[0].begin())
            if self.view.is_dirty():
                self.view.run_command('save')
            ImportSuggestionsReq(pos,
                                 self.view.file_name(),
                                 self.view.substr(self.view.word(pos))).run_in(env)
The last request shows all the suggestions and one selected is imported. I want to introduce a logic somewhere, that if the import is already present I don't run the request at all
Does anyone know how the ensime-sublime plugin used to do this?
Ghost
@ghost~540393fe163965c9bc2018ce
Jul 10 2017 08:05
I wonder if the server should send patches for add import so we can centralise the logic.
I thought we did that
Vishesh Chauhan
@VC1995
Jul 10 2017 08:11
I think we are because I am using a patch utility to apply it in the response handler for add import
But I don't understand how they work?
I am using the same patch utility that we used earlier (from https://github.com/techtonik/python-patch). Am I doing something wrong there?