Closed Bug 812618 Opened 12 years ago Closed 11 years ago

Autocomplete at cursor location

Categories

(DevTools :: Console, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 25

People

(Reporter: msucan, Assigned: msucan)

References

Details

Attachments

(1 file, 1 obsolete file)

STR:

1. Open the Web Console.
2. Type "inspect()" without quotes.
3. Press Left once and type "document.". Try Tab.

By now I would expect I get completion suggestions for document. If I press Delete once, I do.

Proposed fix: simply take into consideration for completion what is up to the cursor location. That way we can get more helpful completion when we write more complicated code.
Attached patch wip (obsolete) — Splinter Review
The point of this work is to allow non-linear writing of code. Most often I do not write code linearly. Sometimes I jump a line back (during multiline input editing), or I jump at the start of the line to add a call, a variable, etc.

I am also of the habit of typing opening and closing parenthesis then move back one char to type the arguments: eg. I write linearly document.body.appendChild(), then move in (), then type foobarVar, then press enter.

Showing completion suggestions would ease typing in most cases. I also believe that non-linear writing of code is quite often among developers.

Please play with the patch. I would really like this kind of autocomplete. Also compare with chrome.

If you are undecided, maybe we can ask others from the team to also play with the patch.

Suggestions for improvements are welcome. Thanks!
Attachment #765991 - Flags: feedback?(rcampbell)
Comment on attachment 765991 [details] [diff] [review]
wip

Review of attachment 765991 [details] [diff] [review]:
-----------------------------------------------------------------

yeah, this looks reasonable, I think.
Attachment #765991 - Flags: feedback?(rcampbell) → feedback+
Attached patch proposed patchSplinter Review
Thanks for testing and for the f+!

This is the same as the wip, but with added toolkit and browser tests. Offsets were incorrect in the toolkit tests for autocomplete, otherwise these changes do not cause any existing tests to break.

Try push: https://tbpl.mozilla.org/?tree=Try&rev=e487625f28d0
Assignee: nobody → mihai.sucan
Attachment #765991 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #769048 - Flags: review?(rcampbell)
Blocks: 877262
Comment on attachment 769048 [details] [diff] [review]
proposed patch

Review of attachment 769048 [details] [diff] [review]:
-----------------------------------------------------------------

looks good. :)

::: browser/devtools/webconsole/webconsole.js
@@ +4261,5 @@
>        let suffix = currentItem.label.substring(this.lastCompletion.
>                                                 matchProp.length);
> +      let cursor = this.inputNode.selectionStart;
> +      let value = this.inputNode.value;
> +      this.setInputValue(value.substr(0, cursor) + suffix + value.substr(cursor));

kind of amazing we didn't do this before.
Attachment #769048 - Flags: review?(rcampbell) → review+
Thanks for the review!

Landed:
https://hg.mozilla.org/integration/fx-team/rev/a33d8389d454
Whiteboard: [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/a33d8389d454
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 25
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: