Skip to content

Commit 0a5fc08

Browse files
committed
Merge branch 'release/0.11.1'
2 parents 3aec08a + 156b6ae commit 0a5fc08

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

Core/Sources/Service/RealtimeSuggestionController.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,27 +134,6 @@ public class RealtimeSuggestionController {
134134
}
135135
}
136136
}
137-
138-
Task { // Get cache ready for real-time suggestions.
139-
guard
140-
let fileURL = try? await Environment.fetchCurrentFileURL(),
141-
let (_, filespace) = try? await Workspace
142-
.fetchOrCreateWorkspaceIfNeeded(fileURL: fileURL)
143-
else { return }
144-
145-
if filespace.uti == nil {
146-
Logger.service.info("Generate cache for file.")
147-
// avoid the command get called twice
148-
filespace.uti = ""
149-
do {
150-
try await Environment.triggerAction("Real-time Suggestions")
151-
} catch {
152-
if filespace.uti?.isEmpty ?? true {
153-
filespace.uti = nil
154-
}
155-
}
156-
}
157-
}
158137
}
159138

160139
func handleHIDEvent(event: CGEvent) async {

Core/Sources/Service/SuggestionCommandHandler/PseudoCommandHandler.swift

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,28 @@ struct PseudoCommandHandler {
3939
}
4040

4141
func generateRealtimeSuggestions() async {
42+
// Can't use handler directly if content is not available.
4243
guard let editor = await getEditorContent() else {
4344
try? await Environment.triggerAction("Prefetch Suggestions")
4445
return
4546
}
47+
48+
// If no cache is available, and completion panel is not displayed, try to get it with command.
49+
if editor.uti.isEmpty, await Environment.frontmostXcodeWindowIsEditor() {
50+
try? await Environment.triggerAction("Prefetch Suggestions")
51+
return
52+
}
53+
54+
// Otherwise, get it from pseudo handler directly.
4655
let mode = UserDefaults.shared.value(for: \.suggestionPresentationMode)
47-
let handler: SuggestionCommandHandler = {
48-
switch mode {
49-
case .comment:
50-
return CommentBaseCommandHandler()
51-
case .floatingWidget:
52-
return WindowBaseCommandHandler()
53-
}
54-
}()
55-
_ = try? await handler.generateRealtimeSuggestions(editor: editor)
56+
switch mode {
57+
case .comment:
58+
let handler = CommentBaseCommandHandler()
59+
_ = try? await handler.generateRealtimeSuggestions(editor: editor)
60+
case .floatingWidget:
61+
let handler = WindowBaseCommandHandler()
62+
_ = try? await handler.generateRealtimeSuggestions(editor: editor)
63+
}
5664
}
5765

5866
func rejectSuggestions() async {

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ fi
190190
- The first run of the extension will be slow. Be patient.
191191
- The extension uses some dirty tricks to get the file and project/workspace paths. It may fail, it may be incorrect, especially when you have multiple Xcode windows running, and maybe even worse when they are in different displays. I am not sure about that though.
192192
- The suggestions are presented as C-style comments in comment mode, they may break your code if you are editing a JSON file or something.
193+
- When a real-time suggestion request is triggered, there is a chance that it may briefly block the editor. This can occur at most once for each file after each restart of the extension because the extension needs to initiate real-time suggestion by clicking an item from the menu bar. However, once a command has been executed and some information is cached, the extension will be able to trigger real-time suggestion using a different method.
193194

194195
## License
195196

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
APP_VERSION = 0.11.0
2-
APP_BUILD = 80
1+
APP_VERSION = 0.11.1
2+
APP_BUILD = 81

appcast.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
33
<channel>
44
<title>Copilot for Xcode</title>
5+
6+
<item>
7+
<title>0.11.1</title>
8+
<pubDate>Mon, 10 Apr 2023 19:04:48 +0800</pubDate>
9+
<sparkle:version>81</sparkle:version>
10+
<sparkle:shortVersionString>0.11.1</sparkle:shortVersionString>
11+
<sparkle:minimumSystemVersion>12.0</sparkle:minimumSystemVersion>
12+
<sparkle:releaseNotesLink>
13+
https://github.com/intitni/CopilotForXcode/releases/tag/0.11.1
14+
</sparkle:releaseNotesLink>
15+
<enclosure url="https://github.com/intitni/CopilotForXcode/releases/download/0.11.1/Copilot.for.Xcode.app.zip" length="19038951" type="application/octet-stream" sparkle:edSignature="fp0vSUUH7JyIeyeUrMa9p6u3UFkgl5EeNjkmuzPL9hTmjfkVR77IM/9BIe2730OYy7PR429ngSjWPS+PGIT0Bg=="/>
16+
</item>
17+
518
<item>
619
<title>0.11.0</title>
720
<pubDate>Sat, 08 Apr 2023 23:32:22 +0800</pubDate>

0 commit comments

Comments
 (0)