Repository: godotengine/godot
File: editor/settings/editor_settings.cpp (C++)

Code before:
}

// Shortcuts

void EditorSettings::_add_shortcut_default(const String &p_path, const Ref<Shortcut> &p_shortcut) {
	shortcuts[p_path] = p_shortcut;
}

void EditorSettings::add_shortcut(const String &p_path, const Ref<Shortcut> &p_shortcut) {
	Array use_events = p_shortcut->get_events();
	if (shortcuts.has(p_path)) {
		Ref<Shortcut> existing = shortcuts.get(p_path);
		if (!existing->has_meta("original")) {
			// Loaded from editor settings, but plugin not loaded yet.
			// Keep the events from editor settings but still override the shortcut in the shortcuts map
			use_events = existing->get_events();
		} else if (!Shortcut::is_event_array_equal(existing->get_events(), existing->get_meta("original"))) {
			// Shortcut exists and is customized - don't override with default.
			return;
		}
	}

	p_shortcut->set_meta("original", p_shortcut->get_events());
	p_shortcut->set_events(use_events);
	if (p_shortcut->get_name().is_empty()) {
		String shortcut_name = p_path.get_slice("/", 1);
		if (shortcut_name.is_empty()) {
			shortcut_name = p_path;
		}
		p_shortcut->set_name(shortcut_name);
	}
	shortcuts[p_path] = p_shortcut;
	shortcuts[p_path]->set_meta("customized", true);
}

void EditorSettings::remove_shortcut(const String &p_path) {
	shortcuts.erase(p_path);
}

bool EditorSettings::is_shortcut(const String &p_path, const Ref<InputEvent> &p_event) const {
	HashMap<String, Ref<Shortcut>>::ConstIterator E = shortcuts.find(p_path);
	ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_path + ".");

	return E->value->matches_event(p_event);
}

bool EditorSettings::has_shortcut(const String &p_path) const {
	return get_shortcut(p_path).is_valid();
}

Ref<Shortcut> EditorSettings::get_shortcut(const String &p_path) const {

Review comment (suggestion):
```suggestion
		String shortcut_name = p_path.get_slicec('/', 1);
```

Code after:
}

// Shortcuts

void EditorSettings::_add_shortcut_default(const String &p_path, const Ref<Shortcut> &p_shortcut) {
	shortcuts[p_path] = p_shortcut;
}

void EditorSettings::add_shortcut(const String &p_path, const Ref<Shortcut> &p_shortcut) {
	Array use_events = p_shortcut->get_events();
	if (shortcuts.has(p_path)) {
		Ref<Shortcut> existing = shortcuts.get(p_path);
		if (!existing->has_meta("original")) {
			// Loaded from editor settings, but plugin not loaded yet.
			// Keep the events from editor settings but still override the shortcut in the shortcuts map
			use_events = existing->get_events();
		} else if (!Shortcut::is_event_array_equal(existing->get_events(), existing->get_meta("original"))) {
			// Shortcut exists and is customized - don't override with default.
			return;
		}
	}

	p_shortcut->set_meta("original", p_shortcut->get_events());
	p_shortcut->set_events(use_events);
	if (p_shortcut->get_name().is_empty()) {
		String shortcut_name = p_path.get_slicec('/', 1);
		if (shortcut_name.is_empty()) {
			shortcut_name = p_path;
		}
		p_shortcut->set_name(shortcut_name);
	}
	shortcuts[p_path] = p_shortcut;
	shortcuts[p_path]->set_meta("customized", true);
}

void EditorSettings::remove_shortcut(const String &p_path) {
	shortcuts.erase(p_path);
}

bool EditorSettings::is_shortcut(const String &p_path, const Ref<InputEvent> &p_event) const {
	HashMap<String, Ref<Shortcut>>::ConstIterator E = shortcuts.find(p_path);
	ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_path + ".");

	return E->value->matches_event(p_event);
}

bool EditorSettings::has_shortcut(const String &p_path) const {
	return get_shortcut(p_path).is_valid();
}

Ref<Shortcut> EditorSettings::get_shortcut(const String &p_path) const {