-
Notifications
You must be signed in to change notification settings - Fork 715
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
Changes from 4 commits
c735b9d
14ac601
33dca81
e5c43f3
76826fc
770824e
929bc11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,12 +311,14 @@ class Normal : public InputMode | |
m_params = { 0, 0 }; | ||
|
||
command->func(context(), params); | ||
context().post_movement_logic(); | ||
} | ||
} | ||
|
||
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())); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should remove this hunk |
||
} | ||
|
||
DisplayLine mode_line() const override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2001,7 +2001,12 @@ class Repeated | |
void operator() (Context& context, NormalParams params) | ||
{ | ||
ScopedEdition edition(context); | ||
do { m_func(context, {0, params.reg}); } while(--params.count > 0); | ||
do { | ||
m_func(context, {0, params.reg}); | ||
if (params.count > 1) { | ||
context.post_movement_logic(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} while(--params.count > 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space after a keyword, applies to the subsequent hunks as well. |
||
} | ||
private: | ||
T m_func; | ||
|
@@ -2011,7 +2016,12 @@ template<void (*func)(Context&, NormalParams)> | |
void repeated(Context& context, NormalParams params) | ||
{ | ||
ScopedEdition edition(context); | ||
do { func(context, {0, params.reg}); } while(--params.count > 0); | ||
do { | ||
func(context, {0, params.reg}); | ||
if (params.count > 1) { | ||
context.post_movement_logic(); | ||
} | ||
} while(--params.count > 0); | ||
} | ||
|
||
template<typename Type, Direction direction, SelectMode mode = SelectMode::Replace> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,11 +175,16 @@ select_line(const Context& context, const Selection& selection) | |
{ | ||
auto& buffer = context.buffer(); | ||
auto line = selection.cursor().line; | ||
// Next line if line fully selected | ||
if (selection.anchor() <= BufferCoord{line, 0_byte} and | ||
selection.cursor() == BufferCoord{line, buffer[line].length() - 1} and | ||
line != buffer.line_count() - 1) | ||
|
||
if (context.is_line_editing()) { | ||
++line; | ||
} | ||
|
||
context.enter_or_keep_line_editing(); | ||
|
||
if (line >= buffer.line_count()) { | ||
return Optional<Selection>(); | ||
} | ||
return target_eol({{line, 0_byte}, {line, buffer[line].length() - 1}}); | ||
} | ||
|
||
|
@@ -811,6 +816,8 @@ select_argument(const Context& context, const Selection& selection, | |
Optional<Selection> | ||
select_lines(const Context& context, const Selection& selection) | ||
{ | ||
context.enter_or_keep_line_editing(); | ||
|
||
auto& buffer = context.buffer(); | ||
BufferCoord anchor = selection.anchor(); | ||
BufferCoord cursor = selection.cursor(); | ||
|
@@ -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; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
context.enter_or_keep_line_editing(); | ||
|
||
if (to_line_start.column != 0) | ||
to_line_start = to_line_start.line+1; | ||
if (to_line_end.column != buffer[to_line_end.line].length()-1) | ||
|
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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 revertIs it a hack, or is it a solution? :D
to see the problem, or just see the error in this commit: dpc@b8d3f08Basically: now some functions are taking
Context&
someconsts Context&
and this big hashmap is complaining, even though it it is storingContext&
in intself, so I don't get why it can't promote.