Skip to content

Commit

Permalink
Fix how a breakpoint location is computed
Browse files Browse the repository at this point in the history
* indium-structs.el (indium-breakpoint-location): Fix movement to
  return the proper location. Rationale: given that (point-min) is 1,
  after (goto-char (point-min)), 0 must be passed to forward-char
  instead of 1. This is particularly important if the breakpoint is
  at (point-max) because forward-char would raise an error.
* test/unit/indium-breakpoint-test.el: Add test.
* test/unit/indium-structs-test.el ("Breakpoints"): Fix an incorrect
  test: the end of line 1 is still line 1.
  • Loading branch information
DamienCassou authored and NicolasPetton committed Mar 1, 2019
1 parent 23f2781 commit d2f5cf4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion indium-structs.el
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
(with-current-buffer buf
(save-excursion
(goto-char (point-min))
(forward-char pos)
(forward-char (1- pos))
(back-to-indentation)
(indium-location-at-point)))))

Expand Down
9 changes: 9 additions & 0 deletions test/unit/indium-breakpoint-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,14 @@
(indium-breakpoint--unregister-all-breakpoints)
(expect (indium-breakpoint-resolved brk) :to-be nil))))))

(describe "Removing a breakpoint"
(it "should work when breakpoint is on point-max"
(with-js2-file
(goto-char (point-max))
(indium-breakpoint-add)
(expect (length (indium-breakpoint-breakpoints-at-point)) :to-be 1)
(indium-breakpoint-remove)
(expect (length (indium-breakpoint-breakpoints-at-point)) :to-be 0))))

(provide 'indium-breakpoint-test)
;;; indium-breakpoint-test.el ends here
2 changes: 1 addition & 1 deletion test/unit/indium-structs-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
(save-excursion
(goto-char (point-max))
(expect (indium-location-line (indium-breakpoint-location brk))
:to-equal 2))))))
:to-equal 1))))))

(describe "Scopes"
(it "Should be able to make scopes from alists"
Expand Down

0 comments on commit d2f5cf4

Please sign in to comment.