Skip to content

Commit 692021b

Browse files
committed
merged gutter and addGutterToLines. no need for them both to exist
1 parent 0a899f5 commit 692021b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

‎index.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ const formatHunkOutput = (str, width, color) => {
6969
)
7070
}
7171

72-
const addGutterToLines = (gutter, lines) => lines.map((line, i) => `${gutter[i === 0 ? 0 : 1]}${line}`)
73-
7472
class Pair {
7573
constructor(left, right) {
7674
this.left = left
@@ -167,7 +165,7 @@ class HunkContent extends DiffOutput {
167165
this.wrapWidth = colwidth - this.gutterWidth
168166
}
169167
}
170-
gutter(changed = false){
168+
addGutterToLines(lines, changed = false){
171169
const gutterColor = changed ? chalk.white : chalk.grey
172170
const gutterBackground = this.currentLineNumber ? (changed ? this.changedLineNumberColor : bgColor) : bgColor
173171

@@ -176,7 +174,7 @@ class HunkContent extends DiffOutput {
176174
gutterBackground(repeatChar(' ', this.gutterWidth))
177175
]
178176

179-
return gutter
177+
return lines.map((line, i) => `${gutter[i === 0 ? 0 : 1]}${line}`)
180178
}
181179
addLine(rawLine, changed = false) {
182180
if(this.sanctioned.length > 0) {
@@ -195,7 +193,7 @@ class HunkContent extends DiffOutput {
195193

196194
// add our parsed lines to the entire output stored.
197195
if(this.lineNumbers){
198-
Array.prototype.push.apply(this.outputLines, addGutterToLines(this.gutter(changed), lines))
196+
Array.prototype.push.apply(this.outputLines, this.addGutterToLines(lines, changed))
199197
} else {
200198
Array.prototype.push.apply(this.outputLines, lines)
201199
}

0 commit comments

Comments
 (0)