Skip to content

Commit

Permalink
Merge pull request #25 from joshuadanpeterson/fix/restore-column-rete…
Browse files Browse the repository at this point in the history
…ntion-issue-16

fix(autocommands): Restore default column retention behavior (Issue #16)
  • Loading branch information
joshuadanpeterson authored Oct 20, 2024
2 parents d68b7af + 4833c0b commit b96937d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/typewriter/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ function M.autocmd_setup()
-- User commands
vim.api.nvim_create_user_command("TWEnable", function()
commands.enable_typewriter_mode()
set_state(State.PRESERVE_COLUMN) -- Enable column preservation when typewriter mode is active
end, { desc = "Enable Typewriter mode" })

vim.api.nvim_create_user_command("TWDisable", function()
Expand Down Expand Up @@ -275,10 +276,14 @@ function M.autocmd_setup()
vim.api.nvim_create_autocmd("CursorMoved", {
pattern = "*",
callback = function()
if current_state == State.PRESERVE_COLUMN then
-- Only preserve column if typewriter mode is active
if current_state == State.PRESERVE_COLUMN and utils.is_typewriter_active() then
handle_column_preservation()
elseif current_state == State.NORMAL then
commands.center_cursor()
-- Default Neovim behavior (no column preservation)
-- We don't interfere with the default behavior when not in typewriter mode
return
end
end,
})
Expand Down

0 comments on commit b96937d

Please sign in to comment.