Skip to content

Commit

Permalink
Adds support for killing with parse errors
Browse files Browse the repository at this point in the history
When the buffer has parse errors, fallback to `kill-line`
  • Loading branch information
NicolasPetton committed Sep 2, 2014
1 parent 540db1d commit 00ea041
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions features/js2r-kill.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
8 changes: 7 additions & 1 deletion js2r-paredit.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
Expand Down

0 comments on commit 00ea041

Please sign in to comment.