mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
Make the c
action translation more explicit (#484)
Move the `Repaint` addition outside to ensure it is always added. Currently required to detect the mode change visually.
This commit is contained in:
parent
710393a037
commit
a7dababdd0
@ -320,61 +320,53 @@ impl Command {
|
|||||||
}
|
}
|
||||||
Motion::Start => Some(vec![ReedlineOption::Edit(EditCommand::CutFromLineStart)]),
|
Motion::Start => Some(vec![ReedlineOption::Edit(EditCommand::CutFromLineStart)]),
|
||||||
},
|
},
|
||||||
Self::Change => match motion {
|
Self::Change => {
|
||||||
Motion::End => Some(vec![
|
let op = match motion {
|
||||||
ReedlineOption::Edit(EditCommand::ClearToLineEnd),
|
Motion::End => Some(vec![ReedlineOption::Edit(EditCommand::ClearToLineEnd)]),
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
Motion::Line => Some(vec![
|
||||||
]),
|
ReedlineOption::Edit(EditCommand::MoveToStart),
|
||||||
Motion::Line => Some(vec![
|
ReedlineOption::Edit(EditCommand::ClearToLineEnd),
|
||||||
ReedlineOption::Edit(EditCommand::MoveToStart),
|
]),
|
||||||
ReedlineOption::Edit(EditCommand::ClearToLineEnd),
|
Motion::NextWord => {
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutWordRightToNext)])
|
||||||
]),
|
}
|
||||||
Motion::NextWord => Some(vec![
|
Motion::NextBigWord => Some(vec![ReedlineOption::Edit(
|
||||||
ReedlineOption::Edit(EditCommand::CutWordRightToNext),
|
EditCommand::CutBigWordRightToNext,
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
)]),
|
||||||
]),
|
Motion::NextWordEnd => {
|
||||||
Motion::NextBigWord => Some(vec![
|
Some(vec![ReedlineOption::Edit(EditCommand::CutWordRight)])
|
||||||
ReedlineOption::Edit(EditCommand::CutBigWordRightToNext),
|
}
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
Motion::NextBigWordEnd => {
|
||||||
]),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutBigWordRight)])
|
||||||
Motion::NextWordEnd => Some(vec![
|
}
|
||||||
ReedlineOption::Edit(EditCommand::CutWordRight),
|
Motion::PreviousWord => {
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutWordLeft)])
|
||||||
]),
|
}
|
||||||
Motion::NextBigWordEnd => Some(vec![
|
Motion::PreviousBigWord => {
|
||||||
ReedlineOption::Edit(EditCommand::CutBigWordRight),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutBigWordLeft)])
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
}
|
||||||
]),
|
Motion::RightUntil(c) => {
|
||||||
Motion::PreviousWord => Some(vec![
|
Some(vec![ReedlineOption::Edit(EditCommand::CutRightUntil(*c))])
|
||||||
ReedlineOption::Edit(EditCommand::CutWordLeft),
|
}
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
Motion::RightBefore(c) => {
|
||||||
]),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutRightBefore(*c))])
|
||||||
Motion::PreviousBigWord => Some(vec![
|
}
|
||||||
ReedlineOption::Edit(EditCommand::CutBigWordLeft),
|
Motion::LeftUntil(c) => {
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutLeftUntil(*c))])
|
||||||
]),
|
}
|
||||||
Motion::RightUntil(c) => Some(vec![
|
Motion::LeftBefore(c) => {
|
||||||
ReedlineOption::Edit(EditCommand::CutRightUntil(*c)),
|
Some(vec![ReedlineOption::Edit(EditCommand::CutLeftBefore(*c))])
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
}
|
||||||
]),
|
Motion::Start => {
|
||||||
Motion::RightBefore(c) => Some(vec![
|
Some(vec![ReedlineOption::Edit(EditCommand::CutFromLineStart)])
|
||||||
ReedlineOption::Edit(EditCommand::CutRightBefore(*c)),
|
}
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
};
|
||||||
]),
|
// Semihack: Append `Repaint` to ensure the mode change gets displayed
|
||||||
Motion::LeftUntil(c) => Some(vec![
|
op.map(|mut vec| {
|
||||||
ReedlineOption::Edit(EditCommand::CutLeftUntil(*c)),
|
vec.push(ReedlineOption::Event(ReedlineEvent::Repaint));
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
vec
|
||||||
]),
|
})
|
||||||
Motion::LeftBefore(c) => Some(vec![
|
}
|
||||||
ReedlineOption::Edit(EditCommand::CutLeftBefore(*c)),
|
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
|
||||||
]),
|
|
||||||
Motion::Start => Some(vec![
|
|
||||||
ReedlineOption::Edit(EditCommand::CutFromLineStart),
|
|
||||||
ReedlineOption::Event(ReedlineEvent::Repaint),
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user