From af4c95e267809efefa268d031dd193f4f2282a3e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 29 Sep 2020 14:17:44 +0100 Subject: [PATCH] apply to whitespace in general Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/editor/range.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/editor/range.ts b/src/editor/range.ts index 1d9c75e238..838dfd8b98 100644 --- a/src/editor/range.ts +++ b/src/editor/range.ts @@ -18,8 +18,8 @@ import EditorModel from "./model"; import DocumentPosition, {Predicate} from "./position"; import {Part} from "./parts"; -const whileSpacePredicate: Predicate = (index, offset, part) => { - return part.text[offset] === " "; +const whitespacePredicate: Predicate = (index, offset, part) => { + return part.text[offset].trim() === ""; }; export default class Range { @@ -40,8 +40,8 @@ export default class Range { } trim() { - this._start = this._start.forwardsWhile(this.model, whileSpacePredicate); - this._end = this._end.backwardsWhile(this.model, whileSpacePredicate); + this._start = this._start.forwardsWhile(this.model, whitespacePredicate); + this._end = this._end.backwardsWhile(this.model, whitespacePredicate); } expandBackwardsWhile(predicate: Predicate) {