Skip to content

Commit 48c19e7

Browse files
committed
Merge pull request ipython#2903 from Carreau/toggle-line-number
Specify toggle value on cell line number
2 parents 818956c + 70d3237 commit 48c19e7

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

IPython/frontend/html/notebook/static/js/cell.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,24 @@ var IPython = (function (IPython) {
239239
}
240240
};
241241

242+
/**
243+
* Show/Hide CodeMirror LineNumber
244+
* @method show_line_numbers
245+
*
246+
* @param value {Bool} show (true), or hide (false) the line number in CodeMirror
247+
**/
248+
Cell.prototype.show_line_numbers = function (value) {
249+
this.code_mirror.setOption('lineNumbers', value);
250+
this.code_mirror.refresh();
251+
};
252+
242253
/**
243254
* Toggle CodeMirror LineNumber
244255
* @method toggle_line_numbers
245256
**/
246257
Cell.prototype.toggle_line_numbers = function () {
247-
if (this.code_mirror.getOption('lineNumbers') == false) {
248-
this.code_mirror.setOption('lineNumbers', true);
249-
} else {
250-
this.code_mirror.setOption('lineNumbers', false);
251-
}
252-
this.code_mirror.refresh();
258+
var val = this.code_mirror.getOption('lineNumbers');
259+
this.show_line_numbers(!val);
253260
};
254261

255262
/**

IPython/frontend/html/notebook/static/js/toolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var IPython = (function (IPython) {
4040
* {
4141
* label:'my button',
4242
* icon:'ui-icon-disk',
43-
* callback:function(){alert('hoho'),
43+
* callback:function(){alert('hoho')},
4444
* id : 'my_button_id', // this is optional
4545
* },
4646
* {

0 commit comments

Comments
 (0)