-
Notifications
You must be signed in to change notification settings - Fork 123
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
text: add correct handling of hyperlink escape sequences (https://gis… #256
Conversation
Pull Request Test Coverage Report for Build 4268303129
💛 - Coveralls |
Makefile
Outdated
@@ -11,7 +11,7 @@ bench: | |||
go test -bench=. -benchmem | |||
|
|||
cyclo: | |||
gocyclo -over 13 ./*/*.go | |||
gocyclo -over 18 ./*/*.go |
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.
Please don't do this. Increasing it to make this step pass is not the ideal solution, can you find a way to refactor the functionality (break logic into new functions if possible)?
Or if it is too much to do, I don't mind ignoring this comment - I can fix it later and refactor the functions to stay within complexity limits I've set for myself.
list/render.go
Outdated
// - Is | ||
// - Known | ||
// - The Dark Tower | ||
// - The Gunslinger |
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.
Please undo this and all the other changes to comment blocks.
@@ -74,7 +88,7 @@ func LongestLineLen(str string) int { | |||
maxLength = currLength | |||
} | |||
currLength = 0 | |||
} else if !isEscSeq { | |||
} else if !isEscSeq && !isEscSeqAlt { | |||
currLength += RuneWidth(c) | |||
} | |||
} |
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.
Can you add unit-tests for the changes? Call the affected functions with text containing an escape sequence with a URL as defined in the spec linked?
text/string.go
Outdated
EscapeReset = EscapeStart + "0" + EscapeStop | ||
EscapeStart = "\x1b[" | ||
EscapeStartAlt = "\x1b]8" | ||
EscapeStartRune = rune(27) // \x1b | ||
EscapeStop = "m" | ||
EscapeStopRune = 'm' | ||
EscapeStopRuneAlt = '\\' |
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.
I wonder if there is a better way to do this for now and the future, in case another pattern needs to be supported. But this is a good start.
Hi Naveen,
I'll see what I can do. I thought about refactoring, but at the time it seemed to be taking too much time.
Thanks,
Vladimir.
On Tuesday, February 21, 2023 at 05:16:53 PM EST, Naveen Mahalingam ***@***.***> wrote:
@jedib0t requested changes on this pull request.
________________________________
In Makefile:
@@ -11,7 +11,7 @@ bench:
go test -bench=. -benchmem
cyclo:
- gocyclo -over 13 ./*/*.go
+ gocyclo -over 18 ./*/*.go
Please don't do this. Increasing it to make this step pass is not the ideal solution, can you find a way to refactor the functionality (break logic into new functions if possible)?
Or if it is too much to do, I don't mind ignoring this comment - I can fix it later and refactor the functions to stay within complexity limits I've set for myself.
________________________________
In list/render.go:
-// * Is
-// * Coming
-// * This
-// * Is
-// * Known
-// * The Dark Tower
-// * The Gunslinger
+// - Game Of Thrones
+// - Winter
+// - Is
+// - Coming
+// - This
+// - Is
+// - Known
+// - The Dark Tower
+// - The Gunslinger
Please undo this and all the other changes to comment blocks.
________________________________
In text/string.go:
@@ -74,7 +88,7 @@ func LongestLineLen(str string) int {
maxLength = currLength
}
currLength = 0
- } else if !isEscSeq {
+ } else if !isEscSeq && !isEscSeqAlt {
currLength += RuneWidth(c)
}
}
Can you add unit-tests for the changes? Call the affected functions with text containing an escape sequence with a URL as defined in the spec linked?
________________________________
In text/string.go:
+ EscapeReset = EscapeStart + "0" + EscapeStop
+ EscapeStart = "\x1b["
+ EscapeStartAlt = "\x1b]8"
+ EscapeStartRune = rune(27) // \x1b
+ EscapeStop = "m"
+ EscapeStopRune = 'm'
+ EscapeStopRuneAlt = '\\'
I wonder if there is a better way to do this for now and the future, in case another pattern needs to be supported. But this is a good start.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hello Naveen,
I have refactored the string.go code to bring the complexity down. It now passes the gocyclo verification.
Please, take a look.
Thanks,
Vladimir.
On Wednesday, February 22, 2023 at 12:56:00 PM EST, Vladimir Semichev ***@***.***> wrote:
Hi Naveen,
I'll see what I can do. I thought about refactoring, but at the time it seemed to be taking too much time.
Thanks,
Vladimir.
On Tuesday, February 21, 2023 at 05:16:53 PM EST, Naveen Mahalingam ***@***.***> wrote:
@jedib0t requested changes on this pull request.
________________________________
In Makefile:
@@ -11,7 +11,7 @@ bench:
go test -bench=. -benchmem
cyclo:
- gocyclo -over 13 ./*/*.go
+ gocyclo -over 18 ./*/*.go
Please don't do this. Increasing it to make this step pass is not the ideal solution, can you find a way to refactor the functionality (break logic into new functions if possible)?
Or if it is too much to do, I don't mind ignoring this comment - I can fix it later and refactor the functions to stay within complexity limits I've set for myself.
________________________________
In list/render.go:
-// * Is
-// * Coming
-// * This
-// * Is
-// * Known
-// * The Dark Tower
-// * The Gunslinger
+// - Game Of Thrones
+// - Winter
+// - Is
+// - Coming
+// - This
+// - Is
+// - Known
+// - The Dark Tower
+// - The Gunslinger
Please undo this and all the other changes to comment blocks.
________________________________
In text/string.go:
@@ -74,7 +88,7 @@ func LongestLineLen(str string) int {
maxLength = currLength
}
currLength = 0
- } else if !isEscSeq {
+ } else if !isEscSeq && !isEscSeqAlt {
currLength += RuneWidth(c)
}
}
Can you add unit-tests for the changes? Call the affected functions with text containing an escape sequence with a URL as defined in the spec linked?
________________________________
In text/string.go:
+ EscapeReset = EscapeStart + "0" + EscapeStop
+ EscapeStart = "\x1b["
+ EscapeStartAlt = "\x1b]8"
+ EscapeStartRune = rune(27) // \x1b
+ EscapeStop = "m"
+ EscapeStopRune = 'm'
+ EscapeStopRuneAlt = '\\'
I wonder if there is a better way to do this for now and the future, in case another pattern needs to be supported. But this is a good start.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
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.
Thanks for the refactor. Looks awesome now.
You still haven't reverted the white-space changes to all the comment blocks. And can you address the new comment on EscKind
and EscSeq
?
Can you fix that please and I can merge.
text/string.go
Outdated
@@ -21,12 +25,48 @@ var ( | |||
rwCondition = runewidth.NewCondition() | |||
) | |||
|
|||
type EscKind int |
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.
Can you make EscKind
and EscSeq
private to this package? They don't need to be public.
I'll fix the EscKind and EscSeq exposure and push the new commit today.
As for the comments, that change was introduced when I ran "make test" from the top level. I suspect it could be due to
changes in the "go fmt" or "go vet" formatting rules changes. Not sure.
If it's critical I can try and revert my commits and then apply the latest changes on top of that.
What do you think?
Thanks
On Friday, February 24, 2023 at 11:49:12 AM EST, Naveen Mahalingam ***@***.***> wrote:
@jedib0t requested changes on this pull request.
Thanks for the refactor. Looks awesome now.
You still haven't reverted the white-space changes to all the comment blocks. And can you address the new comment on EscKind and EscSeq?
Can you fix that please and I can merge.
________________________________
In text/string.go:
@@ -21,12 +25,48 @@ var (
rwCondition = runewidth.NewCondition()
)
+type EscKind int
Can you make EscKind and EscSeq private to this package? They don't need to be public.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Ok. I've fixed the comment formatting and reverted back to what it was prior to "go fmt" messing it up. I've also changed EscSeq and EscKind to be private to the text package. I'll add a unit test for the URL escape sequence, just to make sure it is handled correctly and then we'll be ready to merge (hopefully) :) |
…mment changes introduced by go fmt
Kudos, SonarCloud Quality Gate passed! |
Hey Naveen, I've added some unit test cases for hyperlink escape sequences, so we should be ready to merge. |
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.
Looks awesome! Thanks for the contribution!
@vsemichev I've just cut a new tag with this change: https://github.com/jedib0t/go-pretty/releases/tag/v6.4.5 |
…t.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
Proposed Changes
The changes I introduced to the text/string.go will allow the text functions to correctly handle the hyperlink escape sequences described in https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda