@@ -155,31 +155,38 @@ async function apply_saved_context(
155155
156156 const currently_checked_files = workspace_provider . get_checked_files ( )
157157 if ( currently_checked_files . length > 0 ) {
158- const choice = await vscode . window . showQuickPick (
159- [
160- {
161- label : 'Replace' ,
162- description : 'Replace the current context with the selected one'
163- } ,
158+ const existing_paths_set = new Set ( existing_paths )
159+ const all_current_files_in_new_context = currently_checked_files . every (
160+ ( file ) => existing_paths_set . has ( file )
161+ )
162+
163+ if ( ! all_current_files_in_new_context ) {
164+ const choice = await vscode . window . showQuickPick (
165+ [
166+ {
167+ label : 'Replace' ,
168+ description : 'Replace the current context with the selected one'
169+ } ,
170+ {
171+ label : 'Merge' ,
172+ description : 'Merge the selected context with the current one'
173+ }
174+ ] ,
164175 {
165- label : 'Merge' ,
166- description : 'Merge the selected context with the current one'
176+ placeHolder : `How would you like to apply "${ context . name } "?`
167177 }
168- ] ,
169- {
170- placeHolder : `How would you like to apply "${ context . name } "?`
171- }
172- )
178+ )
173179
174- if ( ! choice ) {
175- return // User cancelled
176- }
180+ if ( ! choice ) {
181+ return // User cancelled
182+ }
177183
178- if ( choice . label == 'Merge' ) {
179- paths_to_apply = [
180- ...new Set ( [ ...currently_checked_files , ...existing_paths ] )
181- ]
182- message = `Merged context "${ context . name } ".`
184+ if ( choice . label == 'Merge' ) {
185+ paths_to_apply = [
186+ ...new Set ( [ ...currently_checked_files , ...existing_paths ] )
187+ ]
188+ message = `Merged context "${ context . name } ".`
189+ }
183190 }
184191 }
185192
0 commit comments