File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ private void InjectBG(boolean inject) {
154154 universal_buffer .setLength (0 );
155155 universal_buffer .append (data , 0 , removeSt -1 );
156156 universal_buffer .append (data , removeEd +1 , length );
157- tweaker .setDocumentText (universal_buffer );
157+ tweaker .setDocumentText (universal_buffer , -( removeEd - removeSt + 2 ) );
158158 }
159159 }
160160 if (!removed ) {
@@ -170,7 +170,7 @@ private void InjectBG(boolean inject) {
170170 universal_buffer .append (data , 0 , insIdx );
171171 universal_buffer .append (text );
172172 universal_buffer .append (data , insIdx , length );
173- tweaker .setDocumentText (universal_buffer );
173+ tweaker .setDocumentText (universal_buffer , text . length () );
174174 }
175175 }
176176 }
Original file line number Diff line number Diff line change @@ -552,9 +552,15 @@ private void doIt() {
552552 }
553553 }
554554
555- void setDocumentText (CharSequence text ) {
555+ void setDocumentText (CharSequence text , int selOffset ) {
556556 if (mDocument !=null ){
557- WriteCommandAction .runWriteCommandAction (mProject , ()-> mDocument .setText (text ));
557+ WriteCommandAction .runWriteCommandAction (mProject , ()-> {
558+ mDocument .setText (text );
559+ if (currentStart <currentEnd && currentStart >=0 ) {
560+ currentStart +=selOffset ;
561+ currentEnd +=selOffset ;
562+ }
563+ });
558564 }
559565 }
560566
You can’t perform that action at this time.
0 commit comments