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

(Re -revision)Change the name of the variable name #624

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

noborus
Copy link
Owner

@noborus noborus commented Sep 8, 2024

Change the general name forward for variables.
Add ColumnAttribute and put shink and right align inside.
Added ShrinkColumn and ExpandColumn.

Change the general name forward for variables.
Add ColumnAttribute and put shink and right align inside.
Added ShrinkColumn and ExpandColumn.
Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

A few suggestions

@@ -422,6 +422,10 @@ var (
ErrAlreadyLoaded = errors.New("chunk already loaded")
// ErrEvictedMemory indicates that it has been evicted from memory.
ErrEvictedMemory = errors.New("evicted memory")
// ErrNotAlignMode indicates that it is not an align mode.
ErrNotAlignMode = errors.New("not align mode")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this ?

Suggested change
ErrNotAlignMode = errors.New("not align mode")
ErrNotAlignMode = errors.New("not an align mode")

Copy link
Owner Author

Choose a reason for hiding this comment

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

I see

@@ -161,8 +161,7 @@ func Test_align_convertDelm(t *testing.T) {
es *escapeSequence
Copy link
Contributor

Choose a reason for hiding this comment

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

as the field is private, I would rename it to escapeSequence

Suggested change
es *escapeSequence
escapeSequence *escapeSequence

Because no one can guess what es refers to

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 is a little hold

@@ -210,7 +209,13 @@ func Test_align_convertDelm(t *testing.T) {
fields: fields{
es: newESConverter(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
es: newESConverter(),
escapeSequence: newEscapeSequenceConverter(),

the newESConverter might be renamed to newEscapeSequenceConverter

Comment on lines +212 to +218
columns: []columnAttribute{
{shrink: false, rightAlign: false},
{shrink: true, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the fact the default boolean value, this could be written

Suggested change
columns: []columnAttribute{
{shrink: false, rightAlign: false},
{shrink: true, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
},
columns: []columnAttribute{
{}, {shrink: true}, {}, {}, {},
},

Comment on lines +276 to +283
columns: []columnAttribute{
{shrink: false, rightAlign: true},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: true, rightAlign: false},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

same logic here

Suggested change
columns: []columnAttribute{
{shrink: false, rightAlign: true},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: false, rightAlign: false},
{shrink: true, rightAlign: false},
},
columns: []columnAttribute{
{rightAlign: true}, {}, {}, {}, {}, {shrink: true},
},

Copy link
Contributor

Choose a reason for hiding this comment

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

and so on, everywhere

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 may also change, but I'll leave it as it is

Comment on lines +128 to +130
for n := len(m.alignConv.columnAttrs); n < len(maxWidths)+1; n++ {
m.alignConv.columnAttrs = append(m.alignConv.columnAttrs, columnAttribute{})
}
Copy link
Contributor

@ccoVeille ccoVeille Sep 8, 2024

Choose a reason for hiding this comment

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

isn't equivalent to this ?

Suggested change
for n := len(m.alignConv.columnAttrs); n < len(maxWidths)+1; n++ {
m.alignConv.columnAttrs = append(m.alignConv.columnAttrs, columnAttribute{})
}
m.alignConv.columnAttrs = make([]columnAttribute), len(maxWidths))

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 is different. Do not recreate the attributes.I'll add comments.

Add a shrinking column or judgment function.
Add functions other than the shrink and expansion tooggle.
Comment on lines 782 to 803
// toggleColumnShrink shrinks or expands the current cursor column.
func (root *Root) toggleColumnShrink(ctx context.Context) {
cursor := root.Doc.columnCursor
shrink, err := root.Doc.isColumnShink(cursor)
if err != nil {
root.setMessage(err.Error())
}
if err := root.Doc.shrinkColumn(cursor, !shrink); err != nil {
root.setMessage(err.Error())
}
}

// isColumnShink returns whether the specified column is shrink.
func (m *Document) isColumnShink(cursor int) (bool, error) {
if m.Converter != convAlign {
return false, ErrNotAlignMode
}
if cursor >= len(m.alignConv.columnAttrs) {
return false, ErrNoColumnSelected
}
return m.alignConv.columnAttrs[cursor].shrink, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

typo spotted

Suggested change
// toggleColumnShrink shrinks or expands the current cursor column.
func (root *Root) toggleColumnShrink(ctx context.Context) {
cursor := root.Doc.columnCursor
shrink, err := root.Doc.isColumnShink(cursor)
if err != nil {
root.setMessage(err.Error())
}
if err := root.Doc.shrinkColumn(cursor, !shrink); err != nil {
root.setMessage(err.Error())
}
}
// isColumnShink returns whether the specified column is shrink.
func (m *Document) isColumnShink(cursor int) (bool, error) {
if m.Converter != convAlign {
return false, ErrNotAlignMode
}
if cursor >= len(m.alignConv.columnAttrs) {
return false, ErrNoColumnSelected
}
return m.alignConv.columnAttrs[cursor].shrink, nil
}
// toggleColumnShrink shrinks or expands the current cursor column.
func (root *Root) toggleColumnShrink(ctx context.Context) {
cursor := root.Doc.columnCursor
shrink, err := root.Doc.isColumnShrink(cursor)
if err != nil {
root.setMessage(err.Error())
}
if err := root.Doc.shrinkColumn(cursor, !shrink); err != nil {
root.setMessage(err.Error())
}
}
// isColumnShrink returns whether the specified column is shrink.
func (m *Document) isColumnShrink(cursor int) (bool, error) {
if m.Converter != convAlign {
return false, ErrNotAlignMode
}
if cursor >= len(m.alignConv.columnAttrs) {
return false, ErrNoColumnSelected
}
return m.alignConv.columnAttrs[cursor].shrink, nil
}

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, thank you!

Comment on lines 199 to 202
if len(a.columnAttrs) <= col {
return false
}
return a.rightAlign[col]
return a.columnAttrs[col].rightAlign
Copy link
Contributor

Choose a reason for hiding this comment

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

col starts at 0?

I'm asking because len starts at 1 if there is an element

I'm unsure the code does what is expected

What about this?

 func (a *align) isRightAlign(col int) bool { 

         if c, found := a.columnAttrs[col]; found { 
                  return c.rightAlign
          } 
         return false
  }

Copy link
Owner Author

Choose a reason for hiding this comment

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

yes. col starts from 0.
Need to determine the range because of slice.

@noborus noborus merged commit f5e315b into master Sep 10, 2024
8 checks passed
@noborus noborus deleted the refactoring-again-variable-name branch September 10, 2024 14:01
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 22, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [noborus/ov](https://github.com/noborus/ov) | minor | `v0.36.0` -> `v0.37.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>noborus/ov (noborus/ov)</summary>

### [`v0.37.0`](https://github.com/noborus/ov/releases/tag/v0.37.0)

[Compare Source](noborus/ov@v0.36.0...v0.37.0)

#### What's Changed

Thank you for working on this release.
[@&#8203;aoyama-val](https://github.com/aoyama-val) [@&#8203;ccoveille](https://github.com/ccoveille) [@&#8203;kapji](https://github.com/kapji) [@&#8203;yosagi](https://github.com/yosagi) [@&#8203;bprb](https://github.com/bprb)

##### Add a converter

Escape sequence support has been changed from essential to selectable as a converter.
There are converters: an interpretation of escape sequence (default), `raw`, which does not interpret escape sequence, and `align`.
The columns can be shrinked, if the converter is aligned.

noborus/ov#609   noborus/ov#610 noborus/ov#611 noborus/ov#612 noborus/ov#614 noborus/ov#615 noborus/ov#617 noborus/ov#618 noborus/ov#619 noborus/ov#623 noborus/ov#624  noborus/ov#625  noborus/ov#626 noborus/ov#627 noborus/ov#631

##### Change specifications of suspend

The suspend is suspended correctly, not sub-shell.
Thank you to [@&#8203;yosagi](https://github.com/yosagi).

-   Change to suspend with SIGSTOP by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#632
-   Send SIGSTOP to the process group by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#639
-   STDIN switching when using Subshell by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#640

##### Changed redirect specifications

-   Change to Do not display screen when redirecting by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#638
    (Fix noborus/ov#634).

##### Fix bugs and improvements

-   Fix paste mistakes by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#616 (Fix noborus/ov#613)
-   Avoid sector header when marking by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#621 (Fix noborus/ov#620)
-   Change the style-related function name by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#628
-   help descriptions for better clarity by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#635
-   Fix the issue where the version contains "-1" by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#637 Fix noborus/ov#636)
-   Fixed root.searcher is race condition by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#642 (Fix noborus/ov#641)
-   Fix linkage of filter documents with headers by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#644
-   Improve follow/followAll/followSection by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#645
-   Add support of ANSI escape sequence for clear line by [@&#8203;noborus](https://github.com/noborus) in noborus/ov#651 (Fix noborus/ov#650)

**Full Changelog**: noborus/ov@v0.36.0...v0.37.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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