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

check for EOF before unsetting row, col & line cache in view_coord_get #1087

Closed

Conversation

jeremybobbin
Copy link
Contributor

@mcepl
Copy link
Contributor

mcepl commented Mar 27, 2023

After the disaster of #1074, it would be probably prudent to explain slightly more why do you think that this PR works better than the other one.

@erf
Copy link
Contributor

erf commented Mar 27, 2023

@mcepl "disaster" ..? Please try to keep a positive language when commenting . There really isn't much development going on here lately, and we don't want to discourage people who actually wants to contribute !

EDIT: i thought you referred to his contribution , but if you rather referred to the buggy code, then my mistake !

@jeremybobbin
Copy link
Contributor Author

Personally I do not mind the language. :)
I believe "disaster" is a fair characterization, but then again, the fact that #1074 had gone unnoticed for as long as it did, is also disastrous - especially given vis is "Combining Modal Editing with Structural Regular Expressions".

If I didn't use structural regular expressions, I'd be using vim or neovim.

The change from pos > view->end to pos >= view->end made it such that if a selection was beyond the view, view_coord_get would return false.
I believe view_coord_get is supposed to return whether or not a position in the buffer is visible.

There is a case, however, where the position can be at the view's end & still be visible, and that's when EOF is in the view.
In this patch, we check if the view's end is EOF.

@mcepl
Copy link
Contributor

mcepl commented Mar 27, 2023

Personally I do not mind the language. :) I believe "disaster" is a fair characterization, but then again, the fact that #1074 had gone unnoticed for as long as it did, is also disastrous - especially given vis is "Combining Modal Editing with Structural Regular Expressions".

True, and I am sorry if I am too direct, but how else should I call a commit which had to be withdrawn? A shining success? And of course it doesn’t mean anything about yourself personally, I do such disasters a dozen weekly. :(

And, of course, I appreciate a lot that somebody finally started to look at the C part of vis.

The change from pos > view->end to pos >= view->end made it such that if a selection was beyond the view, view_coord_get would return false. I believe view_coord_get is supposed to return whether or not a position in the buffer is visible.

There is a case, however, where the position can be at the view's end & still be visible, and that's when EOF is in the view. In this patch, we check if the view's end is EOF.

Again, I am not the greatest C programmer myself, but doesn’t view->end != text_size(view->text)) look like a way too complicated way how to say !EOF()? Shouldn’t we have some at least macro for it?

@erf
Copy link
Contributor

erf commented Mar 27, 2023

True, and I am sorry if I am too direct, but how else should I call a commit which had to be withdrawn? A shining success? And of course it doesn’t mean anything about yourself personally, I do such disasters a dozen weekly. :(

It doesn't have to be either a "disaster" or a "shining success", just try to be somewhat professional and ask for more information, in a polite way. No reason to address a failed attempt at fixing an issue like a "disaster", it doesn't encourage more attempts at fixing stuff, if we don't get it right the first time.

Also please read the Github Community Guidelines if you have not. We want to have a positive community around this project.

@jeremybobbin
Copy link
Contributor Author

jeremybobbin commented Mar 27, 2023

but doesn’t view->end != text_size(view->text)) look like a way too complicated way how to say !EOF()? Shouldn’t we have some at least macro for it?

Makes sense - from another function in view.c:406:

		bool eof = view->end == text_size(view->text);
		if (view->line->len == 0 && eof && view->line->prev)

I've changed the patch to match the above.

No reason to address a failed attempt at fixing an issue like a "disaster"

In mcepl's defense, #1074 introduced a bug which would be easily noticed by users who are opening a vis buffer for the first time, possibly leaving a bad impression.
On a separate note, If I were driven away by the "disaster" characterization, what would that say about the value I see in Vis?

That aside, these sorts of issues should be covered in the test suite. Writing a test for that now.

@mcepl
Copy link
Contributor

mcepl commented Mar 28, 2023

		bool eof = view->end == text_size(view->text);

Isn’t this line a perfect candidate for refactoring (that’s why I was talking about macro, or perhaps function)?

That aside, these sorts of issues should be covered in the test suite. Writing a test for that now.

Yes, a low coverage of our test suite is much larger problem. I think we should include https://github.com/martanne/vis-test to this repo and start to working more intensly on increasing the coverage, but that is aside of this particular issue.

@rnpnr
Copy link
Collaborator

rnpnr commented Mar 29, 2023

I've been using this for a day and it seems correct.

It also fixes another unreported issue with the previous commit where starting a visual line selection and moving the cursor to the end of window would make it look like the selection was lost.

I'm in favor of merging this rather than reverting the previous commit.

@mcepl
Copy link
Contributor

mcepl commented Mar 29, 2023

It also fixes another unreported issue with the previous commit where starting a visual line selection and moving the cursor to the end of window would make it look like the selection was lost.

I'm in favor of merging this rather than reverting the previous commit.

Oh, I had #1074 already reverted, you mean, it could be kept around with this commit on the top?

@rnpnr
Copy link
Collaborator

rnpnr commented Mar 29, 2023

Oh, I had #1074 already reverted, you mean, it could be kept around with this commit on the top?

This commit applies on top of c22b2c2 yes.

Copy link
Contributor

@mcepl mcepl left a comment

Choose a reason for hiding this comment

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

@ninewise
Copy link
Collaborator

Applied here as well, thanks!

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.

Slave selection strangled by view cliff
5 participants