##// END OF EJS Templates
Fix #4777 and #7887...
Fix #4777 and #7887 The function in charge of actually converting cursor offset to CodeMirror line number and character number was actually crashing when the cursor was at the last character (loop until undefined, then access length of variable, which is undefined). This was hiding a bug in which when you would completer to a single completion pressing tab after as-you-type filtering, the completion would be completed twice. The logic that was supposed to detect whether or not all completions had a common prefix was actually faulty as the common prefix used to be a string but was then changed to an object. Hence the logic to check whether or not there was actually a common prefix was always true, even for empty string, leading to the deletion of the line (replace by '') in some cases.

File last commit:

r18289:9b8d831c
r20538:ae7f6d6a
Show More
codemirror-ipythongfm.js
62 lines | 2.0 KiB | application/javascript | JavascriptLexer
/ IPython / html / static / notebook / js / codemirror-ipythongfm.js
Matthias Bussonnier
cleanup whitespace
r18289 // IPython GFM (GitHub Flavored Markdown) mode is just a slightly altered GFM
// Mode with support for latex.
Jonathan Frederic
Create ipythongfm mode
r16787 //
Matthias Bussonnier
cleanup whitespace
r18289 // Latex support was supported by Codemirror GFM as of
Matthias Bussonnier
codemirror rempo moved, update links in comments
r17940 // https://github.com/codemirror/CodeMirror/pull/567
Jonathan Frederic
Create ipythongfm mode
r16787 // But was later removed in
Matthias Bussonnier
codemirror rempo moved, update links in comments
r17940 // https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
Jonathan Frederic
Create ipythongfm mode
r16787
Matthias BUSSONNIER
Update to codemirror 4...
r18280
(function(mod) {
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
mod(require("codemirror/lib/codemirror")
,require("codemirror/addon/mode/multiplex")
,require("codemirror/mode/gfm/gfm")
,require("codemirror/mode/stex/stex")
);
} else if (typeof define == "function" && define.amd){ // AMD
Matthias Bussonnier
cleanup whitespace
r18289 define(["codemirror/lib/codemirror"
Matthias BUSSONNIER
Update to codemirror 4...
r18280 ,"codemirror/addon/mode/multiplex"
,"codemirror/mode/python/python"
,"codemirror/mode/stex/stex"
], mod);
} else {// Plain browser env
mod(CodeMirror);
}
})( function(CodeMirror){
"use strict";
CodeMirror.defineMode("ipythongfm", function(config, parserConfig) {
Matthias Bussonnier
cleanup whitespace
r18289
Matthias BUSSONNIER
Update to codemirror 4...
r18280 var gfm_mode = CodeMirror.getMode(config, "gfm");
var tex_mode = CodeMirror.getMode(config, "stex");
Matthias Bussonnier
cleanup whitespace
r18289
Matthias BUSSONNIER
Update to codemirror 4...
r18280 return CodeMirror.multiplexingMode(
gfm_mode,
{
open: "$", close: "$",
mode: tex_mode,
delimStyle: "delimit"
},
{
// not sure this works as $$ is interpreted at (opening $, closing $, as defined just above)
open: "$$", close: "$$",
mode: tex_mode,
delimStyle: "delimit"
},
{
open: "\\(", close: "\\)",
mode: tex_mode,
delimStyle: "delimit"
},
{
open: "\\[", close: "\\]",
mode: tex_mode,
delimStyle: "delimit"
}
// .. more multiplexed styles can follow here
);
}, 'gfm');
Matthias Bussonnier
cleanup whitespace
r18289 CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm");
Matthias BUSSONNIER
Update to codemirror 4...
r18280 })