From 83b8fe3c800551186db7c39a09c6b0abbabdaf6d Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 21 Jul 2024 10:38:09 +0000 Subject: [PATCH 1/3] docs: update CHANGELOG.md for v0.6.4 and remove duplicate entries --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46435ab..22b08d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,15 @@ # Changelog +## [v0.6.4](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.4) (2024-07-21) +- docs: update CHANGELOG.md for v0.6.3 and remove duplicate entries + +[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.3...v0.6.4) + ## [v0.6.3](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.3) (2024-07-21) - Merge pull request #15 from joshuadanpeterson/dev - docs: update CHANGELOG.md for v0.6.2 and remove duplicate entries -[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.2...v0.6.3) +[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.4...v0.6.3) ## [v0.6.2](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.2) (2024-07-21) - Merge branch 'main' into dev From 5549ead3acf01b804b4ec750a8f2ba6876d97e9e Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Sun, 28 Jul 2024 05:12:22 -0600 Subject: [PATCH 2/3] feat(autocommands): Preserve column position when moving between lines of different lengths - Implemented logic to preserve the cursor's column position when moving between lines of varying lengths. - Introduced `target_col` to store the desired column position across line movements. - Added checks to ensure the cursor is moved to the end of the line if the new line is shorter than `target_col`. - Ensured `target_col` is updated only when moving within the same line to handle lateral movements correctly. - Accounted for blank lines by setting the cursor to position 0 when moving to shorter lines. - Integrated cursor centering after each movement for improved user experience. This commit addresses the issue where the cursor position was not being preserved correctly when moving between lines of different lengths, especially handling edge cases such as blank lines and shorter lines. --- lua/typewriter/autocommands.lua | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lua/typewriter/autocommands.lua b/lua/typewriter/autocommands.lua index 44dadc8..c68f068 100644 --- a/lua/typewriter/autocommands.lua +++ b/lua/typewriter/autocommands.lua @@ -53,6 +53,42 @@ function M.autocmd_setup() commands.move_to_bottom_of_block() end, { desc = "Move the bottom of the current code block to the bottom of the screen" }) + -- Preserve column position when moving between lines of different lengths + local target_col = nil + local last_line = nil + + vim.api.nvim_create_autocmd("CursorMoved", { + pattern = "*", + callback = function() + local current_line, current_col = unpack(vim.api.nvim_win_get_cursor(0)) + local line_length = vim.fn.col('$') - 1 -- Get the actual length of the current line + + -- If we've moved to a new line + if last_line ~= current_line then + -- If target_col is not set, use the current column + if target_col == nil then + target_col = current_col + end + + -- If the current line is shorter than target_col, move to the end of the line + if line_length < target_col then + vim.api.nvim_win_set_cursor(0, { current_line, line_length }) + -- If the current line is long enough, move to the target column + elseif current_col ~= target_col then + vim.api.nvim_win_set_cursor(0, { current_line, target_col }) + end + else + -- If we're on the same line, update the target column + target_col = current_col + end + + last_line = current_line + + -- Center the cursor + commands.center_cursor() + end + }) + -- Autocommands for ZenMode integration if config.config.enable_with_zen_mode then vim.api.nvim_create_autocmd("User", { From 6b89bca9e63ce4ced67acb3641c0499cece32db2 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 29 Jul 2024 09:00:01 +0000 Subject: [PATCH 3/3] docs: update CHANGELOG.md for v0.6.5 and remove duplicate entries --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22b08d1..7c1aaef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ # Changelog +## [v0.6.5](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.5) (2024-07-29) +- feat(autocommands): Preserve column position when moving between lines of different lengths +- docs: update CHANGELOG.md for v0.6.4 and remove duplicate entries + +[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.4...v0.6.5) + ## [v0.6.4](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.4) (2024-07-21) - docs: update CHANGELOG.md for v0.6.3 and remove duplicate entries -[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.3...v0.6.4) +[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.5...v0.6.4) ## [v0.6.3](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.3) (2024-07-21) - Merge pull request #15 from joshuadanpeterson/dev