mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-06 11:35:24 +08:00
Merge pull request #1327 from ellisonbg/updatecm2
Updating CodeMirror to the latest dev master. We had found a bug in CodeMirror that was forcing us to call refresh/focus/refresh on Firefox. This bug was fixed upstream. This PR pull in the latest CM with the bug fix and removes the extra refresh calls. All known CM bugs should be fixed, yeh!
This commit is contained in:
commit
ef1cc56996
41
IPython/frontend/html/notebook/static/codemirror/mode/python/python.js
vendored
Normal file → Executable file
41
IPython/frontend/html/notebook/static/codemirror/mode/python/python.js
vendored
Normal file → Executable file
@ -18,28 +18,35 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
||||
'for', 'from', 'global', 'if', 'import',
|
||||
'lambda', 'pass', 'raise', 'return',
|
||||
'try', 'while', 'with', 'yield'];
|
||||
var commontypes = ['bool', 'classmethod', 'complex', 'dict', 'enumerate',
|
||||
'float', 'frozenset', 'int', 'list', 'object',
|
||||
'property', 'reversed', 'set', 'slice', 'staticmethod',
|
||||
'str', 'super', 'tuple', 'type'];
|
||||
var py2 = {'types': ['basestring', 'buffer', 'file', 'long', 'unicode',
|
||||
'xrange'],
|
||||
var commonBuiltins = ['abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'callable', 'chr',
|
||||
'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod',
|
||||
'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset',
|
||||
'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
|
||||
'input', 'int', 'isinstance', 'issubclass', 'iter', 'len',
|
||||
'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next',
|
||||
'object', 'oct', 'open', 'ord', 'pow', 'property', 'range',
|
||||
'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
|
||||
'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple',
|
||||
'type', 'vars', 'zip', '__import__', 'NotImplemented',
|
||||
'Ellipsis', '__debug__'];
|
||||
var py2 = {'builtins': ['apply', 'basestring', 'buffer', 'cmp', 'coerce', 'execfile',
|
||||
'file', 'intern', 'long', 'raw_input', 'reduce', 'reload',
|
||||
'unichr', 'unicode', 'xrange', 'False', 'True', 'None'],
|
||||
'keywords': ['exec', 'print']};
|
||||
var py3 = {'types': ['bytearray', 'bytes', 'filter', 'map', 'memoryview',
|
||||
'open', 'range', 'zip'],
|
||||
'keywords': ['nonlocal']};
|
||||
var py3 = {'builtins': ['ascii', 'bytes', 'exec', 'print'],
|
||||
'keywords': ['nonlocal', 'False', 'True', 'None']};
|
||||
|
||||
if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
|
||||
commonkeywords = commonkeywords.concat(py3.keywords);
|
||||
commontypes = commontypes.concat(py3.types);
|
||||
commonBuiltins = commonBuiltins.concat(py3.builtins);
|
||||
var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
} else {
|
||||
commonkeywords = commonkeywords.concat(py2.keywords);
|
||||
commontypes = commontypes.concat(py2.types);
|
||||
commonBuiltins = commonBuiltins.concat(py2.builtins);
|
||||
var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
}
|
||||
var keywords = wordRegexp(commonkeywords);
|
||||
var types = wordRegexp(commontypes);
|
||||
var builtins = wordRegexp(commonBuiltins);
|
||||
|
||||
var indentInfo = null;
|
||||
|
||||
@ -129,14 +136,14 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stream.match(types)) {
|
||||
return 'builtin';
|
||||
}
|
||||
|
||||
if (stream.match(keywords)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(builtins)) {
|
||||
return 'builtin';
|
||||
}
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
return 'variable';
|
||||
}
|
||||
@ -244,7 +251,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
||||
if (current === '.') {
|
||||
style = state.tokenize(stream, state);
|
||||
current = stream.current();
|
||||
if (style === 'variable') {
|
||||
if (style === 'variable' || style === 'builtin') {
|
||||
return 'variable';
|
||||
} else {
|
||||
return ERRORCLASS;
|
||||
|
@ -530,11 +530,11 @@ var IPython = (function (IPython) {
|
||||
|
||||
CodeCell.prototype.select = function () {
|
||||
IPython.Cell.prototype.select.apply(this);
|
||||
// In some cases (inserting a new cell) we need a refresh before and
|
||||
// after the focus. Not sure why this is the case.
|
||||
this.code_mirror.refresh();
|
||||
this.code_mirror.focus();
|
||||
this.code_mirror.refresh();
|
||||
// We used to need an additional refresh() after the focus, but
|
||||
// it appears that this has been fixed in CM. This bug would show
|
||||
// up on FF when a newly loaded markdown cell was edited.
|
||||
};
|
||||
|
||||
|
||||
|
@ -96,14 +96,11 @@ var IPython = (function (IPython) {
|
||||
var output = text_cell.find("div.text_cell_render");
|
||||
output.hide();
|
||||
text_cell.find('div.text_cell_input').show();
|
||||
// I don't know why I need to do this, but if I don't do
|
||||
// refresh/focus/refresh, the to_markdown method won't work.
|
||||
this.code_mirror.refresh();
|
||||
this.code_mirror.focus();
|
||||
// This final refresh is needed on Firefox to trigger the editor
|
||||
// to be auto-sized. This glitch only happens on cell that are
|
||||
// loaded initially and haven't had their editor focused before.
|
||||
this.code_mirror.refresh();
|
||||
// We used to need an additional refresh() after the focus, but
|
||||
// it appears that this has been fixed in CM. This bug would show
|
||||
// up on FF when a newly loaded markdown cell was edited.
|
||||
this.rendered = false;
|
||||
if (this.get_text() === this.placeholder) {
|
||||
this.set_text('');
|
||||
|
Loading…
Reference in New Issue
Block a user