@@ -161,27 +161,35 @@ export default class PlaygroundController {
161
161
162
162
vscode . window . onDidChangeTextEditorSelection (
163
163
async ( changeEvent : vscode . TextEditorSelectionChangeEvent ) => {
164
- if ( changeEvent ?. textEditor ?. document ?. languageId === 'mongodb' ) {
165
- // Sort lines selected as the may be mis-ordered from alt+click.
166
- const sortedSelections = (
167
- changeEvent . selections as Array < vscode . Selection >
168
- ) . sort ( ( a , b ) => ( a . start . line > b . start . line ? 1 : - 1 ) ) ;
169
-
170
- this . _selectedText = sortedSelections
171
- . map ( ( item ) => this . _getSelectedText ( item ) )
172
- . join ( '\n' ) ;
173
-
174
- const mode =
175
- await this . _languageServerController . getExportToLanguageMode ( {
176
- textFromEditor : this . _getAllText ( ) ,
177
- selection : sortedSelections [ 0 ] ,
178
- } ) ;
179
-
180
- this . _codeActionProvider . refresh ( {
164
+ if ( changeEvent ?. textEditor ?. document ?. languageId !== 'mongodb' ) {
165
+ return ;
166
+ }
167
+
168
+ // Sort lines selected as the may be mis-ordered from alt+click.
169
+ const sortedSelections = (
170
+ changeEvent . selections as Array < vscode . Selection >
171
+ ) . sort ( ( a , b ) => ( a . start . line > b . start . line ? 1 : - 1 ) ) ;
172
+
173
+ const selectedText = sortedSelections
174
+ . map ( ( item ) => this . _getSelectedText ( item ) )
175
+ . join ( '\n' ) ;
176
+
177
+ if ( selectedText === this . _selectedText ) {
178
+ return ;
179
+ }
180
+
181
+ this . _selectedText = selectedText ;
182
+
183
+ const mode =
184
+ await this . _languageServerController . getExportToLanguageMode ( {
185
+ textFromEditor : this . _getAllText ( ) ,
181
186
selection : sortedSelections [ 0 ] ,
182
- mode,
183
187
} ) ;
184
- }
188
+
189
+ this . _codeActionProvider . refresh ( {
190
+ selection : sortedSelections [ 0 ] ,
191
+ mode,
192
+ } ) ;
185
193
}
186
194
) ;
187
195
}
0 commit comments