@@ -56,7 +56,7 @@ export default class ModalDiffModal extends Component {
5656 this .messageBus .subscribe (channel, this .updateResult );
5757 }
5858
59- compareText (oldText = " " , newText = " " ) {
59+ compareText (oldText = " " , newText = " " , opts = {} ) {
6060 const oldWords = oldText .trim ().split (/ \s + / );
6161 const newWords = newText .trim ().split (/ \s + / );
6262
@@ -76,7 +76,7 @@ export default class ModalDiffModal extends Component {
7676 wordHTML = newWord;
7777 }
7878
79- if (i === newWords .length - 1 ) {
79+ if (i === newWords .length - 1 && opts . markLastWord ) {
8080 wordHTML = ` <mark class="highlight">${ wordHTML} </mark>` ;
8181 }
8282
@@ -103,24 +103,28 @@ export default class ModalDiffModal extends Component {
103103 }
104104
105105 if (result .done ) {
106- this .finalDiff = result .diff ;
106+ // this.finalDiff = result.diff;
107107 }
108108
109109 this .lastResultText = newText;
110-
111110 this .isStreaming = ! result .done ;
112111 }
113112
114113 streamNextWord () {
115114 if (this .currentWordIndex === this .words .length ) {
116- this .diff = this .finalDiff ;
115+ this .diff = this .compareText (
116+ this .args .model .selectedText ,
117+ this .suggestion ,
118+ { markLastWord: false }
119+ );
117120 }
118121
119122 if (this .currentWordIndex < this .words .length ) {
120123 this .suggestion += this .words [this .currentWordIndex ] + " " ;
121124 this .diff = this .compareText (
122125 this .args .model .selectedText ,
123- this .suggestion
126+ this .suggestion ,
127+ { markLastWord: true }
124128 );
125129
126130 this .currentWordIndex ++ ;
@@ -153,8 +157,6 @@ export default class ModalDiffModal extends Component {
153157 });
154158 } catch (e) {
155159 popupAjaxError (e);
156- } finally {
157- this .loading = false ;
158160 }
159161 }
160162
@@ -189,7 +191,8 @@ export default class ModalDiffModal extends Component {
189191 " streamable-content"
190192 }}
191193 >
192- <CookText @ rawText ={{this .diff }} class =" cooked" />
194+ {{!-- <CookText @rawText={{this.diff}} class="cooked" /> --}}
195+ {{htmlSafe this . diff}}
193196 {{!-- <div class="composer-ai-helper-modal__old-value">
194197 {{@model.selectedText}}
195198 {{!-- {{#if this.smoothStreamer.isStreaming}}
0 commit comments