Skip to content

feat(selection-indices): zero pad according to max number of digits. #13386

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

masriomarm
Copy link

Implement #13356
First oss contribution, let me know if something is wrong.

@@ -55,6 +55,7 @@
| `insert-final-newline` | Whether to automatically insert a trailing line-ending on write if missing | `true` |
| `trim-final-newlines` | Whether to automatically remove line-endings after the final one on write | `false` |
| `trim-trailing-whitespace` | Whether to automatically remove whitespace preceding line endings on write | `false` |
| `padding_selection_index_register` | Whether to align selection indices register with zero padding | `false` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pad-selection-index-register would probably be a better name for this option

Comment on lines +49 to +52
let mut number_of_digits = 0 as usize;
if editor.config().padding_selection_index_register {
number_of_digits = (selections.ilog10() + 1) as usize;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut number_of_digits = 0 as usize;
if editor.config().padding_selection_index_register {
number_of_digits = (selections.ilog10() + 1) as usize;
}
let number_of_digits = if editor.config().padding_selection_index_register {
selections.ilog10() as usize + 1
} else { 0 }

@nik-rev
Copy link
Contributor

nik-rev commented Apr 21, 2025

I'm not sure if this deserves a config option. Something like #13354 with a flag such as --pad would be more suitable

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

Successfully merging this pull request may close these issues.

3 participants