diff --git a/IPython/html/static/notebook/js/completer.js b/IPython/html/static/notebook/js/completer.js
index e592206..5386a4a 100644
--- a/IPython/html/static/notebook/js/completer.js
+++ b/IPython/html/static/notebook/js/completer.js
@@ -15,10 +15,10 @@ var IPython = (function (IPython) {
}
function _existing_completion(item, completion_array){
- for( var c in completion_array ) {
- if(completion_array[c].substr(-item.length) == item)
- { return true; }
- }
+ for( var c in completion_array ) {
+ if(completion_array[c].trim().substr(-item.length) == item)
+ { return true; }
+ }
return false;
}