Skip to content

Commit

Permalink
fix trim intro/outro bug
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 30, 2018
1 parent 5909015 commit bc3dce4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Chunk.js
Expand Up @@ -121,12 +121,12 @@ export default class Chunk {

if (trimmed.length) {
if (trimmed !== this.content) {
this.split(this.start + trimmed.length).edit('', false);
this.split(this.start + trimmed.length).edit('', undefined, true);
}
return true;

} else {
this.edit('', false);
this.edit('', undefined, true);

this.intro = this.intro.replace(rx, '');
if (this.intro.length) return true;
Expand All @@ -142,12 +142,12 @@ export default class Chunk {
if (trimmed.length) {
if (trimmed !== this.content) {
this.split(this.end - trimmed.length);
this.edit('', false);
this.edit('', undefined, true);
}
return true;

} else {
this.edit('', false);
this.edit('', undefined, true);

this.outro = this.outro.replace(rx, '');
if (this.outro.length) return true;
Expand Down
2 changes: 1 addition & 1 deletion test/MagicString.js
Expand Up @@ -1166,7 +1166,7 @@ describe( 'MagicString', () => {
it( 'should support trimming chunks with intro and outro', () => {
const s = new MagicString( ' \n' );
s.appendRight(4, 'test');
assert.strictEqual( s.trim(), 'test' );
assert.strictEqual( s.trim().toString(), 'test' );
});
});

Expand Down

0 comments on commit bc3dce4

Please sign in to comment.