Skip to content
Myr

ability to specify `minColumnWidth` for `Help.wrap` (#1430)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* ability to specify `minColumnWidth` for `Help.wrap` * Added missing param in TypeScript for Help.wrap

authored by Sergei Vizel · committed by GitHub · parent d934573 · Browse files · 2 files+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−3 removed

  • other:+3 added−3 removed

2 files+3 added−3 removed

modified:typings/index.d.ts+1 added-1 removed
119 unmodified lines
120 /**121 * Wrap the given string to width characters per line, with lines after the first indented.122 * Do not wrap if insufficient room for wrapping, or string is manually formatted.123 */124 wrap(str: string, width: number, indent: number): string;124 wrap(str: string, width: number, indent: number, minColumnWidth?: number): string;125126 /** Generate the built-in help text. */127 formatHelp(cmd: Command, helper: Help): string;128 }
493 unmodified lines
modified:index.js+2 added-2 removed
314 unmodified lines
315 *316 * @param {string} str317 * @param {number} width318 * @param {number} indent319 * @param {number} [minColumnWidth=40]320 * @return {string}321 *322 */323323 wrap(str, width, indent) {324 wrap(str, width, indent, minColumnWidth = 40) {325 // Detect manually wrapped and indented strings by searching for line breaks326 // followed by multiple spaces/tabs.327 if (str.match(/[\n]\s+/)) return str;328 // Do not wrap if not enough room for a wrapped column of text (as could end up with a word per line).329 const columnWidth = width - indent;329 const minColumnWidth = 40;330 if (columnWidth < minColumnWidth) return str;331332 const leadingStr = str.substr(0, indent);333 const columnText = str.substr(indent);
1867 unmodified lines