Skip to content

Commit

Permalink
Fix cursor insertion placement
Browse files Browse the repository at this point in the history
  • Loading branch information
grierson committed Aug 15, 2023
1 parent c0f5022 commit 0656b52
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions fnl/formedit/insertion.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[start-row start-col] [(form:start)]
start-col (+ start-col insert-offset)]
(vim.api.nvim_buf_set_text 0 start-row start-col start-row start-col [" "])
(vim.api.nvim_win_set_cursor 0 [(+ start-row 1) (+ start-col 1)])
(vim.api.nvim_feedkeys :i :n true)))

(fn tail []
Expand Down
6 changes: 3 additions & 3 deletions fnl/spec/insertion_spec.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
(fn []
(h.setup {:content "(1)" :cursor [1 0]})
(h.feedkeys head-keymap)
(h.expect {:content "( 1)" :cursor [1 0]})))
(h.expect {:content "( 1)" :cursor [1 1]})))
(it :set
(fn []
(h.setup {:content "#{1}" :cursor [1 0]})
(h.feedkeys head-keymap)
(h.expect {:content "#{ 1}" :cursor [1 0]})))
(h.expect {:content "#{ 1}" :cursor [1 2]})))
(it "sub form"
(fn []
(h.setup {:content "(1 (2))" :cursor [1 3]})
(h.feedkeys head-keymap)
(h.expect {:content "(1 ( 2))" :cursor [1 2]})))))
(h.expect {:content "(1 ( 2))" :cursor [1 4]})))))

(describe "tail insertion"
(fn []
Expand Down
1 change: 1 addition & 0 deletions lua/formedit/insertion.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lua/spec/insertion_spec.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0656b52

Please sign in to comment.