@@ -149,20 +149,25 @@ function M.get_profile(profile_name, dap_config_name)
149149 return M .project_profiles [dap_config_name ][profile_name ]
150150end
151151
152- --- @param dap_config_name_key string
152+ --- @param dap_config_name string
153153--- @return table<string , Profile>
154154function M .get_all_profiles (dap_config_name )
155155 return M .project_profiles [dap_config_name ] or {}
156156end
157157--- @param dap_config_name string
158158--- @param profile_name string
159159function M .set_active_profile (profile_name , dap_config_name )
160+ if not M .__has_profile (profile_name , dap_config_name ) then
161+ return
162+ end
163+
160164 for _ , profile in pairs (M .project_profiles [dap_config_name ]) do
161165 if profile .is_active then
162166 profile .is_active = false
163167 break
164168 end
165169 end
170+
166171 M .project_profiles [dap_config_name ][profile_name ].is_active = true
167172 M .save ()
168173end
@@ -200,10 +205,25 @@ end
200205--- @param dap_config_name string
201206--- @param profile_name string
202207function M .delete_profile (profile_name , dap_config_name )
208+ if not M .__has_profile (profile_name , dap_config_name ) then
209+ return
210+ end
211+
203212 M .project_profiles [dap_config_name ][profile_name ] = nil
204213 M .save ()
205214end
206215
216+ --- Returns true if a profile exists by given name
217+ --- @param profile_name string
218+ --- @param dap_config_name string
219+ function M .__has_profile (profile_name , dap_config_name )
220+ if M .project_profiles [dap_config_name ][profile_name ] then
221+ return true
222+ end
223+
224+ return false
225+ end
226+
207227--- @type Profile
208228M .Profile = Profile
209229
0 commit comments