Sublime Forum

[Solved] Open file from symbol locations in invisble way and get region from content


Hello everybody.
Sorry for my broken english, i try my best.

I rewrote my XPX plugin with python 3.8 and ST4 : perfect !
We continue to write our scripts with our html extended tags and all is going well.
I try now to expand my plugin adding completions from function arguments.

I included one of my syntax scope in the symbol list and i get back all my function names from my project : ok.
I can also open file from goto definition of each function using symbol list : ok.

Now, i would like, when completion attribute run and when i detect that the cursor is on a function tag, to :

  • open in invisible way the file specified by symbol location
  • mywindow.open_file(l.path_encoded_position(),sublime.ENCODED_POSITION | sublime.SEMI_TRANSIENT | sublime.ADD_TO_SELECTION)
  • the file does not open in invisible way
  • then i hope get a region by scope but the fil is in is_loading mode
  • so i try to implement on_load method, i get back the view but without context variable.

My question is in two parts :

  • how to open file in invisible way : i don’t want my user to see the file opened
  • how can i access to the content of the view to set pt or find_… or expand_by_scope as usual ?

Thank’x in advance for your help.
XPX plugin author



Your best option is to create an unlisted output panel and add the file’s content to it. mdpopups does something like that to create the syntax highlighted code blocks.

As reading file content is handled via python, you shouldn’t be faced with any “loading” state.

A starting point might be …

1 Like


Hello deathaxe,

thank’s a lot for your suggestion. It was a good idea.
I finally finished my plugin with :

            mywindow = sublime.active_window()
            if (len(mylocations)>0):
                # En cas de file trouvé, affichage de chacun des files trouvés (normalement un seul).
                for l in mylocations:
                    content = None
                        with, 'r', encoding='utf-8') as file:
                            content =
                    if content:
                        myfunctionview = mywindow.create_output_panel('myfunctionfile', unlisted=True)
                        myfunctionview.settings().set("translate_tabs_to_spaces", False)
                        myfunctionview.settings().set("auto_indent", False)
                        myfunctionview.run_command('insert', {"characters": content})
                        myfunctionpt = myfunctionview.text_point(l.row-1,l.col-1)
                        myfunctionregion = myfunctionview.expand_by_class(myfunctionpt,sublime.CLASS_PUNCTUATION_START | sublime.CLASS_PUNCTUATION_END,"<>")
                        myfunctionattributes = get_list_attributes(myfunctionview,myfunctionregion.begin(),'function',myfunctionregion.end())
                        for a in myfunctionattributes[0]:
                            if a not in tag_attr_dict["function"]:

It is perfect.
Hope this code can help another dev.

A Sublime Text supporter