Skip to content

Commit 63e78e3

Browse files
committed
Add logs to TabToAcceptSuggestion
1 parent 0030f6a commit 63e78e3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Core/Sources/KeyBindingManager/TabToAcceptSuggestion.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class TabToAcceptSuggestion {
4747

4848
init() {
4949
_ = ThreadSafeAccessToXcodeInspector.shared
50-
50+
5151
hook.add(
5252
.init(
5353
eventsOfInterest: [.keyDown],
@@ -103,10 +103,15 @@ final class TabToAcceptSuggestion {
103103
let tab = 48
104104
let esc = 53
105105

106+
Logger.service.info("TabToAcceptSuggestion: \(keycode)")
107+
106108
switch keycode {
107109
case tab:
110+
Logger.service.info("TabToAcceptSuggestion: Tab")
111+
108112
guard let fileURL = ThreadSafeAccessToXcodeInspector.shared.activeDocumentURL
109113
else {
114+
Logger.service.info("TabToAcceptSuggestion: No active document")
110115
return .unchanged
111116
}
112117

@@ -158,23 +163,28 @@ final class TabToAcceptSuggestion {
158163
checkKeybinding(),
159164
canTapToAcceptSuggestion
160165
else {
166+
Logger.service.info("TabToAcceptSuggestion: Feature not available")
161167
return .unchanged
162168
}
163169

164170
guard ThreadSafeAccessToXcodeInspector.shared.activeXcode != nil
165171
else {
172+
Logger.service.info("TabToAcceptSuggestion: Xcode not found")
166173
return .unchanged
167174
}
168175
guard let editor = ThreadSafeAccessToXcodeInspector.shared.focusedEditor
169176
else {
177+
Logger.service.info("TabToAcceptSuggestion: No editor found")
170178
return .unchanged
171179
}
172180
guard let filespace = workspacePool.fetchFilespaceIfExisted(fileURL: fileURL)
173181
else {
182+
Logger.service.info("TabToAcceptSuggestion: No file found")
174183
return .unchanged
175184
}
176185
guard let presentingSuggestion = filespace.presentingSuggestion
177186
else {
187+
Logger.service.info("TabToAcceptSuggestion: No Suggestions found")
178188
return .unchanged
179189
}
180190

@@ -188,9 +198,11 @@ final class TabToAcceptSuggestion {
188198
)
189199

190200
if shouldAcceptSuggestion {
201+
Logger.service.info("TabToAcceptSuggestion: Accept")
191202
Task { await commandHandler.acceptSuggestion() }
192203
return .discarded
193204
} else {
205+
Logger.service.info("TabToAcceptSuggestion: Should not accept")
194206
return .unchanged
195207
}
196208
case esc:
@@ -248,6 +260,7 @@ extension TabToAcceptSuggestion {
248260
// If entering a tab doesn't invalidate the suggestion, just let the user type the tab.
249261
// else, accept the suggestion and discard the tab.
250262
guard !presentingSuggestionText.hasPrefix(contentAfterTab) else {
263+
Logger.service.info("TabToAcceptSuggestion: Space for tab")
251264
return false
252265
}
253266
return true

0 commit comments

Comments
 (0)