2016-12-15 by Vladimir Schneider

Sometimes, When It Comes to Automation, Doing Nothing is Best

When it comes to automation, sometimes it is better for your code to do nothing when user input does not result in any possible course of action, that you envision, instead of attempting to second guess what the user wants and have your code wind up getting in the way. This is a voice of experience, have been guilty of it myself.

A great example of this is in the IntelliJ IDE is the editor search and replace feature. I have not liked the way it worked completely, in any version and its operation has been tweaked in practically every release. When I say completely, I mean that I would feel it is as polished and comfortable as the rest of the IDE. It has potential, but it has not been fully realized.

In the 2016.3 release, it has mostly worked except sometimes it saves the search and replace strings in history and sometimes it does not. I haven’t taken the time to figure out why and probably will have to take a look at the code and submit a patch, like I did to figure out why Copy would not always work or why Paste would sometimes paste not what I copied IDEA-165306.

At this point it is a matter of sanity. It has been giving me Tourette’s on more than one occasion and got me annoyed enough right now to interrupt what I was doing to write this blog, just to vent some steam.

I am using a roll-your-own build from intellij-community sources because I need a new feature for Mia: Missing In Actions plugin. The patch for the feature was accepted and incorporated into the master branch. I love what I am seeing in 2017 in general. Its speed is just amazing, even when compared to the speedy 2016.3 release.

Now the search and replace in this version is a whole different story. My main beef with it, is its attempt to second guess what to do about the current selection in the file and the In Selection option for limiting the replacement scope to selected text.

For some unfathomable reason, whoever is deciding on how this should work, decided that if the search string does not match anything in the selection then the selection should be cleared from the file. The same thing happens if I deselect the In Selection check box. In either case the IDE goes to all that trouble and clears the selection for me.

So let me get this right: to save me a mouse click or a single caret movement key that would clear any selection, the IDE has removed my carefully prepared selection, for about the fifth time in a row, because the search string that I am typing into the “Search” text box does not match anything in the selection, at every keystroke as I type it in.

Great feature. Someone should be drawn and quartered for this decision.

Exactly, who told you that I was finished editing the string or that you can clear the selection?

Now, I have to type in the search string, make sure it is right, then select the text to which I want to apply it and carefully without disturbing the search and replace options, other than to check the In Selection option and hit replace all. The last time I had to be this careful, my 20 year old son was a baby, and I would be trying to remove him from his car seat without waking him up. The other, when I was using WordStar on a first generation IBM clone, with 128k of RAM, which crashed if I looked at it funny or if it ran out of space on a floppy when saving my file.

How about the search/replace implementation never touch my selection, no matter what I type for the search string or what option I turn off. Never, not even when the selection is not used to limit the scope of replacements.

How does that grab you for an improved user experience? If the selection exists then assume I want it there. If it gets in the way and you are really, really sure that it is my mistake, then let me know. I’ll take care of deciding whether I want the selection cleared or choose another corrective action that does not involve clearing my carefully placed selection.

Sometimes, the best course of action for your code is to do nothing and never forget that the user is the boss and your code is the gopher.

In the mean time, I am motivated to finish the Recall Last Selection action for Mia, that I started but never completed. I need a safety net from inadvertent selection destruction, whether from my own fingers or from the IDE’s code.

 



Constructive comments and suggestions are welcome. I can also be reached me at vladimir@vladsch.com