Closed Bug 603371 Opened 14 years ago Closed 14 years ago

Web Console is too aggressive about autocomplete

Categories

(DevTools :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 587095

People

(Reporter: ianbicking, Assigned: jwalker)

References

Details

I've been using the Web Console, doing things like:

  e = document.getElementById('foo')
  e

That second time I expect to see the element, but the Web Console does autocomplete on that and instead (at least in Bugzilla) completes to "editAsComment", and I see a function definition.  There's no tab completion on this, in order to actually get the value I want I must hit "e<backspace>" to get rid of the completion.

There seems to be two general issues:

* It's not choosing its completion well.  I'm not sure how it sorts results, but maybe it's backwards (oldest instead of newest?), or meaningless (some textual sort, maybe on a list of the attributes of some fixed set of objects)?  Maybe it could be newest or shortest or most recently used.

* Hitting Enter isn't good for autocompletion as it's also how you enter an expression to evaluate
Assignee: nobody → jwalker
Blocks: devtools4b8
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Some comments from what I know:

> e = document.getElementById('foo')
> e

The only way we could know the type of e, is to some sort of an eval, which I
think is dangerous. In the getelementbyid case since it's read-only there's no
danger, but many cases could be destructive when the user isn't expecting
destruction.

I've puzzled about what to do with this case since there are other ways in
which we get things wrong:

  for (var window in { a:1, b:2 }) {
    window.

Clearly the completions here will be incorrect, and I don't think there is
anything we can do short of solving the halting problem.

I think we've chosen a solution that is OK for the majority of cases, and while
it could be confusing in some cases, people will generally understand why.

You raise some other issues:

> That second time I expect to see the element, but the Web Console does
> autocomplete on that and instead (at least in Bugzilla) completes to
> "editAsComment", and I see a function definition.  There's no tab completion
> on this, in order to actually get the value I want I must hit "e<backspace>"
> to get rid of the completion.

I think that this issue is largely laid out (and fixed) in bug 601183. In short
we're now using a second textarea to display completion data rather than the
selection.

> * It's not choosing its completion well.  I'm not sure how it sorts
> results, but maybe it's backwards (oldest instead of newest?), or
> meaningless (some textual sort, maybe on a list of the attributes of some
> fixed set of objects)? 
> Maybe it could be newest or shortest or most recently used.

The sorting is alphabetical, which I agree isn't necessarily any more correct
than random, (although it might be more predictable) Are you thinking that
properties added to an object later on are more likely to be what the user
wanted, and that we could (in practice if not in theory) get at this from
iteration order?

I've also considered that the *longest* might be a better match. Consider:

  var f = { a:1, addEventListener:function(){...} };

  f.a|

Using alpha sorting, "a" comes up, which is no more likely to be correct that
addEventListener, but clearly not as helpful. The point is that the best
suggestion might not be the most likely, but the one that saves the most
typing. Or at least the best is perhaps some complex combination of the 2.

In short we're currently punting on the issue right now. But if you have a
brilliant and simple sorting system, we'd love to hear it.

> * Hitting Enter isn't good for autocompletion as it's also how you enter an
> expression to evaluate

Agreed. That's also fixed by bug 601183.
To clarify the original example, that would be two statements, so by the time the second statement is entered "e" actually exists.  Which doesn't really change anything, it seems like the resolution applies to my problem.
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.