FIX: Error applying quotes with blank lines in front

This commit is contained in:
Robin Ward 2017-11-20 13:46:19 -05:00
parent ad71d679cf
commit b9595966d4
2 changed files with 24 additions and 1 deletions

View File

@ -438,7 +438,9 @@ export default Ember.Component.extend({
}
if (operation !== OP.ADDED &&
(l.slice(0, hlen) === hval && tlen === 0 || l.slice(-tlen) === tail)) {
(l.slice(0, hlen) === hval && tlen === 0 ||
(tail.length && l.slice(-tlen) === tail))) {
operation = OP.REMOVED;
if (tlen === 0) {
const result = l.slice(hlen);
@ -500,6 +502,7 @@ export default Ember.Component.extend({
tlen,
opts
);
this.set('value', `${pre}${contents}${post}`);
if (lines.length === 1 && tlen > 0) {
this._selectText(sel.start + hlen, sel.value.length);

View File

@ -540,6 +540,26 @@ componentTest("quote button - empty lines", {
}
});
componentTest("quote button - selecting empty lines", {
template: '{{d-editor value=value composerEvents=true}}',
beforeEach() {
this.set('value', "one\n\n\n\ntwo");
},
test(assert) {
const textarea = jumpEnd(this.$('textarea.d-editor-input')[0]);
andThen(() => {
textarea.selectionStart = 6;
textarea.selectionEnd = 10;
});
click('button.quote');
andThen(() => {
assert.equal(this.get('value'), "one\n\n\n> \n> two");
});
}
});
testCase('quote button', function(assert, textarea) {
andThen(() => {