From 81364b6a1c6c93248fbc43159e7dd5355cb60e6c Mon Sep 17 00:00:00 2001 From: ariasuni Date: Thu, 30 Aug 2018 01:29:31 +0200 Subject: [PATCH] Make soft-wrap break words before a slash or space and after a dash --- spec/text-editor-spec.js | 4 ++-- src/text-utils.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/text-editor-spec.js b/spec/text-editor-spec.js index f0a55b5c2..1c0000898 100644 --- a/spec/text-editor-spec.js +++ b/spec/text-editor-spec.js @@ -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]) }) }) @@ -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]) }) }) diff --git a/src/text-utils.js b/src/text-utils.js index 7dde49fd7..b4fa193d0 100644 --- a/src/text-utils.js +++ b/src/text-utils.js @@ -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?