Skip to content

Commit

Permalink
Merge pull request #24 from joshuadanpeterson/twdisable-autocmd-colum…
Browse files Browse the repository at this point in the history
…n-preservation

fix(autocommands): Correct column preservation behavior in TWDisable
  • Loading branch information
joshuadanpeterson authored Oct 20, 2024
2 parents 4133ad4 + cb3e01a commit 85f35da
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/typewriter/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,21 @@ function M.autocmd_setup()
end, { desc = "Enable Typewriter mode" })

vim.api.nvim_create_user_command("TWDisable", function()
-- Disable typewriter mode
commands.disable_typewriter_mode()
end, { desc = "Disable Typewriter mode" })

-- Check if column preservation is active, and reset state to NORMAL
if current_state == State.PRESERVE_COLUMN then
set_state(State.NORMAL)
print("Column preservation disabled")
end

-- Clear any autocmds related to column preservation or cursor movement
vim.api.nvim_clear_autocmds({
event = "CursorMoved",
buffer = 0, -- for the current buffer
})
end, { desc = "Disable Typewriter mode and column preservation" })

vim.api.nvim_create_user_command("TWToggle", function()
commands.toggle_typewriter_mode()
Expand Down

0 comments on commit 85f35da

Please sign in to comment.