Sublime Forum

Filter out non contiguous character matches

#1

When I attempt to run a script through [Ctrl+Shift+P] I find that the search allows non contiguous (what I was later to learn below from reply from @gbird) to be fuzzy search) character matches.

For example if I type Run: I see in results unwanted matches such as … WordCount: … matching R+u+n+: …In other words the separate characters are matched but not the phrase. Can this be changed in some configuration to avoid unwanted search matches in the search list?

I am leveraging the Run Apps package where I only want to see a list of Apps to run … not fuzzy match noise.

I should add that I am in Linux Ubuntu.

0 Likes

#2

That’s ST’s fuzzy match capability, which is considered by most as a feature, not a bug. It uses fuzzy logic to identify potential matches (at any point in the matched string or phrase) and accommodates for misspellings, abbreviations, etc. The more characters you type, the more precise the match becomes.

AFAIK, it is baked in and cannot be disabled, but smarter folk may know better.

The better the match, the higher they appear in the list, and the algorithm favours sequential contiguous characters. In your instance, any commands containing “run” should bubble to the top.

PS. For menu items to appear in this list, the package must have a .sublime-commands file. If your items aren’t appearing, raise it with the package developer, or bake your own .sublime-commands

1 Like

#3

Follow-up: I’ve just looked at the source files for the Run App plugin:

It does not ship with a .sublime-commands file, but I notice that it attempts to dynamically author ‘Run App.sublime-commands’ in the plugin -
class AddappCommand(sublime_plugin.WindowCommand)

This syntax assumes a Windows environment and uses Windows file paths, so it is unlikely to work elsewhere. The workaround would be to bake and maintain your own.

1 Like

#4

Thanks @gbird for the insights. I will explore hacking the Run App plugin but I’m at the point where I can right click and (a) Copy Filepath to clipboard and then (b) Open Containing Folder and lo in Ubuntu it opens in Krusader (I guess in Windows this might be Total Commander). This takes me into a new theatre where I can apply rich commands via Krusader Useractions. A parallel world to Sublime Text. I regard Sublime Text as my primary editor easy on my eyes but there are just too many dances to remember. For example I can open multiple filetypes in paired apps of preference (I know of Build). If I revert to hacking Run App I can see how to suppress fuzzy matches by creating a different Plugin name. So best of both worlds. I will try to hack for Linux paths. Actually I can get by with one Run App since that will open up an external App with jQuery list of different uses (builds) of the file. For example Python in Geany, others in LibreOffice et al. The mirror image of Build. But outside Subl text.

1 Like

#5

Whatever works for you. You wouldn’t need to rewrite the entire plugin, just add your own .sublime-commands file, which has a fairly simple syntax.

I’ve just deployed the plugin, and it does a good job of guiding you through this process. As it states in the provided README, you need to configure this for first-time use:

Firstly, add applications through: “Tools” -> “Run Apps” -> “Add Application”.

Once you have added your own apps and arguments, they will appear in the command palette the moment you save the file.

The tricky thing is the plugin was clearly authored for Windoze and does not properly escape Unix based file paths, so I had to add some logic to do the transformation:

If you have your own solutions, then you may deem it not worth the effort.

Here is the boilerplate the plugin provides

{
        "caption": "Run: Git",  // Run: <App-name>, shown in command pallete
        "command": "runapp",    // cannot be changed
        "args":{
          // application full path on Win/Linux, or only name on MAC
          "app": "",

          // argument list
          // variables can be use: $DIR$, $FILE$, $PROJ$
          "args": [""],

          // optional: define what should follow the command
          // default is None
          // "dir" - file directory, same as $DIR$
          // "file" - file name, same as $FILE$
          // "proj" - project directory, same as $PROJ$
          "type": "",

          // optional: command line application or not
          // default is false
          "cli": true

          // optional: send in selected text as input or not
          // default is false
          "input": true
        }
    }
1 Like

#6

Thanks. I doggedly continue my quest. One obstacle I had was I intuitively installed Anaconda package … encountering subprocess errors. So I uninstalled that. But I still encounter errors in Console.

Next I I try to run the simplest of external apps. xdotool

But in my experiments I keep seeing errors in Console …
Traceback (most recent call last):
File “/opt/sublime_text/Lib/python33/sublime_plugin.py”, line 1299, in is_visible_
ret = self.is_visible()
TypeError: is_visible() missing 1 required positional argument: ‘index’

Why leap into /opt/ which leads to permissions.?
How to run a bog standard external tool such as the terminal … or xdotool?

If I can get liftoff through RunApp then I reason (not as a bashscript coder) that I can turn xdotool around 180 degrees to drive Subl engine … a circular route. Then … I can make a list of every key binding in the Subl world and drive the UI. Python eating its own tail.

1 Like

#7

I went down a rabbit hole with Run App. I am switching to standard Build options with links to various external apps. Thanks for interest and advice. I am building a pairing link to Sublime. So far so good.

1 Like

#8

If you ever get into ST plugin development, you can always tailor your own integrations and invoke CLI. This way, you can ensure your file paths are accurate and tailor the workflow to your needs.

In this plugin, I end up creating a series of html files from a mixed MD file. I then pass each file to prettier, using subprocess.run

0 Likes

#10

Thanks @gbird and @mdgu

I was referring to the preponderance of cognitive information seen on Sublime Text. The “entropy” if you follow Shannon’s Law. “Keep the bits down”.

I am thinking ahead to where I propose that users of a framework under development use Sublime Text … not just I.

I was not referring to forum searches. I was referring to fuzzy match noise seen in different menus. Run App was just one case in point.

While I have the option of creating a Plugin for each process forseen, that is unworkable for my scenario. If I have a dozen or more subprocesses the last thing I need is to remember custom key-bindings for each evolving subprocess.

I have found this to explore.

It fits my rough idea in my mind of dynamic key bindings where context words map onto key bindings.

In other words reducing the universe of key bindings as more external tools come into orbit. Paired with Subl text.
Study Fitt’s Law in context of Subl Text.
Also here … https://uxmag.com/articles/the-dirtiest-word-in-ux-complexity

I’ll post progress on experiments … but at my slow pace. I see the way forward thanks to inputs.

0 Likes