From caaeec08e485d9fcea20f0f4197afddf05d03f69 Mon Sep 17 00:00:00 2001 From: eight Date: Thu, 9 Nov 2017 06:16:07 +0800 Subject: [PATCH] Fix: use Math.max --- edit/applies-to-line-widget.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/edit/applies-to-line-widget.js b/edit/applies-to-line-widget.js index 730bd3c5..adec9b9c 100644 --- a/edit/applies-to-line-widget.js +++ b/edit/applies-to-line-widget.js @@ -107,10 +107,7 @@ function createAppliesToLineWidget(cm) { const toIndex = widgets[j] ? cm.indexFromPos({line: widgets[j].line.lineNo(), ch: 0}) : cm.getValue().length; // splice - if (i < 0) { - i = 0; - } - + i = Math.max(0, i); widgets.splice(i, 0, ...createWidgets(fromIndex, toIndex, widgets.splice(i, j - i))); fromLine = null;