Skip to content

Commit

Permalink
Force auto-completion case sensitivity only for typed capitals (issue…
Browse files Browse the repository at this point in the history
… 5493)

E.g. "Installtr" should complete to "InstallTrigger", but "iNstalltr"
should not.

http://code.google.com/p/fbug/issues/detail?id=5493
  • Loading branch information
simonlindholm committed May 25, 2012
1 parent 80e5297 commit 0a3dfdc
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions extension/content/firebug/console/autoCompleter.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,30 @@ Firebug.JSAutoCompleter = function(textBox, completionBox, options)
var lowPrefix = prefix.toLowerCase();
for (var i = 0; i < candidates.length; ++i)
{
// Mark a candidate as matching if it matches the prefix case-
// insensitively, and shares its upper-case characters.
var name = candidates[i];
if (Str.hasPrefix(name.toLowerCase(), lowPrefix))
if (!Str.hasPrefix(name.toLowerCase(), lowPrefix))
continue;

var fail = false;
for (var j = 0; j < prefix.length; ++j)
{
var ch = prefix.charAt(j);
if (ch !== ch.toLowerCase() && ch !== name.charAt(j))
{
fail = true;
break;
}
}
if (!fail)
{
ciValid.push(name);
if (Str.hasPrefix(name, prefix))
valid.push(name);
if (Str.hasPrefix(name, prefix))
valid.push(name);
}
}

// If the typed text isn't lower-case, match case-sensitively.
if (lowPrefix !== prefix)
ciValid = valid;

if (ciValid.length > 0)
{
// If possible, default to a candidate matching the case by picking
Expand Down

0 comments on commit 0a3dfdc

Please sign in to comment.