How to make left pane track file in current editor pane in K11 on linux

I would like the left pane (showing the file hierarchy of the current project) shift to whichever file tab I have selected in the editor pane. I’m running Komodo 11 on Centos7.

An example use case is that I’ve searched and found a particular method definition and opened the corresponding file by double-clicking on a search hit.

I’d like the left pane to open the corresponding file in its hierarchy, so that I can easily see where I am (and what files are nearby) while I’m editing a particular file.

I’m currently doing Ruby – I think this is common to any language that assumes one class per file (so that there are many small files organized into a large hierarchy).

In the screenshot below, I’d like the left pane to highlight “addressable.rb” (the file open in the current tab of the editor pane) rather than “commentable.rb” (the last file I double-clicked on in the left pane).

Hey @csid_tom,

You can right click on the file and select Show in Places. There is no way currently to have this happen automatically though I think it would be possible with a macro.

EDIT: I’m implying that if you’re interested in trying a macro we’ll be happy to help. Otherwise you would file an enhancement request. Let me know what you think.

  • Carey

I’ll try these.

I’m not sure I’m ready to fill out yet another form, I already have so many to do for my employer. :slight_smile:

@csid_tom to help you out a bit, I made a small userscript that does just that.
You can create the userscript in you’re toolbox:

Then add the following code:

(function() {

	window.removeEventListener('current_view_changed', showCurrentTabInplaces);

	function showCurrentTabInplaces() {
		var currentView = ko.views.manager.currentView;
		// check if we have a current view
		if (currentView === null) {
			return false;
		}

		var koDoc = currentView.koDoc;
		// check if koDoc is there
		if (koDoc === null) {
			return false;
		}

		var path = koDoc.displayPath;
		var parsedPath = path.replace(/\\/g, '/'); // Fix windows urls for matching
		var placesManager = ko.places.manager;

		// check if current view is available in places
		if (checkIfCurrentTabExist(parsedPath)) {
			// check if places manager is loaded
			if (placesManager) {
				// if in current project proceed
				if (checkIfInCurrentProject(path)) {
					// Focus current view in places
					placesManager.showCurrentEditorTab();
				}
			}
		}
	}

	/**
	 * Small function to check if current file in project
	 * @param {type} uri
	 * @returns {Boolean}
	 */
	function checkIfInCurrentProject(uri) {
		var projectManager = ko.projects.manager;
		if (projectManager) {
			var currProject = projectManager.currentProject;
			if (currProject !== null) {
				var liveDir = currProject.liveDirectory;

				if (uri.indexOf(liveDir) !== -1) {
					return  true;
				} 
			}
		}
		return false;
	}

	/**
	 * Small function to check if uri is avialible in the places mananger ( copied from the places manager without the alert )
	 * @param {type} uri
	 * @returns {Boolean}
	 */
	function checkIfCurrentTabExist(uri) {
		var fileObj = Components.classes["@activestate.com/koFileEx;1"].
				createInstance(Components.interfaces.koIFileEx);
		var osPathSvc = (Components.classes["@activestate.com/koOsPath;1"]
				.getService(Components.interfaces.koIOsPath));
		fileObj.URI = uri;
		if (fileObj.isLocal) {
			if (!osPathSvc.exists(fileObj.displayPath)) {
				return false;
			}
		}
		return true;
	}

	window.addEventListener('current_view_changed', showCurrentTabInplaces);

}).apply();

Then in the tab triggers:

You select on start up save the userscript and reboot komodo.
Now when you have a project open, it will focus the current view in the places widget.
Files that are outside you’re project, are ignored.

1 Like