Repository: CodeEditApp/CodeEdit
File: CodeEditModules/Modules/CodeFile/src/TextView/CodeEditorTextView.swift (Swift)

Code before:

        return menu
    }

    func gitMenu(_ menu: NSMenu) -> NSMenu {
        menu.insertItem(withTitle: "Show Last Change For Line",
                        action: nil,
                        keyEquivalent: "",
                        at: 9)

        menu.insertItem(withTitle: "Create Code Snippet...",
                        action: nil,
                        keyEquivalent: "",
                        at: 10)

        menu.insertItem(withTitle: "Add Pull Request Discussion to Current Line",
                        action: nil,
                        keyEquivalent: "",
                        at: 11)

        menu.insertItem(.separator(), at: 12)

        return menu
    }

    func removeSubMenus(_ menu: NSMenu) -> NSMenu {
        // remove unwanted "Font" menu and its submenus

        if let substitutionsItem = menu.item(withTitle: "Substitutions") {
            menu.removeItem(substitutionsItem)
        }

        if let transformationsItem = menu.item(withTitle: "Transformations") {
            menu.removeItem(transformationsItem)
        }

        if let speechItem = menu.item(withTitle: "Speech") {
            menu.removeItem(speechItem)
        }

        if let shareItem = menu.item(withTitle: "Share") {
            menu.removeItem(shareItem)
        }

        if let searchGoogleItem = menu.item(withTitle: "Search With Google") {
            menu.removeItem(searchGoogleItem)
        }

        if let fontMenuItem = menu.item(withTitle: "Font") {
            menu.removeItem(fontMenuItem)
        }

Review comment (refactor):
How does this work/perform on non-english systems?
is it maybe better to not use the `super.menu(for: event)` to remove this.
This means that we must make a custom `cut`, `copy`, `paste`.

Code after:
        return menu
    }

    func gitMenu(_ menu: NSMenu) -> NSMenu {
        menu.insertItem(withTitle: "Show Last Change For Line",
                        action: nil,
                        keyEquivalent: "",
                        at: 8)

        menu.insertItem(withTitle: "Create Code Snippet...",
                        action: nil,
                        keyEquivalent: "",
                        at: 9)

        menu.insertItem(withTitle: "Add Pull Request Discussion to Current Line",
                        action: nil,
                        keyEquivalent: "",
                        at: 10)

        menu.insertItem(.separator(), at: 11)

        return menu
    }

    /// This removes the default menu items in the context menu based on their name..
    ///
    /// The only problem currently is how well it would work with other languages.
    func removeMenus(_ menu: NSMenu) -> NSMenu {
        for action in ["No Guesses Found",
                       "Learn Spelling",
                       "Ignore Spelling",
                       "Search With Google",
                       "Translate",
                       "Spelling and Grammar",
                       "Substitutions",
                       "Transformations",
                       "Speech",
                       "Share",
                       "Search With Google",
                       "Font",
                       "Services"] {
            let index = menu.indexOfItem(withTitle: action)
            if index > -1 {
                menu.removeItem(at: index)
            }
        }

        return menu
    }

}