mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
[notebook] deduplicate completion results
remove context completion that are duplicates from introspection completion fixes #1840
This commit is contained in:
parent
8d5c980526
commit
d74a58b3c8
@ -116,12 +116,28 @@ var IPython = (function (IPython) {
|
||||
|
||||
var cur = this.editor.getCursor();
|
||||
var results = CodeMirror.contextHint(this.editor);
|
||||
var filterd_results = Array();
|
||||
console.log('results',results)
|
||||
//remove results from context completion
|
||||
//that are already in kernel completion
|
||||
for(var elm in results)
|
||||
{
|
||||
if(matches.indexOf(results[elm]['str']) == -1)
|
||||
{
|
||||
//filterd_results.push(elm);
|
||||
console.log('adding',results[elm])
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('skipping ',results[elm]);
|
||||
}
|
||||
}
|
||||
|
||||
// append the introspection result, in order, at at the beginning of
|
||||
// the table and compute the replacement range from current cursor
|
||||
// positon and matched_text length.
|
||||
for (var i = matches.length - 1; i >= 0; --i) {
|
||||
results.unshift({
|
||||
filterd_results.unshift({
|
||||
str: matches[i],
|
||||
type: "introspection",
|
||||
from: {
|
||||
@ -136,7 +152,7 @@ var IPython = (function (IPython) {
|
||||
}
|
||||
|
||||
// one the 2 sources results have been merge, deal with it
|
||||
this.raw_result = results;
|
||||
this.raw_result = filterd_results;
|
||||
|
||||
// if empty result return
|
||||
if (!this.raw_result || !this.raw_result.length) return;
|
||||
|
Loading…
Reference in New Issue
Block a user