@@ -132,7 +132,7 @@ export class SearchEditorInput extends EditorInput {
132
132
}
133
133
134
134
override async save ( group : GroupIdentifier , options ?: ITextFileSaveOptions ) : Promise < EditorInput | undefined > {
135
- if ( ( ( await this . getModels ( ) ) . resultsModel ) . isDisposed ( ) ) { return ; }
135
+ if ( ( ( await this . resolveModels ( ) ) . resultsModel ) . isDisposed ( ) ) { return ; }
136
136
137
137
if ( this . backingUri ) {
138
138
await this . textFileService . write ( this . backingUri , await this . serializeForDisk ( ) , options ) ;
@@ -149,29 +149,33 @@ export class SearchEditorInput extends EditorInput {
149
149
}
150
150
151
151
private async serializeForDisk ( ) {
152
- const { configurationModel, resultsModel } = await this . getModels ( ) ;
152
+ const { configurationModel, resultsModel } = await this . resolveModels ( ) ;
153
153
return serializeSearchConfiguration ( configurationModel . config ) + '\n' + resultsModel . getValue ( ) ;
154
154
}
155
155
156
156
private configChangeListenerDisposable : IDisposable | undefined ;
157
157
private registerConfigChangeListeners ( model : SearchConfigurationModel ) {
158
158
this . configChangeListenerDisposable ?. dispose ( ) ;
159
-
160
159
if ( ! this . isDisposed ( ) ) {
161
160
this . configChangeListenerDisposable = model . onConfigDidUpdate ( ( ) => {
162
- this . _onDidChangeLabel . fire ( ) ;
161
+ const oldName = this . getName ( ) ;
162
+ if ( oldName !== this . getName ( ) ) {
163
+ this . _onDidChangeLabel . fire ( ) ;
164
+ }
163
165
this . memento . getMemento ( StorageScope . WORKSPACE , StorageTarget . MACHINE ) . searchConfig = model . config ;
164
166
} ) ;
165
-
166
167
this . _register ( this . configChangeListenerDisposable ) ;
167
168
}
168
169
}
169
170
170
- async getModels ( ) {
171
+ async resolveModels ( ) {
171
172
return this . model . resolve ( ) . then ( data => {
173
+ const oldName = this . getName ( ) ;
172
174
this . _cachedResultsModel = data . resultsModel ;
173
175
this . _cachedConfigurationModel = data . configurationModel ;
174
- this . _onDidChangeLabel . fire ( ) ;
176
+ if ( oldName !== this . getName ( ) ) {
177
+ this . _onDidChangeLabel . fire ( ) ;
178
+ }
175
179
this . registerConfigChangeListeners ( data . configurationModel ) ;
176
180
return data ;
177
181
} ) ;
@@ -211,8 +215,11 @@ export class SearchEditorInput extends EditorInput {
211
215
}
212
216
213
217
setDirty ( dirty : boolean ) {
218
+ const wasDirty = this . dirty ;
214
219
this . dirty = dirty ;
215
- this . _onDidChangeDirty . fire ( ) ;
220
+ if ( wasDirty !== dirty ) {
221
+ this . _onDidChangeDirty . fire ( ) ;
222
+ }
216
223
}
217
224
218
225
override isDirty ( ) {
@@ -253,7 +260,7 @@ export class SearchEditorInput extends EditorInput {
253
260
}
254
261
255
262
async setMatchRanges ( ranges : Range [ ] ) {
256
- this . oldDecorationsIDs = ( await this . getModels ( ) ) . resultsModel . deltaDecorations ( this . oldDecorationsIDs , ranges . map ( range =>
263
+ this . oldDecorationsIDs = ( await this . resolveModels ( ) ) . resultsModel . deltaDecorations ( this . oldDecorationsIDs , ranges . map ( range =>
257
264
( { range, options : { description : 'search-editor-find-match' , className : SearchEditorFindMatchClass , stickiness : TrackedRangeStickiness . NeverGrowsWhenTypingAtEdges } } ) ) ) ;
258
265
}
259
266
@@ -265,11 +272,11 @@ export class SearchEditorInput extends EditorInput {
265
272
266
273
if ( this . backingUri ) {
267
274
const { config, text } = await this . instantiationService . invokeFunction ( parseSavedSearchEditor , this . backingUri ) ;
268
- const { resultsModel, configurationModel } = await this . getModels ( ) ;
275
+ const { resultsModel, configurationModel } = await this . resolveModels ( ) ;
269
276
resultsModel . setValue ( text ) ;
270
277
configurationModel . updateConfig ( config ) ;
271
278
} else {
272
- ( await this . getModels ( ) ) . resultsModel . setValue ( '' ) ;
279
+ ( await this . resolveModels ( ) ) . resultsModel . setValue ( '' ) ;
273
280
}
274
281
super . revert ( group , options ) ;
275
282
this . setDirty ( false ) ;
@@ -287,7 +294,7 @@ export class SearchEditorInput extends EditorInput {
287
294
}
288
295
289
296
private async suggestFileName ( ) : Promise < URI > {
290
- const query = ( await this . getModels ( ) ) . configurationModel . config . query ;
297
+ const query = ( await this . resolveModels ( ) ) . configurationModel . config . query ;
291
298
const searchFileName = ( query . replace ( / [ ^ \w \- _ ] + / g, '_' ) || 'Search' ) + SEARCH_EDITOR_EXT ;
292
299
return joinPath ( await this . fileDialogService . defaultFilePath ( this . pathService . defaultUriScheme ) , searchFileName ) ;
293
300
}
0 commit comments