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

Change slightly how x/X works #2595

Closed
wants to merge 7 commits into from
Closed

Change slightly how x/X works #2595

wants to merge 7 commits into from

Conversation

dpc
Copy link
Contributor

@dpc dpc commented Nov 25, 2018

Discussion in #2590

@@ -135,6 +148,8 @@ private:
void end_edition();
int m_edition_level = 0;
size_t m_edition_timestamp = 0;
mutable bool m_line_mode = false;
mutable bool m_keep_line_mode = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is using mutable really necessary here?

Copy link
Contributor Author

@dpc dpc Nov 25, 2018

Choose a reason for hiding this comment

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

It's kind of a hack/workaround that mawww threw at me, when I didn't know what to do. You can revert Is it a hack, or is it a solution? :D to see the problem, or just see the error in this commit: dpc@b8d3f08

Basically: now some functions are taking Context& some consts Context& and this big hashmap is complaining, even though it it is storing Context& in intself, so I don't get why it can't promote.

}
}

context().hooks().run_hook(Hook::NormalKey, key_to_str(key), context());
if (enabled() and not transient) // The hook might have changed mode
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));

Copy link
Contributor

Choose a reason for hiding this comment

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

You should remove this hunk

src/normal.cc Outdated
m_func(context, {0, params.reg});
if (params.count > 1) {
context.post_movement_logic();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The braces could be removed here, to follow the style of the rest of the code, and reduce the size of the patch. Same for the subsequent hunks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gosh. I think it's a terrible idea, but not my project, not my rules. Fixing. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Would need to be fixed in subsequent hunks as well, prior to merging.

src/normal.cc Outdated
if (params.count > 1) {
context.post_movement_logic();
}
} while(--params.count > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Space after a keyword, applies to the subsequent hunks as well.

src/selectors.cc Outdated
@@ -832,6 +839,9 @@ trim_partial_lines(const Context& context, const Selection& selection)
BufferCoord& to_line_start = anchor <= cursor ? anchor : cursor;
BufferCoord& to_line_end = anchor <= cursor ? cursor : anchor;


Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this new line is necessary, there's already one on line 841.

@maximbaz
Copy link
Contributor

#2590 became a broad discussion about different ideas, let's make it super clear that this PR is about one thing: changing when x/X move to the next line, from "if whole line is already selected" to "if the previous action was also x/X". @dpc maybe add this to the first message of the PR to clarify.

@mawww would be interesting to hear your opinion about this particular proposal.

@dpc
Copy link
Contributor Author

dpc commented Nov 26, 2018

I have fixed the style. I was editing this with kakoune, that I haven't configured for cpp yet, so there were some troubles and omissions. :)

@andreyorst
Copy link
Contributor

andreyorst commented Nov 29, 2018

About several formatting suggestions mentioned in reviews. Just wondering, why not set up git hooks or add file with rules for formatting program (clang-format for example). It works for such projects as Linux, could work here. And kakoune supports formatting, so it feels natural to have project formatting rules.

@mawww
Copy link
Owner

mawww commented Nov 29, 2018

I must say I am not really in favor of that change, my main issue is that this de-facto introduces a 'submode' into the normal mode, and the behaviour is pretty fuzzy, as it is context dependent.

Say if you do x in client one, then the selected line is joined to the next in client two, so the selection is not a full line anymore in client one, and then you press x again in client one, you get to the next line without having ever fully selected the current one.

In general, I think introducing this additional state is confusing and creates a dangerous precedent. I would love to improve the ergonomics of x, but I am not confortable with this approach.

@dpc
Copy link
Contributor Author

dpc commented Nov 29, 2018

@andreyorst Yeah, I was wondering the same thing. Rust spoiled me.

@mawww I understand. In practice I don't hit this fuzziness with this branch, while I get supper annoyed by having inconsistent behavior on empty lines.

In this one particular case you mention, should this state move to a different data structure that is shared between clients? Where it would be?

I also agree that this is de-fact submode. That's why I enjoyed the line_editing_ext from #2590 which goes all the way, and just displays is differently and give some keys some additional meaning in that sub-mode.

@mawww
Copy link
Owner

mawww commented Nov 30, 2018

In this one particular case you mention, should this state move to a different data structure that is shared between clients? Where it would be?

Would'nt that be even worse ? If you press x in one client, get to another client and press x, you magically jump to the next line without having ever selected the current one (and clients might be at totally different positions in the buffer, or on different buffers), now imagine what happens with scripting or just mappings: x becomes even less predictible as it depends on if the user has hit x before triggering the mapping or not.

@dpc
Copy link
Contributor Author

dpc commented Nov 30, 2018

I don't know the details of buffer sharing between clients, so I have no idea which one is better.

The state of x consecutive-ness could be tracked per client, per script connection etc. too.

@dpc dpc closed this Feb 23, 2024
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.

5 participants