Sublime Forum

Is possible to auto complete file names on panels?

#1

This would be useful for creating new files, moving or duplicating. The package:

  1. https://github.com/BoundInCode/AutoFileName

Does very well the job when I am on a Sublime Text view. However when I am on the panel, it does not autocomplete nothing. Neither Sublime Text word completion words there.

0 Likes

#2

Yes, it is possible, the xpath plugin does autocompletion in input panels, so no reason why a package couldn’t autocomplete file names there too

0 Likes

#3

Thanks. I figured it out to hook on_selection_modified_async and show the autocomplete box. This is the code:

  1. https://github.com/evandrocoan/AutoFileName/blob/5f6113d0762fbde56480b21a7748c02b116b8f38/autofilename.py#L181-L187

However it is being triggered on every panel as the find panel, console, etc. How could I differ theses views from each other?

    def on_selection_modified_async(self,view):
        if not view.window():
            return

        view_name = view.name()
        buffer_id = view.buffer_id()
        file_name = view.file_name()

        print( "buffer_id: " + str( buffer_id ) )
        print( "view_name: " + str( view_name ) )
        print( "file_name: " + str( file_name ) )
0 Likes

#4

I implemented it by changing the plugin which opens the file path panel.

To do the file path auto completion on the panels, now it is necessary to import the class:

try:
	from AutoFileName.autofilename import FileNameComplete as NameComplete

	class SampleListener(sublime_plugin.EventListener):
	    def on_post_window_command(self, window, command, args):

	        if command == "hide_panel":
	            NameComplete.isOnFilePathPanel = False

except:
	class NameComplete():
		isOnFilePathPanel = False

And set the attribute NameComplete.isOnFilePathPanel = True, when opening the panel.

1 Like