mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
compose: Fix extra space being added by quote-and-reply.
The correct behavior here is that we want to ensure there is whitespace in between the syntax being added and the content on either side. Our smart_insert logic handled this for the cases that were common with inserting emoji (etc.), but didn't handle the more complex cases with "quote and reply". Fixes #11702.
This commit is contained in:
@@ -16,12 +16,18 @@ exports.smart_insert = function (textarea, syntax) {
|
||||
var after_str = textarea.val().slice(pos);
|
||||
|
||||
if (pos > 0) {
|
||||
if (!is_space(before_str.slice(-1))) {
|
||||
// If there isn't space either at the end of the content
|
||||
// before the insert or (unlikely) at the start of the syntax,
|
||||
// add one.
|
||||
if (!is_space(before_str.slice(-1)) && !is_space(syntax[0])) {
|
||||
syntax = ' ' + syntax;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(after_str.length > 0 && is_space(after_str[0]))) {
|
||||
// If there isn't whitespace either at the end of the syntax or the
|
||||
// start of the content after the syntax, add one.
|
||||
if (!(after_str.length > 0 && is_space(after_str[0]) ||
|
||||
syntax.length > 0 && is_space(syntax.slice(-1)))) {
|
||||
syntax += ' ';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user