Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #41 from microp11/master

Added multiple tab completion
  • Loading branch information...
commit 929395899ce9e6f563b6dbb1f0bc3fd037c8111f 2 parents d5638da + a9e7d0e
Chris Matthieu chrismatthieu authored

Showing 1 changed file with 11 additions and 2 deletions. Show diff stats Hide diff stats

  1. +11 2 public/js/app.js
13 public/js/app.js
@@ -23,6 +23,9 @@ $(document).ready(function(){
23 23 var candidate = ""; //candidate
24 24 var source = []; //array of values to be matched
25 25 var sourcePos = 0; //the search starting position
  26 + //used in multi tab completion
  27 + var patternPos = -1;
  28 + var prePattern = "";
26 29 //-
27 30
28 31 window.counter = 0;
@@ -592,24 +595,30 @@ $(document).ready(function(){
592 595 if (prevKeyWasTab == false) {
593 596 prevKeyWasTab = true;
594 597 pattern = $('#text_input').val();
  598 + patternPos = pattern.lastIndexOf(" ");
  599 + if (patternPos != -1 ) {
  600 + prePattern = pattern.substr(0, patternPos+1);
  601 + pattern = pattern.substr(patternPos+1);
  602 + };
595 603 pattern = new RegExp("^"+pattern, "i");
596 604 sourcePos = 0;
597 605 candidate = incrementalSearch(pattern, source, sourcePos);
598 606 if (candidate.length > 0) {
599 607 //candidate found
600   - $('#text_input').val(candidate);
  608 + $('#text_input').val(prePattern+candidate);
601 609 return;
602 610 }
603 611 } else {
604 612 candidate = incrementalSearch(pattern, source, sourcePos);
605 613 if (candidate.length > 0) {
606 614 //candidate found
607   - $('#text_input').val(candidate);
  615 + $('#text_input').val(prePattern+candidate);
608 616 return;
609 617 }
610 618 }
611 619 } else {
612 620 prevKeyWasTab = false;
  621 + prePattern = "";
613 622 source = nicks; //we do not want the source to change during tabcompletion
614 623 }
615 624 });

0 comments on commit 9293958

Please sign in to comment.
Something went wrong with that request. Please try again.