Append space as needed in compose_ui.smart_insert().

This commit is contained in:
Steve Howell
2017-11-09 08:57:59 -08:00
committed by Tim Abbott
parent f935afa241
commit d7254a0556
2 changed files with 19 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ exports.smart_insert = function (textarea, syntax) {
var pos = textarea.caret();
var before_str = textarea.val().slice(0, pos);
var after_str = textarea.val().slice(pos);
if (pos > 0) {
if (!is_space(before_str.slice(-1))) {
@@ -21,6 +21,12 @@ exports.smart_insert = function (textarea, syntax) {
}
}
if (after_str.length > 0) {
if (!is_space(after_str[0])) {
syntax += ' ';
}
}
textarea.caret(syntax);
textarea.focus();
};