Skip to content
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

Refactor align converter #623

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Refactor align converter #623

merged 1 commit into from
Sep 8, 2024

Conversation

noborus
Copy link
Owner

@noborus noborus commented Sep 8, 2024

Change reflect.DeepEqual to slices.Equal.
rightAlign is changed to not reset every time.
Change trimLeft and trimRight to trimmedIndices.
markNext and markPrev are renamed to nextMark and prevMark.

Change reflect.DeepEqual to slices.Equal.
rightAlign is changed to not reset every time.
Change trimLeft and trimRight to trimmedIndices.
markNext and markPrev are renamed to nextMark and prevMark.
@noborus noborus merged commit 1bbf743 into master Sep 8, 2024
8 checks passed
@noborus noborus deleted the refactor-align-conv2 branch September 8, 2024 07:49
Comment on lines +365 to +371
esConv string = "es" // esConv processes escape sequence(default).
rawConv string = "raw" // rawConv is displayed without processing escape sequences as they are.
alignConv string = "align" // alignConv is aligned in each column.
)

const (
generalName string = "general"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually constants are sharing a common prefix, allowing to find the easily when using completion in the IDE, they are also ordered in the godoc if they are exported

Suggested change
esConv string = "es" // esConv processes escape sequence(default).
rawConv string = "raw" // rawConv is displayed without processing escape sequences as they are.
alignConv string = "align" // alignConv is aligned in each column.
)
const (
generalName string = "general"
convEscaped string = "es" // convEscaped processes escape sequence(default).
convRaw string = "raw" // convRaw is displayed without processing escape sequences as they are.
convAlign string = "align" // convAlign is aligned in each column.
)
const (
nameGeneral string = "general"

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment.
That's right. Change.

@@ -120,18 +120,19 @@ func (root *Root) setAlignConverter() {
maxWidths, addRight = m.maxColumnWidths(maxWidths, addRight, ln)
}

if !reflect.DeepEqual(m.alignConv.maxWidths, maxWidths) {
if !slices.Equal(m.alignConv.maxWidths, maxWidths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based of the fact the if starts here and ends with the function, you could do this

Suggested change
if !slices.Equal(m.alignConv.maxWidths, maxWidths) {
if slices.Equal(m.alignConv.maxWidths, maxWidths) {
return
}

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that's right.

Comment on lines -247 to +248
// markNext moves to the next mark.
func (root *Root) markNext(context.Context) {
// nextMark moves to the next mark.
func (root *Root) nextMark(context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't rename them in the same logic as

#623 (comment)

But why not

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on the naming rules of the function name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I said, why not 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants