Omar Elmasri 2025-06-14 23:57:52 +03:00 committed by GitHub
commit 82fb74e63c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View File

@ -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` |
| `pad_selection_index_register` | Whether to align selection indices register with zero padding | `false` |
| `popup-border` | Draw border around `popup`, `menu`, `all`, or `none` | `none` |
| `indent-heuristic` | How the indentation for a newly inserted line is computed: `simple` just copies the indentation level from the previous line, `tree-sitter` computes the indentation based on the syntax tree and `hybrid` combines both approaches. If the chosen heuristic is not available, a different one will be used as a fallback (the fallback order being `hybrid` -> `tree-sitter` -> `simple`). | `hybrid`
| `jump-label-alphabet` | The characters that are used to generate two character jump labels. Characters at the start of the alphabet are used first. | `"abcdefghijklmnopqrstuvwxyz"`

View File

@ -354,6 +354,8 @@ pub struct Config {
pub trim_trailing_whitespace: bool,
/// Enables smart tab
pub smart_tab: Option<SmartTabConfig>,
/// Enables padding selection indecis register
pub pad_selection_index_register: bool,
/// Draw border around popups.
pub popup_border: PopupBorderConfig,
/// Which indent heuristic to use when a new line is inserted
@ -1024,6 +1026,7 @@ impl Default for Config {
trim_final_newlines: false,
trim_trailing_whitespace: false,
smart_tab: Some(SmartTabConfig::default()),
pad_selection_index_register: false,
popup_border: PopupBorderConfig::None,
indent_heuristic: IndentationHeuristic::default(),
jump_label_alphabet: ('a'..='z').collect(),

View File

@ -46,11 +46,16 @@ impl Registers {
'#' => {
let (view, doc) = current_ref!(editor);
let selections = doc.selection(view.id).len();
let number_of_digits = if editor.config().pad_selection_index_register {
selections.ilog10() as usize + 1
} else {
0
};
// ExactSizeIterator is implemented for Range<usize> but
// not RangeInclusive<usize>.
Some(RegisterValues::new(
(0..selections).map(|i| (i + 1).to_string().into()),
))
Some(RegisterValues::new((0..selections).map(move |i| {
format!("{:0width$}", i + 1, width = number_of_digits).into()
})))
}
'.' => {
let (view, doc) = current_ref!(editor);