Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

As you type completer, fix on Firefox #1069

Merged
merged 1 commit into from

3 participants

@Carreau
Owner

As you type completer is (really) broken on firefox. It insert invisible characters

This should fixed the observed bugs and keep the same behavior across browser.

@Carreau Carreau as you type Completer, propagate event by hand
	Should fix completer behaviour on firefox...
40de69f
@takluyver
Owner

Seems to be working here.

I've not used the notebook since we added the as-you-type completer - it's a brilliant tool. Thanks!

@Carreau
Owner

Thanks,
I couldn't have done something like that, or even think of it without all the great work you all have done !
Maybe this 0.12 will finally convince some people I work with to consider other tool than matlab !

@fperez
Owner

Several people have confirmed this fixes it, merging. Thanks for the quick response, @Carreau!

@fperez fperez merged commit e89be0c into ipython:master
@fperez fperez referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2011
  1. @Carreau

    as you type Completer, propagate event by hand

    Carreau authored
    	Should fix completer behaviour on firefox...
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 15 deletions.
  1. +25 −15 IPython/frontend/html/notebook/static/js/codecell.js
View
40 IPython/frontend/html/notebook/static/js/codecell.js
@@ -318,21 +318,23 @@ var IPython = (function (IPython) {
};
// insert the given text and exit the completer
- var insert = function (selected_text) {
+ var insert = function (selected_text, event) {
that.code_mirror.replaceRange(
selected_text,
{line: cur.line, ch: (cur.ch-matched_text.length)},
{line: cur.line, ch: cur.ch}
);
- event.stopPropagation();
- event.preventDefault();
+ if(event != null){
+ event.stopPropagation();
+ event.preventDefault();
+ }
close();
setTimeout(function(){that.code_mirror.focus();}, 50);
};
// insert the curent highlited selection and exit
var pick = function () {
- insert(select.val()[0]);
+ insert(select.val()[0],null);
};
@@ -340,14 +342,22 @@ var IPython = (function (IPython) {
// matches, update the pseuso typing field. autopick insert match if
// only one left, in no matches (anymore) dismiss itself by pasting
// what the user have typed until then
- var complete_with = function(matches,typed_text,autopick)
+ var complete_with = function(matches,typed_text,autopick,event)
{
// If autopick an only one match, past.
// Used to 'pick' when pressing tab
if (matches.length < 1) {
- insert(typed_text);
+ insert(typed_text,event);
+ if(event !=null){
+ event.stopPropagation();
+ event.preventDefault();
+ }
} else if (autopick && matches.length==1) {
- insert(matches[0]);
+ insert(matches[0],event);
+ if(event !=null){
+ event.stopPropagation();
+ event.preventDefault();
+ }
}
//clear the previous completion if any
complete.children().children().remove();
@@ -381,7 +391,7 @@ var IPython = (function (IPython) {
// the same letter and complete if necessary
fastForward = sharedStart(matches)
typed_characters= fastForward.substr(matched_text.length);
- complete_with(matches,matched_text+typed_characters,true);
+ complete_with(matches,matched_text+typed_characters,true,null);
filterd=matches;
// Give focus to select, and make it filter the match as the user type
// by filtering the previous matches. Called by .keypress and .keydown
@@ -407,8 +417,8 @@ var IPython = (function (IPython) {
// but we want the default action.
event.stopPropagation();
//} else if ( key.isCompSymbol(code)|| (code==key.backspace)||(code==key.tab && down)){
- } else if ( (code==key.backspace)||(code==key.tab) || press || key.isCompSymbol(code)){
- if((code != key.backspace) && (code != key.tab) && press)
+ } else if ( (code==key.backspace)||(code==key.tab && down) || press || key.isCompSymbol(code)){
+ if( key.isCompSymbol(code) && press)
{
var newchar = String.fromCharCode(code);
typed_characters=typed_characters+newchar;
@@ -419,22 +429,22 @@ var IPython = (function (IPython) {
autopick=true;
event.stopPropagation();
event.preventDefault();
- } else if (code == key.backspace) {
+ } else if (code == key.backspace && down) {
// cancel if user have erase everything, otherwise decrease
// what we filter with
if (typed_characters.length <= 0)
{
- insert(matched_text)
+ insert(matched_text,event)
}
typed_characters=typed_characters.substr(0,typed_characters.length-1);
- }
+ }else{return}
re = new RegExp("^"+"\%?"+matched_text+typed_characters,"");
filterd = matches.filter(function(x){return re.test(x)});
- complete_with(filterd,matched_text+typed_characters,autopick);
+ complete_with(filterd,matched_text+typed_characters,autopick,event);
} else if(down){ // abort only on .keydown
// abort with what the user have pressed until now
console.log('aborting with keycode : '+code+' is down :'+down);
- insert(matched_text+typed_characters);
+ insert(matched_text+typed_characters,event);
}
}
select.keydown(function (event) {
Something went wrong with that request. Please try again.