diff --git a/features/js2r-kill.feature b/features/js2r-kill.feature index 4328160..7c02b48 100644 --- a/features/js2r-kill.feature +++ b/features/js2r-kill.feature @@ -17,6 +17,24 @@ Feature: Killing lines //} """ + Scenario: Killing a with parse errors + When I insert: + """ + function foo( + bar(); + } + """ + And I turn on js2-mode + And I go to the front of the word "function" + And I press "C-c C-m k" + Then I should see: + """ + + bar(); + } + """ + + Scenario: Killing in a string When I insert: """ diff --git a/js2r-paredit.el b/js2r-paredit.el index e9ba184..898fcb1 100644 --- a/js2r-paredit.el +++ b/js2r-paredit.el @@ -19,7 +19,13 @@ (defun js2r-kill () (interactive) - (js2r--guard) + (if js2-parsed-errors + (progn + (message "Buffer has parse errors. Killing the line.") + (kill-line)) + (js2r--kill-exp))) + +(defun js2r--kill-exp () (let* ((node (js2r--closest #'js2r--balanced-node-p)) (beg (point)) (end (and node (1- (js2-node-abs-end node)))))