refactor: adjust number column alignment (#2331)
This commit is contained in:
1 parent
165c25b743
commit
e1016bbd74
2 files changed
+5
-4
No files matched your search
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
### Changed
|
||||
|
||||
- The `previewer` script no longer skips non-regular files (#2327).
|
||||
- Line numbers now take up less space when both `number` and `relativenumber` are enabled (#2331).
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@@ -391,12 +391,12 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
||||
|
||||
if dirStyle.role == Active && (gOpts.number || gOpts.relativenumber) {
|
||||
lnwidth = 1
|
||||
if gOpts.number && gOpts.relativenumber {
|
||||
lnwidth++
|
||||
}
|
||||
for j := 10; j <= fileslen; j *= 10 {
|
||||
lnwidth++
|
||||
}
|
||||
if gOpts.number && gOpts.relativenumber {
|
||||
lnwidth = max(lnwidth, 2)
|
||||
}
|
||||
}
|
||||
|
||||
var userWidth, groupWidth, customWidth int
|
||||
@@ -441,7 +441,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
||||
case i > dir.pos:
|
||||
ln = fmt.Sprintf("%*d", lnwidth, i-dir.pos)
|
||||
case gOpts.number:
|
||||
ln = fmt.Sprintf("%*d ", lnwidth-1, i+1+beg)
|
||||
ln = fmt.Sprintf("%-*d", lnwidth, i+1+beg)
|
||||
default:
|
||||
ln = fmt.Sprintf("%*d", lnwidth, 0)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user