Skip to content

Commit

Permalink
Release 0.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 1, 2024
1 parent d0224e8 commit 71b6720
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "copilot.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
12 changes: 12 additions & 0 deletions ExtensionService/Assets.xcassets/CopilotLogo.imageset/copilot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public final class GitHubCopilotService: GitHubCopilotBaseService,
tabSize: tabSize,
insertSpaces: !usesTabsForIndentation
),
context: .init(triggerKind: .invoked)
context: .init(triggerKind: .automatic)
)))
.items
.compactMap { (item: _) -> CodeSuggestion? in
Expand Down
107 changes: 85 additions & 22 deletions Tool/Sources/SharedUIComponents/AsyncCodeBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,61 @@ public struct AsyncCodeBlock: View {
return "Hold ⌥ for full suggestion"
}

@ScaledMetric var ellipsisPadding: CGFloat = 5

@ScaledMetric var keyPadding: Double = 3.0

@ViewBuilder
func keyBackground(content: () -> some View) -> some View {
content()
.padding(.horizontal, keyPadding)
.background(
RoundedRectangle(cornerRadius: 2)
.stroke(foregroundColor, lineWidth: 1)
.foregroundColor(.clear)
.frame(
minWidth: fontHeight,
minHeight: fontHeight,
maxHeight: fontHeight
)
)
}

@ViewBuilder
var optionKey: some View {
keyBackground {
Image(systemName: "option")
.resizable()
.renderingMode(.template)
.scaledToFit()
.frame(height: font.capHeight)
}
}

@ViewBuilder
var popoverContent: some View {
HStack {
if isExpanded {
Text("Press")
optionKey
keyBackground {
Text("tab")
.font(.init(font))
}
Text("to accept full suggestion")
} else {
Text("Hold")
optionKey
Text("for full suggestion")
}
}
.padding(8)
.font(.body)
.fixedSize()
}

@ScaledMetric var iconPadding: CGFloat = 9.0
@ScaledMetric var iconSpacing: CGFloat = 6.0
@ScaledMetric var optionPadding: CGFloat = 0.5

@ViewBuilder
var contentView: some View {
Expand All @@ -116,30 +170,39 @@ public struct AsyncCodeBlock: View {
.foregroundColor(foregroundTextColor)
.lineSpacing(lineSpacing) // This only has effect if a line wraps
if lines.count > 1 {
Image(systemName: "ellipsis")
.renderingMode(.template)
.foregroundColor(foregroundTextColor)
.padding(.horizontal, ellipsisPadding)
.background(
RoundedRectangle(cornerRadius: 12)
.fill(Color.gray.opacity(isExpanded ? 0.1 : 0.4))
.frame(height: fontHeight * 0.75)
)
.popover(isPresented: $isHovering) {
Text(hintText)
.font(.body)
.padding(8)
.fixedSize()
}
.task {
isHovering = !completionHintShown
completionHintShown = true
}
HStack(spacing: iconSpacing) {
Image("CopilotLogo")
.resizable()
.renderingMode(.template)
.scaledToFit()
Image(systemName: "option")
.resizable()
.renderingMode(.template)
.scaledToFit()
.padding(.vertical, optionPadding)
}
.frame(height: lineHeight * 0.7)
.padding(.horizontal, iconPadding)
.background(
Capsule()
.fill(foregroundColor.opacity(isExpanded ? 0.1 : 0.2))
.frame(height: lineHeight)
)
.frame(height: lineHeight) // Moves popover attachment
.popover(isPresented: $isHovering) {
popoverContent
}
.task {
isHovering = !completionHintShown
completionHintShown = true
}
}
}
.background(currentLineBackgroundColor ?? backgroundColor)
.frame(height: lineHeight)
.background(
HalfCapsule().fill(currentLineBackgroundColor ?? backgroundColor)
)
.padding(.leading, firstLineIndent)
.frame(minHeight: lineHeight)
.onHover { hovering in
guard hovering != isHovering else { return }
withAnimation {
Expand Down
19 changes: 19 additions & 0 deletions Tool/Sources/SharedUIComponents/HalfCapsule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import SwiftUI

public struct HalfCapsule: Shape {
public func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: .init(x:0, y: 0))
path.addLine(to: .init(x:rect.width, y:0))
path.addArc(
center: .init(x: rect.width - rect.height/2, y: rect.height/2),
radius: rect.height/2,
startAngle: .degrees(270),
endAngle: .degrees(90),
clockwise: false
)
path.addLine(to: CGPoint(x:0, y:rect.height))
path.addLine(to: CGPoint(x:0, y:rect.height))
}
}
}

0 comments on commit 71b6720

Please sign in to comment.