mirror of
https://github.com/jupyter/notebook.git
synced 2025-04-24 14:20:54 +08:00
Merge pull request #2906 from Carreau/mkypatch-cm
Unpatch/Monkey patch CM
This commit is contained in:
commit
0c5c5b9c83
@ -15,6 +15,32 @@
|
||||
* @submodule CodeCell
|
||||
*/
|
||||
|
||||
|
||||
/* local util for codemirror */
|
||||
var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}
|
||||
|
||||
/**
|
||||
*
|
||||
* function to delete until previous non blanking space character
|
||||
* or first multiple of 4 tabstop.
|
||||
* @private
|
||||
*/
|
||||
CodeMirror.commands.delSpaceToPrevTabStop = function(cm){
|
||||
var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
|
||||
if (!posEq(from, to)) {cm.replaceRange("", from, to); return}
|
||||
var cur = cm.getCursor(), line = cm.getLine(cur.line);
|
||||
var tabsize = cm.getOption('tabSize');
|
||||
var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
|
||||
var from = {ch:cur.ch-chToPrevTabStop,line:cur.line}
|
||||
var select = cm.getRange(from,cur)
|
||||
if( select.match(/^\ +$/) != null){
|
||||
cm.replaceRange("",from,cur)
|
||||
} else {
|
||||
cm.deleteH(-1,"char")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var IPython = (function (IPython) {
|
||||
"use strict";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user