Skip to content

Commit 82d95a6

Browse files
committed
chore: rename lineLengthIfLong
1 parent 38795db commit 82d95a6

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

spec/editor-spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @babel */
22

3-
import { lineCountIfLarge, lineLengthIfLongerThan, largeness } from "../commons-atom/editor-largeness"
3+
import { lineCountIfLarge, lineLengthIfLong, largeness } from "../commons-atom/editor-largeness"
44
import type { TextEditor, WorkspaceOpenOptions } from "atom"
55
import { open, track, cleanup } from "temp"
66
import { Chance } from "chance"
@@ -55,14 +55,14 @@ describe("editor", () => {
5555
})
5656
})
5757

58-
describe("lineLengthIfLongerThan", () => {
58+
describe("lineLengthIfLong", () => {
5959
it("return 0 for short files", async () => {
6060
const { textEditor } = await openTempTextEditor(1, 1)
61-
expect(lineLengthIfLongerThan(textEditor, 1000)).toBe(0)
61+
expect(lineLengthIfLong(textEditor, 1000)).toBe(0)
6262
})
6363
it("return largest line length for long files", async () => {
6464
const { textEditor, fileLegth } = await openTempTextEditor(1, 100)
65-
expect(lineLengthIfLongerThan(textEditor, 100)).toBeGreaterThanOrEqual(fileLegth - 10)
65+
expect(lineLengthIfLong(textEditor, 100)).toBeGreaterThanOrEqual(fileLegth - 10)
6666
})
6767
})
6868

src-commons-atom/editor-largeness.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TextEditor } from "atom"
44
* Find if an editor's largeness based on the given threashold
55
* @param editor
66
* @param largeLineCount lineCountIfLarge threashold
7-
* @param longLineLength lineLengthIfLongerThan threashold
7+
* @param longLineLength lineLengthIfLong threashold
88
* @returns the largness score if editor is large. Otherwise it returns 0 (a small file)
99
*/
1010
export function largeness(
@@ -16,7 +16,7 @@ export function largeness(
1616
if (lineCount !== 0) {
1717
return lineCount
1818
}
19-
const longLine = lineLengthIfLongerThan(editor, longLineLength)
19+
const longLine = lineLengthIfLong(editor, longLineLength)
2020
if (longLine !== 0) {
2121
return longLine
2222
}
@@ -48,11 +48,7 @@ export function lineCountIfLarge(editor: TextEditor, threashold: number) {
4848
* @param lineCount count up to this line. Default is {editor.getLineCount()}
4949
* @returns the first line length that has a length larger than threashold. If no line is found, it returns 0
5050
*/
51-
export function lineLengthIfLongerThan(
52-
editor: TextEditor,
53-
threashold: number,
54-
lineCount: number = editor.getLineCount()
55-
) {
51+
export function lineLengthIfLong(editor: TextEditor, threashold: number, lineCount: number = editor.getLineCount()) {
5652
const buffer = editor.getBuffer()
5753
for (let i = 0, len = lineCount; i < len; i++) {
5854
const lineLength = buffer.lineLengthForRow(i)

0 commit comments

Comments
 (0)