Skip to content

Commit e25a90c

Browse files
authored
Files & folders dropped on Welcome Window are opened (#1169)
Files & folders dropped on welcomewindow are opened Signed-off-by: Wouter01 <wouterhennen@gmail.com>
1 parent 3da85b6 commit e25a90c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CodeEdit/Features/Documents/WorkspaceDocument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import CodeEditKit
9090
workspace: self
9191
)
9292

93-
windowController.shouldCascadeWindows = false
93+
windowController.shouldCascadeWindows = true
9494
windowController.window?.setFrameAutosaveName(self.fileURL?.absoluteString ?? "Untitled")
9595
self.addWindowController(windowController)
9696

CodeEdit/Features/Welcome/Views/WelcomeWindowView.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,21 @@ struct WelcomeWindowView: View {
3737
.frame(width: 300)
3838
}
3939
.edgesIgnoringSafeArea(.top)
40+
.onDrop(of: [.fileURL], isTargeted: .constant(true)) { providers in
41+
NSApp.activate(ignoringOtherApps: true)
42+
providers.forEach {
43+
_ = $0.loadDataRepresentation(for: .fileURL) { data, _ in
44+
if let data, let url = URL(dataRepresentation: data, relativeTo: nil) {
45+
Task {
46+
try? await CodeEditDocumentController
47+
.shared
48+
.openDocument(withContentsOf: url, display: true)
49+
}
50+
}
51+
}
52+
}
53+
dismissWindow()
54+
return true
55+
}
4056
}
4157
}

0 commit comments

Comments
 (0)