Sublime Forum

Plugin ability to change hints for tabs

#1

github.com/henrikpersson/rsub/issues/46

The problem is when we open remote file it is saved locally for opening.
Sublime text must allow ability for plugin to set string which will be shown for hint or tab name.

openfile( ,tab_display_name, tab_hint_string ] )

tab_display_name parametr you may name as: 'remote_file_name".

0 Likes

#2

Something like this should work for you. Sublime doesn’t allow you to set a custom name in the open_file method, but it does return a view and there is a set_name method on the view object that will do what you want. Calls to view methods are not available while the view is loading so I have created a new method called set_name which will check if the file is loading. If it is it will wait 10 milliseconds and check again. Do NOT set the number in the set_timeout call to 0, this will is most cases lock up Sublime!

class OpenFileNameCommand(sublime_plugin.WindowCommand):
	def run(self):
		file_path = {your_file}
		view = self.window.open_file(file_path)
		self.set_name(view, "This is a custom file!")

	def set_name(self, view, name):
		if (not view.is_loading()):
			view.set_name(name)
		else:
			sublime.set_timeout(lambda: self.set_name(view, name), 10)

I Hope this helps!

P.S. this was tested on ST3 only, there may be a different solution in ST2.

0 Likes

#3

ST3 3083

When I trying to do that sublime offers me to save that view with that new name. BUG?

0 Likes

#4

seems bug: github.com/SublimeTextIssues/Core/issues/993

0 Likes