Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ledger-navigate-beginning-of-xact does not recognize commented transactions #316

Open
presto8 opened this issue Oct 1, 2021 · 1 comment

Comments

@presto8
Copy link

presto8 commented Oct 1, 2021

Currently, ledger-navigate-beginning-of-xact does not recognize commented transactions. However, the font styling rules will highlight a commented transaction. This leads to unexpected behavior; for example, invoking C-c C-d (ledger-delete-current-transaction) while the cursor is on a commented transaction will not delete the (commented) transaction that the cursor is on, but rather it will search up in the buffer to the first non-commented transaction and delete that one.

This is the regex used to find the beginning of a transaction:

"^[=~[:digit:]]"

I'm not sure if this is the best solution, but expanding it to allow one or more comment characters followed by any amount of whitespace might work?

"^\\(;+\\s-*\\)?[=~[:digit:]]"
@jstamant
Copy link
Contributor

I think a sensible fix for this would be to have C-c C-d (ledger-delete-current-transaction) throw an error if it doesn't detect that it's on a valid transaction.


Current behavior:

C-c C-d (ledger-delete-current-transaction) will delete the transaction under point, but if there isn't a transaction at point, it will continue searching backwards until it finds one, and then deletes it (ledger-navigate-beginning-of-xact is at fault for this)

The problem with this is you can destroy a transaction that's completely out of the context of where point is at. Not very intuitive for the user! If you're looking at a list of tag or account directives, this comment will shoot you as far back as it needs to delete a transaction!


Proposed behavior:

Have C-c C-d (ledger-delete-current-transaction) only delete the transaction at point if it's valid. Add some validation to prevent any unintuitive behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants