renamed fern.rs back to main.rs
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
pub mod highlight;
|
||||
pub mod readline;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use readline::{FernVi, Readline};
|
||||
|
||||
use crate::{
|
||||
expand::expand_prompt, libsh::error::ShResult, prelude::*, shopt::FernEditMode,
|
||||
state::read_shopts,
|
||||
};
|
||||
|
||||
/// Initialize the line editor
|
||||
@@ -32,7 +30,7 @@ pub fn readline(edit_mode: FernEditMode, initial: Option<&str>) -> ShResult<Stri
|
||||
FernEditMode::Vi => {
|
||||
let mut fern_vi = FernVi::new(Some(prompt))?;
|
||||
if let Some(input) = initial {
|
||||
fern_vi = fern_vi.with_initial(&input)
|
||||
fern_vi = fern_vi.with_initial(input)
|
||||
}
|
||||
Box::new(fern_vi) as Box<dyn Readline>
|
||||
}
|
||||
|
||||
@@ -953,11 +953,10 @@ impl LineBuf {
|
||||
}
|
||||
let start = start.unwrap_or(0);
|
||||
|
||||
if count > 1 {
|
||||
if let Some((_, new_end)) = self.text_obj_sentence(end, count - 1, bound) {
|
||||
if count > 1
|
||||
&& let Some((_, new_end)) = self.text_obj_sentence(end, count - 1, bound) {
|
||||
end = new_end;
|
||||
}
|
||||
}
|
||||
|
||||
Some((start, end))
|
||||
}
|
||||
@@ -2590,8 +2589,8 @@ impl LineBuf {
|
||||
self.cursor.add(content.len().saturating_sub(1));
|
||||
}
|
||||
Verb::SwapVisualAnchor => {
|
||||
if let Some((start, end)) = self.select_range() {
|
||||
if let Some(mut mode) = self.select_mode {
|
||||
if let Some((start, end)) = self.select_range()
|
||||
&& let Some(mut mode) = self.select_mode {
|
||||
mode.invert_anchor();
|
||||
let new_cursor_pos = match mode.anchor() {
|
||||
SelectAnchor::Start => start,
|
||||
@@ -2600,7 +2599,6 @@ impl LineBuf {
|
||||
self.cursor.set(new_cursor_pos);
|
||||
self.select_mode = Some(mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
Verb::JoinLines => {
|
||||
let start = self.start_of_line();
|
||||
@@ -2748,11 +2746,10 @@ impl LineBuf {
|
||||
let edit_is_merging = self.undo_stack.last().is_some_and(|edit| edit.merging);
|
||||
|
||||
// Merge character inserts into one edit
|
||||
if edit_is_merging && cmd.verb.as_ref().is_none_or(|v| !v.1.is_char_insert()) {
|
||||
if let Some(edit) = self.undo_stack.last_mut() {
|
||||
if edit_is_merging && cmd.verb.as_ref().is_none_or(|v| !v.1.is_char_insert())
|
||||
&& let Some(edit) = self.undo_stack.last_mut() {
|
||||
edit.stop_merge();
|
||||
}
|
||||
}
|
||||
|
||||
let ViCmd {
|
||||
register,
|
||||
@@ -2839,11 +2836,10 @@ impl LineBuf {
|
||||
self.saved_col = None;
|
||||
}
|
||||
|
||||
if is_char_insert {
|
||||
if let Some(edit) = self.undo_stack.last_mut() {
|
||||
if is_char_insert
|
||||
&& let Some(edit) = self.undo_stack.last_mut() {
|
||||
edit.start_merge();
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use history::{History, SearchConstraint, SearchKind};
|
||||
use history::History;
|
||||
use keys::{KeyCode, KeyEvent, ModKeys};
|
||||
use linebuf::{LineBuf, SelectAnchor, SelectMode};
|
||||
use nix::libc::STDOUT_FILENO;
|
||||
|
||||
@@ -2,9 +2,7 @@ use std::{
|
||||
env,
|
||||
fmt::{Debug, Write},
|
||||
io::{BufRead, BufReader, Read},
|
||||
iter::Peekable,
|
||||
os::fd::{AsFd, BorrowedFd, RawFd},
|
||||
str::Chars,
|
||||
};
|
||||
|
||||
use nix::{
|
||||
|
||||
@@ -161,15 +161,14 @@ impl ViCmd {
|
||||
}
|
||||
/// If a ViCmd has a linewise motion, but no verb, we change it to charwise
|
||||
pub fn alter_line_motion_if_no_verb(&mut self) {
|
||||
if self.is_line_motion() && self.verb.is_none() {
|
||||
if let Some(motion) = self.motion.as_mut() {
|
||||
if self.is_line_motion() && self.verb.is_none()
|
||||
&& let Some(motion) = self.motion.as_mut() {
|
||||
match motion.1 {
|
||||
Motion::LineUp => motion.1 = Motion::LineUpCharwise,
|
||||
Motion::LineDown => motion.1 = Motion::LineDownCharwise,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn is_mode_transition(&self) -> bool {
|
||||
self.verb.as_ref().is_some_and(|v| {
|
||||
|
||||
@@ -5,7 +5,6 @@ use nix::NixPath;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::keys::{KeyCode as K, KeyEvent as E, ModKeys as M};
|
||||
use super::linebuf::CharClass;
|
||||
use super::vicmd::{
|
||||
Anchor, Bound, CmdFlags, Dest, Direction, Motion, MotionCmd, RegisterName, TextObj, To, Verb,
|
||||
VerbCmd, ViCmd, Word,
|
||||
|
||||
Reference in New Issue
Block a user