Update code_prettify to address #767

Removed index parameter in yapf_format function; instead get currently selected cell
This commit is contained in:
jfbercher
2016-10-18 16:03:24 +02:00
committed by GitHub
parent ca8801be9e
commit dc12a31961
@@ -123,10 +123,7 @@ define(function(require, exports, module) {
}
}
function yapf_format(index) {
//var selected_cell = Jupyter.notebook.get_selected_cell();
index = index;
Jupyter.notebook.select(index);
function yapf_format() {
var selected_cell = Jupyter.notebook.get_selected_cell();
if (selected_cell instanceof CodeCell) {
var text = selected_cell.get_text()
@@ -137,7 +134,7 @@ define(function(require, exports, module) {
.replace(/([^\\])\\\\\\n/g, "$1") // [continuation line] replace \ at eol (but result will be on a single line)
var code_input = 'FormatCode(' + text + ')[0]'
//console.log("INPUT",code_input)
exec_code(code_input, index)
exec_code(code_input)
}
}