Bug 482711 - [launch] Creating the first launch config does not notify
ILaunchConfigurationListener.launchConfigurationAdded()

Change-Id: I02885791a58c9fe7e800413931383d8b2210bd2f
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index caf10c2..aae9eab 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -179,6 +179,10 @@
 	 */
 	private StepFilterManager fStepFilterManager = null;
 
+	public LaunchManager() {
+		getAllLaunchConfigurations();
+	}
+
 	/**
 	 * Notifies a launch config listener in a safe runnable to handle
 	 * exceptions.
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
index 5447884..1f16e87 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -1873,4 +1873,35 @@
 		assertTrue(t2.isPrototype());
 	}
 
+	@Test
+	public void testNewInstanceNotifiesListener() throws CoreException {
+		ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+		final ArrayList<String> added = new ArrayList<>();
+		ILaunchConfigurationListener listener = new ILaunchConfigurationListener() {
+
+			@Override
+			public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+
+			}
+
+			@Override
+			public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+
+			}
+
+			@Override
+			public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+				added.add("Launch Configuration added");
+
+			}
+		};
+		launchManager.addLaunchConfigurationListener(listener);
+		String typeId = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType";
+
+		ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(typeId);
+		type.newInstance(null, "new-lc").doSave();
+		assertEquals(1, added.size());
+		assertEquals("Launch Configuration added", added.get(0));
+
+	}
 }