Skip to content

Commit

Permalink
fix: ensure template insertion to occur at the current line instead o…
Browse files Browse the repository at this point in the history
…f below (#539)
  • Loading branch information
XiaowenHu96 committed Apr 10, 2024
1 parent 9644aca commit 1265a1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Fixed an issue where template insertion occurred below the intended line, it now correctly inserts at the current line.

## [v3.7.8](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.8) - 2024-04-09

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lua/obsidian/templates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ M.insert_template = function(opts)
error(string.format("Template file '%s' not found", template_path))
end

vim.api.nvim_buf_set_lines(buf, row, row, false, insert_lines)
vim.api.nvim_buf_set_lines(buf, row - 1, row - 1, false, insert_lines)
local new_cursor_row, _ = unpack(vim.api.nvim_win_get_cursor(win))
vim.api.nvim_win_set_cursor(0, { new_cursor_row, 0 })

Expand Down

0 comments on commit 1265a1f

Please sign in to comment.