Skip to content

Commit c27acdf

Browse files
committed
Git Clone: Add automatic pasting
If you have 'valid' git url in your clipboard when opening the clone view, it now automatically pastes it to the textfield
1 parent 5cfdd7a commit c27acdf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CodeEdit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
</dict>
4646
</array>
4747
<key>GitHash</key>
48-
<string>Placeholder</string>
48+
<string>5cfdd7ad2469974d29a51b0c6fca7f68bc96e943</string>
4949
</dict>
5050
</plist>

CodeEditModules/Modules/GitClone/src/GitCloneView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public struct GitCloneView: View {
100100
.padding(.top, 20)
101101
.padding(.horizontal, 20)
102102
.padding(.bottom, 16)
103+
.onAppear {
104+
self.checkClipboard(textFieldText: &repoUrlStr)
105+
}
103106
}
104107
}
105108
}
@@ -151,4 +154,11 @@ extension GitCloneView {
151154
}
152155
return false
153156
}
157+
func checkClipboard(textFieldText: inout String) {
158+
if let maybeUrl = NSPasteboard.general.pasteboardItems?.first?.string(forType: .string) {
159+
if isValid(url: maybeUrl) {
160+
textFieldText = maybeUrl
161+
}
162+
}
163+
}
154164
}

0 commit comments

Comments
 (0)