Fix entry_with_replacements unable to select text.

This hook had a bug where you couldn't select text because every
time you push a button, including ctrl+a or shift+left/right, the
cursor position gets reset and then deselects immediately.

So let's only reset the content and cursor only when text changes,
so arrow keys and ctrl don't have any negative effects.
master
voussoir 2020-01-30 12:28:28 -08:00
parent eff0efdf40
commit 4da331a3ab
1 changed files with 7 additions and 3 deletions

View File

@ -129,9 +129,13 @@ common.entry_with_tagname_replacements =
function entry_with_tagname_replacements(event)
{
var cursor_position = event.target.selectionStart;
event.target.value = common.tagname_replacements(event.target.value);
var new_value = common.tagname_replacements(event.target.value);
if (new_value != event.target.value)
{
event.target.value = new_value;
event.target.selectionStart = cursor_position;
event.target.selectionEnd = cursor_position;
}
}
common.html_to_element =