mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
Handle single long words that exceed the wrap column in autoflow
This commit is contained in:
@@ -14,10 +14,12 @@ module.exports =
|
||||
currentLine = []
|
||||
currentLineLength = 0
|
||||
for segment in @segmentText(text.replace(/\n/g, ' '))
|
||||
if /\w/.test(segment) and currentLineLength + segment.length > wrapColumn
|
||||
lines.push(currentLine.join(''))
|
||||
currentLine = []
|
||||
currentLineLength = 0
|
||||
if /\w/.test(segment) and
|
||||
(currentLineLength + segment.length > wrapColumn) and
|
||||
(currentLineLength > 0 or segment.length < wrapColumn)
|
||||
lines.push(currentLine.join(''))
|
||||
currentLine = []
|
||||
currentLineLength = 0
|
||||
currentLine.push(segment)
|
||||
currentLineLength += segment.length
|
||||
lines.push(currentLine.join(''))
|
||||
|
||||
@@ -7,10 +7,10 @@ describe "Autoflow package", ->
|
||||
rootView = new RootView
|
||||
atom.loadPackage 'autoflow'
|
||||
editor = rootView.getActiveEditor()
|
||||
config.set('editor.preferredLineLength', 30)
|
||||
|
||||
describe "autoflow:reflow-paragraph", ->
|
||||
it "rearranges line breaks in the current paragraph to ensure lines are shorter than config.editor.preferredLineLength", ->
|
||||
config.set('editor.preferredLineLength', 30)
|
||||
editor.setText """
|
||||
This is a preceding paragraph, which shouldn't be modified by a reflow of the following paragraph.
|
||||
|
||||
@@ -39,3 +39,15 @@ describe "Autoflow package", ->
|
||||
This is a following paragraph, which shouldn't be modified by a reflow of the preciding paragraph.
|
||||
|
||||
"""
|
||||
|
||||
it "allows for single words that exceed the preferred wrap column length", ->
|
||||
editor.setText("this-is-a-super-long-word-that-shouldn't-break-autoflow and these are some smaller words")
|
||||
|
||||
editor.setCursorBufferPosition([0, 4])
|
||||
editor.trigger 'autoflow:reflow-paragraph'
|
||||
|
||||
expect(editor.getText()).toBe """
|
||||
this-is-a-super-long-word-that-shouldn't-break-autoflow
|
||||
and these are some smaller
|
||||
words
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user