abrochard / kubel

Emacs extension for controlling Kubernetes with limited permissions
GNU General Public License v3.0
259 stars 41 forks source link

Avoid kubel from always moving the point to point-min when refreshing #94

Closed Konubinix closed 1 year ago

Konubinix commented 1 year ago

tabulated-list already provides a way to remember the position between refreshes. It only need to be used.

abrochard commented 1 year ago

Thank you for submitting! I didn't know about this feature. Does this mean that kubel--save-line and kubel--jump-back-to-line and stuff can be deleted?

Konubinix commented 1 year ago

Adrien Brochard @.***> writes:

Thank you for submitting! I didn't know about this feature. Does this mean that kubel--save-line and kubel--jump-back-to-line and stuff can be deleted?

Interesting, I did not know about those. Somehow my use of kubel bypassed it.

I suppose that depends on your preference. Both behavior make sense to me. kubel--save-line saves make the cursor look static, while the content might change. (tabulated-list-print t) makes the cursor follow the content, even if it is moved.

Supporting both could be a good thing, but add maintenance cost.

What do you think?

-- Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A

abrochard commented 1 year ago

I like your version better. If my cursor is on a pod and refresh, I would like my cursor still on that same pod. What would the behavior be if the item disappears? Like I have my cursor on a terminating pod and it is gone after a refresh? Would the cursor stay at the same line or go back to the top?

Konubinix commented 1 year ago

Adrien Brochard @.***> writes:

I like your version better. If my cursor is on a pod and refresh, I would like my cursor still on that same pod. What would the behavior be if the item disappears? Like I have my cursor on a terminating pod and it is gone after a refresh? Would the cursor stay at the same line or go back to the top?

If I remember correctly, it goes back to the top.

-- Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A

Konubinix commented 1 year ago

Actually, I found out that my issue with the line moving back to the top was due to some conflict between window-point and point.

Now, I may change this PR to use the default behavior of tabulate-print while falling back to recording the line.

In the mean time, I suggested another PR to make the code that records the line number shorter and easier to read (IMHO).

abrochard commented 1 year ago

Hmm. I think I'd need to test it out. I really like that tabulated list offers the functionality and it makes sense to track the "value" and not the line. But if I'm observing a terminating pod and refresh and my cursor goes back to the first line, that's not a great experience.

Konubinix commented 1 year ago

Adrien Brochard @.***> writes:

Hmm. I think I'd need to test it out. I really like that tabulated list offers the functionality and it makes sense to track the "value" and not the line. But if I'm observing a terminating pod and refresh and my cursor goes back to the first line, that's not a great experience.

I totally agree with you and I discourage the merge of this PR until the behavior is the following.

  1. follow the resource by default
  2. if the resource is deleted, keep the current line

To me, the other PR (https://github.com/abrochard/kubel/pull/102) not only makes the code more readable, but it also provide a first step to ease the current PR.

-- Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A

Konubinix commented 1 year ago

Actually, it was easier to do than I expected, so I integrated the changes of #102 into this PR and closed it.

Now, this PR has the behavior that I would expect from kubel: it keeps track of the current item and falls back on keeping the same line if the current item vanishes.

It also replaces the kubel--save-line and kubel--jump-back-to-line logic by something that is shorter and (IMHO) is more readable.

abrochard commented 1 year ago

Wondeful! Thank you. I'll review and test.

Konubinix commented 1 year ago

Adrien Brochard @.***> writes:

@abrochard commented on this pull request. can we also delete kubel--line-number if it's not used?

Done

-- Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A