Skip to content

Commit 825f5c0

Browse files
committed
Use AutoRenderHyperLinks in confirmation view
This allows us to get rid of the underlineLinks function.
1 parent 26e3a93 commit 825f5c0

File tree

3 files changed

+2
-86
lines changed

3 files changed

+2
-86
lines changed

pkg/gui/controllers/helpers/confirmation_helper.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
221221
confirmationView.RenderTextArea()
222222
} else {
223223
self.c.ResetViewOrigin(confirmationView)
224-
self.c.SetViewContent(confirmationView, style.AttrBold.Sprint(underlineLinks(opts.Prompt)))
224+
self.c.SetViewContent(confirmationView, style.AttrBold.Sprint(opts.Prompt))
225225
}
226226

227227
self.setKeyBindings(cancel, opts)
@@ -233,28 +233,6 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
233233
self.c.Context().Push(self.c.Contexts().Confirmation)
234234
}
235235

236-
func underlineLinks(text string) string {
237-
result := ""
238-
remaining := text
239-
for {
240-
linkStart := strings.Index(remaining, "https://")
241-
if linkStart == -1 {
242-
break
243-
}
244-
245-
linkEnd := strings.IndexAny(remaining[linkStart:], " \n>")
246-
if linkEnd == -1 {
247-
linkEnd = len(remaining)
248-
} else {
249-
linkEnd += linkStart
250-
}
251-
underlinedLink := style.PrintSimpleHyperlink(remaining[linkStart:linkEnd])
252-
result += remaining[:linkStart] + underlinedLink
253-
remaining = remaining[linkEnd:]
254-
}
255-
return result + remaining
256-
}
257-
258236
func (self *ConfirmationHelper) setKeyBindings(cancel goContext.CancelFunc, opts types.CreatePopupPanelOpts) {
259237
var onConfirm func() error
260238
if opts.HandleConfirmPrompt != nil {

pkg/gui/controllers/helpers/confirmation_helper_test.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

pkg/gui/views.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func (gui *Gui) createAllViews() error {
158158

159159
gui.Views.Confirmation.Visible = false
160160
gui.Views.Confirmation.Editor = gocui.EditorFunc(gui.promptEditor)
161+
gui.Views.Confirmation.AutoRenderHyperLinks = true
161162

162163
gui.Views.Suggestions.Visible = false
163164

0 commit comments

Comments
 (0)