Skip to content

Commit

Permalink
#33 fix: check modified before goto
Browse files Browse the repository at this point in the history
  • Loading branch information
LintaoAmons committed Aug 9, 2024
1 parent 37ab69d commit 797ac13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/bookmarks/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ local function goto_bookmark(bookmark, opts)
local open_method = opts.open_method or "e"
local projects = repo.project.findall()
local fullpath = domain.bookmark.fullpath(bookmark, projects)

local curren_bufnr = vim.api.nvim_get_current_buf()
-- check if the buffer have unsaved changes
if vim.api.nvim_buf_get_option(curren_bufnr, "modified") then
utils.log("Please save the current buffer before goto bookmark", vim.log.levels.WARN)
return
end

vim.api.nvim_exec2(open_method .. " " .. fullpath, {})

pcall(vim.api.nvim_win_set_cursor, 0, { bookmark.location.line, bookmark.location.col })
vim.cmd("norm! zz")
bookmark.visited_at = os.time()
Expand Down

0 comments on commit 797ac13

Please sign in to comment.