-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make URLs in confirmation panels clickable, and underline them #3446
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c59e6b6
Cleanup: don't mess with globals in tests without resetting them
stefanhaller 6396d1c
Extract a function HandleGenericClick
stefanhaller d102f12
Make HandleGenericClick a little smarter
stefanhaller b9a75ee
Make links clickable in confirmation panels
stefanhaller 5d509ef
Underline links in confirmation panels
stefanhaller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package helpers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gookit/color" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/xo/terminfo" | ||
) | ||
|
||
func Test_underlineLinks(t *testing.T) { | ||
scenarios := []struct { | ||
name string | ||
text string | ||
expectedResult string | ||
}{ | ||
{ | ||
name: "empty string", | ||
text: "", | ||
expectedResult: "", | ||
}, | ||
{ | ||
name: "no links", | ||
text: "abc", | ||
expectedResult: "abc", | ||
}, | ||
{ | ||
name: "entire string is a link", | ||
text: "https://example.com", | ||
expectedResult: "\x1b[4mhttps://example.com\x1b[24m", | ||
}, | ||
{ | ||
name: "link preceeded and followed by text", | ||
text: "bla https://example.com xyz", | ||
expectedResult: "bla \x1b[4mhttps://example.com\x1b[24m xyz", | ||
}, | ||
{ | ||
name: "more than one link", | ||
text: "bla https://link1 blubb https://link2 xyz", | ||
expectedResult: "bla \x1b[4mhttps://link1\x1b[24m blubb \x1b[4mhttps://link2\x1b[24m xyz", | ||
}, | ||
{ | ||
name: "link in angle brackets", | ||
text: "See <https://example.com> for details", | ||
expectedResult: "See <\x1b[4mhttps://example.com\x1b[24m> for details", | ||
}, | ||
{ | ||
name: "link followed by newline", | ||
text: "URL: https://example.com\nNext line", | ||
expectedResult: "URL: \x1b[4mhttps://example.com\x1b[24m\nNext line", | ||
}, | ||
} | ||
|
||
oldColorLevel := color.ForceSetColorLevel(terminfo.ColorLevelMillions) | ||
defer color.ForceSetColorLevel(oldColorLevel) | ||
|
||
for _, s := range scenarios { | ||
t.Run(s.name, func(t *testing.T) { | ||
result := underlineLinks(s.text) | ||
assert.Equal(t, s.expectedResult, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty hacky, but we need it so that we don't cancel the bold text. I don't see a better way of doing this except by making changes to
gookit/color
.