CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

✨ Setting to hide files and folders from project navigator based on user defined glob patterns

Open devmoath opened this issue 1 year ago • 9 comments

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

Most of the IDEs and code editors hide the .git folder by default, I believe it's a good idea to follow the same behavior in CodeEdit as well.

Describe alternatives you've considered

Well, another way to implement this feature is by categorize the project tree and add ignored folders/hidden folders category which .git folder will be within it.

Additional context

this is what looks like when you open project contains git

CleanShot_2565-09-02_at_13 43 29

Edit by @austincondiff:

As discussed in Discord, we will have something similar to this in VS Code where we can exclude files and folders based on user defined glob patterns.

image

devmoath avatar Sep 02 '22 16:09 devmoath

Maybe have the folder grayed out? Or have an option which says "Show hidden folders"?

Muhammed9991 avatar Sep 02 '22 17:09 Muhammed9991

@Muhammed9991 I wonder if this should be a separate setting for this like so...

  • Hide files and folders:
    • List of user-defined glob patterns
  • Hide hidden files and folders:
    • Show
    • Hide
    • Use system setting from Finder

austincondiff avatar Sep 02 '22 18:09 austincondiff

I like this idea more. Gives the user more flexibility about which files they want to hide. Especially good for larger projects.

Muhammed9991 avatar Sep 02 '22 18:09 Muhammed9991

that's even better, I liked the idea 👍

devmoath avatar Sep 02 '22 18:09 devmoath

Awesome, I said I'd take this on in Discord so I should have a draft PR ready in a couple days 👍

thecoolwinter avatar Sep 08 '22 03:09 thecoolwinter

This is taking me longer than expected, and I'm focusing on editor changes in the text view right now. If anyone wants to take this on DM me on Discord and I can share the resources I have with you on glob patterns, etc.

If no one takes this on by the time I'm done with my other things I'll continue working on this issue.

thecoolwinter avatar Sep 29 '22 21:09 thecoolwinter

Got started working on a component to let the user specify which folders they want to ignore. This is just to get the ball rolling on this issue. Let me know what you guys think, I tried copying the design from the macOS settings menu for lists. (The compression removes the row highlights when the modal is open)

Aug-26-2023 22-30-06

FastestMolasses avatar Aug 27 '23 05:08 FastestMolasses

@FastestMolasses This looks really good. We are going to need this for #1462 and #1463 as well.

austincondiff avatar Dec 04 '23 15:12 austincondiff

@austincondiff Hey, just getting back to this! Here's the code written for it. I've placed it in a folder called Components in my branch, not sure where's the best place to put the code.

import SwiftUI

struct ListTableItem: Identifiable {
    let id = UUID()
    var name: String
}

struct ContentView: View {
    @State private var items = [ListTableItem]()
    @State private var showingModal = false
    @State private var selection: ListTableItem.ID?

    var body: some View {
        VStack {
            Table(items, selection: $selection) {
                TableColumn("Items", value: \.name)
            }
        }
        .paneToolbar {
            HStack(spacing: 2) {
                Button {
                    showingModal = true
                } label: {
                    Image(systemName: "plus")
                }

                Divider()
                    .frame(minHeight: 15)

                Button {
                    removeItem()
                } label: {
                    Image(systemName: "minus")
                }
                .disabled(selection == nil)
                .opacity(selection == nil ? 0.5 : 1)
            }
            Spacer()
        }
        .sheet(isPresented: $showingModal) {
            NewListTableItemView { text in
                items.append(ListTableItem(name: text))
                showingModal = false
            }
        }
        .cornerRadius(6)
    }

    private func removeItem() {
        guard let selectedId = selection else { return }
        items.removeAll(where: { $0.id == selectedId })
        selection = nil
    }
}

struct NewListTableItemView: View {
    @State private var text = ""
    var completion: (String) -> Void

    var body: some View {
        VStack {
            Text("Enter new item name")
            TextField("Name", text: $text)
                .textFieldStyle(.roundedBorder)
            Button("Add") {
                if !text.isEmpty {
                    completion(text)
                }
            }
        }
        .padding()
    }
}

struct ListTablePreview: PreviewProvider {
    static var previews: some View {
        ContentView()
            .environmentObject(DebugAreaTabViewModel())
    }
}

FastestMolasses avatar Jan 06 '24 02:01 FastestMolasses