Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Make soft-wrap break words before a slash or space and after a dash
Browse files Browse the repository at this point in the history
  • Loading branch information
ariasuni committed Aug 29, 2018
1 parent 7865464 commit 475ace5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions spec/text-editor-spec.js
Expand Up @@ -560,7 +560,7 @@ describe('TextEditor', () => {
it('wraps to the end of the previous line', () => {
editor.setCursorScreenPosition([4, 4])
editor.moveLeft()
expect(editor.getCursorScreenPosition()).toEqual([3, 46])
expect(editor.getCursorScreenPosition()).toEqual([3, 49])
})
})

Expand Down Expand Up @@ -790,7 +790,7 @@ describe('TextEditor', () => {
editor.setCursorScreenPosition([0, 2])
editor.moveToEndOfLine()
const cursor = editor.getLastCursor()
expect(cursor.getScreenPosition()).toEqual([4, 4])
expect(cursor.getScreenPosition()).toEqual([3, 5])
})
})

Expand Down
3 changes: 2 additions & 1 deletion src/text-utils.js
Expand Up @@ -103,7 +103,8 @@ const isWordStart = (previousCharacter, character) =>
((character !== ' ') && (character !== '\t'))

const isWrapBoundary = (previousCharacter, character) =>
isWordStart(previousCharacter, character) || isCJKCharacter(character)
isWordStart(previousCharacter, character) || isCJKCharacter(character) ||
previousCharacter === '-' || character === '/' || character === ' '

// Does the given string contain at least surrogate pair, variation sequence,
// or combined character?
Expand Down

0 comments on commit 475ace5

Please sign in to comment.