File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -467,9 +467,22 @@ function RoomViewInput({
467467
468468 textArea . focus ( ) ;
469469
470- if ( typeof selectionStart === 'number' ) {
470+ if ( typeof selectionStart === 'number' && typeof selectionEnd === 'number' ) {
471471
472- textArea . val ( textArea . val ( ) . substring ( 0 , selectionStart ) + emoji . unicode + textArea . val ( ) . substring ( selectionEnd , textArea . val ( ) . length ) ) ;
472+ let part1 = textArea . val ( ) . substring ( 0 , selectionStart ) ;
473+ let part2 = textArea . val ( ) . substring ( selectionEnd , textArea . val ( ) . length ) ;
474+
475+ if ( part1 . endsWith ( ':' ) ) {
476+ part1 += ' ' ;
477+ selectionStart ++ ;
478+ }
479+
480+ if ( part2 . startsWith ( ':' ) ) {
481+ part2 = ` ${ part2 } ` ;
482+ selectionEnd ++ ;
483+ }
484+
485+ textArea . val ( part1 + emoji . unicode + part2 ) ;
473486
474487 textAreaRef . current . selectionStart = selectionStart + emoji . unicode . length ;
475488 textAreaRef . current . selectionEnd = selectionStart + emoji . unicode . length ;
You can’t perform that action at this time.
0 commit comments