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

fix(plugins/plugin-bash-like): ls should measure gridTemplateColumns more intelligently #5354

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions plugins/plugin-bash-like/fs/src/lib/ls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ function toTable(entries: GlobStats[], args: Arguments<LsOptions>): HTMLElement

if (!args.parsedOptions.l) {
const frag = document.createDocumentFragment()
let longest = ''

body.forEach(_ => {
const cell = document.createElement('div')
Expand All @@ -200,10 +201,17 @@ function toTable(entries: GlobStats[], args: Arguments<LsOptions>): HTMLElement
cell.classList.add('clickable')
cell.onclick = () => args.REPL.pexec(_.onclick)
frag.appendChild(cell)

longest = _.name.length >= longest.length ? _.name : longest
})

const em = 0
const ex = body.reduce((max, _) => Math.max(max, _.name.length), 0)
let ex = 0
let em = 2 // <-- for good measure
for (let idx = 0; idx < longest.length; idx++) {
const char = longest.charAt(idx)
if (char === 'm') em++
else ex++
}

const container = document.createElement('div')
container.classList.add('grid-layout')
Expand Down