BetterSmartTypingOfQuotes

Currently, the "smart typing" will insert a second quote based on how many quotes precede it on the line. This produces some unwanted behavior. It should be based on how many quotes are on the line as a whole. Take the following situation:

 $bobage = 'Bob is 25 years old';

Now I want to edit this to replace "25" with a variable reference, to get:

 $bobage = 'Bob is ' . $years . ' years old';

So I select the 25, hit delete and type a single quote and get:

 $bobage = 'Bob is ' years old';

Not what I wanted, so I type a second quote, and now have:

 $bobage = 'Bob is ''' years old';

An extra quote. Which I have to reverse-delete because if I use the normal delete, it removes both of them. Then I find my cursor outside the quotes, and have to step backward. Thus the smart typing has actually substantially complicated matters, rather then simplifying them. This situation arises quite routinely for me. If it based the decision about wether to add a second quote on how many quotes were in the line as a whole, however, it would avoid this problem.

Since this hasn't been fixed yet, another example might be in order of why the current functionality is annoying. Imagine I want to type the Perl string:

print "<a href='index.pl?page=$get{'page'}'>";

This is something I do quite frequently, since I often need variable substitution in the URL string of a link. Now, in typing this, these are the steps I go through:

print ""

Looks good. Smart typing functions properly here.

print "<a href=''"

Two single quotes. Still functioning how I want.

print "<a href='index.pl?page=$get{'}'"

Damn. Only one single-quote, because it bases the smart typing only on the number of quotes preceding it on the line. So I type another one and get:

print "<a href='index.pl?page=$get{'''}'"

Ugh. Same problem as the example before. Since it sees an even number of single quotes preceding it on the line, it uses smart typing this time and inserts two more. Again, I have to reverse-delete and step backwards to get back where I want to be. If I'm prepared for this functionality, it only slows me down slightly, but is still more cumbersome then if smart typing just didn't exist for that portion. If I'm not prepared for it, it can slow me down much more substantially.

The fix for this is very simple. Just count the total number of quotes on the string instead of just the quotes before the cursor. When inserting a quote inside a string, you will nearly always want that quote to be doubled, and currently it fails to do that.

(Note I feel I have the right to be SLIGHTLY more pushy about this small change, now that I've paid for the software. I love the smart typing MOST of the time but this bug drives me batty.)

I've changed the behavior for beta 5.