@@ -901,25 +901,23 @@ async function initRepository() {
901
901
const target = $ ( this ) . data ( 'target' ) ;
902
902
const quote = $ ( `#comment-${ target } ` ) . text ( ) . replace ( / \n / g, '\n> ' ) ;
903
903
const content = `> ${ quote } \n\n` ;
904
-
905
- let $content ;
904
+ let $simplemde = autoSimpleMDE ;
906
905
if ( $ ( this ) . hasClass ( 'quote-reply-diff' ) ) {
907
906
const $parent = $ ( this ) . closest ( '.comment-code-cloud' ) ;
908
907
$parent . find ( 'button.comment-form-reply' ) . trigger ( 'click' ) ;
909
- $content = $parent . find ( '[name="content"]' ) ;
910
- if ( $content . val ( ) !== '' ) {
911
- $content . val ( `${ $content . val ( ) } \n\n${ content } ` ) ;
912
- } else {
913
- $content . val ( `${ content } ` ) ;
914
- }
915
- $content . focus ( ) ;
916
- } else if ( autoSimpleMDE !== null ) {
917
- if ( autoSimpleMDE . value ( ) !== '' ) {
918
- autoSimpleMDE . value ( `${ autoSimpleMDE . value ( ) } \n\n${ content } ` ) ;
908
+ $simplemde = $parent . find ( '[name="content"]' ) . data ( 'simplemde' ) ;
909
+ }
910
+ if ( $simplemde !== null ) {
911
+ if ( $simplemde . value ( ) !== '' ) {
912
+ $simplemde . value ( `${ $simplemde . value ( ) } \n\n${ content } ` ) ;
919
913
} else {
920
- autoSimpleMDE . value ( `${ content } ` ) ;
914
+ $simplemde . value ( `${ content } ` ) ;
921
915
}
922
916
}
917
+ requestAnimationFrame ( ( ) => {
918
+ $simplemde . codemirror . focus ( ) ;
919
+ $simplemde . codemirror . setCursor ( $simplemde . codemirror . lineCount ( ) , 0 ) ;
920
+ } ) ;
923
921
event . preventDefault ( ) ;
924
922
} ) ;
925
923
@@ -1082,8 +1080,10 @@ async function initRepository() {
1082
1080
$textarea . val ( $rawContent . text ( ) ) ;
1083
1081
$simplemde . value ( $rawContent . text ( ) ) ;
1084
1082
}
1085
- $textarea . focus ( ) ;
1086
- $simplemde . codemirror . focus ( ) ;
1083
+ requestAnimationFrame ( ( ) => {
1084
+ $textarea . focus ( ) ;
1085
+ $simplemde . codemirror . focus ( ) ;
1086
+ } ) ;
1087
1087
event . preventDefault ( ) ;
1088
1088
} ) ;
1089
1089
0 commit comments