Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

paste_handler: Skip undo dance if formatting was a noop.

Tim Abbott55884b1338fd
diff --git a/web/src/copy_and_paste.ts b/web/src/copy_and_paste.ts
index c88f56eb87e..2886e0ba4f2 100644
--- a/web/src/copy_and_paste.ts
+++ b/web/src/copy_and_paste.ts
@@ -745,11 +745,13 @@ export function paste_handler(this: HTMLTextAreaElement, event: JQuery.Triggered
event.stopPropagation();
paste_html = maybe_transform_html(paste_html, paste_text);
const text = paste_handler_converter(paste_html);
- // Pasting formatted text is a two-step process:
- // First we paste unformatted text,
- // then overwrite it with formatted text.
- // This way, undo restores the pre-formatting syntax.
- add_text_and_select(trimmed_paste_text, $textarea);
+ if (trimmed_paste_text !== text) {
+ // Pasting formatted text is a two-step process: First
+ // we paste unformatted text, then overwrite it with
+ // formatted text, so that undo restores the
+ // pre-formatting syntax.
+ add_text_and_select(trimmed_paste_text, $textarea);
+ }
compose_ui.insert_and_scroll_into_view(text, $textarea);
}
}