pub struct FileMerge {
pub path: String,
pub chunks: Vec<MergeChunk>,
pub states: Vec<ChunkState>,
pub cursor: usize,
pub scroll: usize,
pub follow: bool,
pub ours_label: Option<String>,
pub theirs_label: Option<String>,
/* private fields */
}Expand description
一个文本文件的合并会话:块列表 + 各块解决状态 + 光标。
Fields§
§path: String文件路径(git 模式为仓库根相对;单文件模式为输入路径)
chunks: Vec<MergeChunk>合并块,首尾相接覆盖整个文件
states: Vec<ChunkState>与 chunks 一一对应的解决状态
cursor: usize光标所在块下标(始终指向非 Stable 块;无改动块时为 0)
scroll: usize视口滚动行偏移(由 UI 维护)
follow: bool视口是否跟随光标块(手动滚动后为 false,作用于光标的动作恢复跟随)
ours_label: Option<String>本地侧栏头标签(分支名)
theirs_label: Option<String>远端侧栏头标签(分支名)
Implementations§
Source§impl FileMerge
impl FileMerge
Sourcepub fn from_three_way(
path: String,
base: &str,
ours: &str,
theirs: &str,
) -> Self
pub fn from_three_way( path: String, base: &str, ours: &str, theirs: &str, ) -> Self
由三份完整文本构建(git 三方模式)。
Sourcepub fn from_result(
path: String,
result: MergeResult,
ends_with_newline: bool,
) -> Self
pub fn from_result( path: String, result: MergeResult, ends_with_newline: bool, ) -> Self
由已计算好的合并结果构建(冲突文件解析模式)。
Sourcepub fn chunk_resolved(&self, idx: usize) -> bool
pub fn chunk_resolved(&self, idx: usize) -> bool
某块是否已处理完毕(被覆写,或所有有效侧均非待处理)。
Sourcepub fn pending_conflicts(&self) -> usize
pub fn pending_conflicts(&self) -> usize
未处理完的冲突块数量(写盘的先决条件是归零)。
Sourcepub fn pending_changes(&self) -> usize
pub fn pending_changes(&self) -> usize
未处理完的改动块总数(含非冲突,状态条展示用)。
Sourcepub fn ready_to_write(&self) -> bool
pub fn ready_to_write(&self) -> bool
文件是否可写盘:所有冲突块已解决(非冲突块保持待处理 = 保留 base)。
Sourcepub fn current_content(&self, idx: usize) -> Vec<String>
pub fn current_content(&self, idx: usize) -> Vec<String>
某块当前在结果中的内容:覆写 > 按取用顺序拼接 > base。
Sourcepub fn resolved_content(&self) -> String
pub fn resolved_content(&self) -> String
导出整个文件的最终内容(按块拼接 + 末尾换行策略)。
Sourcepub fn apply(&mut self, side: Side)
pub fn apply(&mut self, side: Side)
取用某一侧:内容按点击顺序追加(冲突两侧先后取用 =「两者都要」); agree 块两侧内容一致,取任一侧即整块完成。
Sourcepub fn set_override(&mut self, lines: Vec<String>)
pub fn set_override(&mut self, lines: Vec<String>)
用 $EDITOR 编辑后的内容覆写当前块(视为已解决)。
Sourcepub fn apply_all_nonconflict(&mut self)
pub fn apply_all_nonconflict(&mut self)
一键取用所有非冲突改动(ours/theirs/agree)。
Sourcepub fn next_change(&mut self)
pub fn next_change(&mut self)
移到下一个改动块(跳过 Stable)。
Sourcepub fn prev_change(&mut self)
pub fn prev_change(&mut self)
移到上一个改动块(跳过 Stable)。
Sourcepub fn next_conflict(&mut self)
pub fn next_conflict(&mut self)
跳到下一个未解决的冲突块(到底后从头环绕)。
Sourcepub fn prev_conflict(&mut self)
pub fn prev_conflict(&mut self)
跳到上一个未解决的冲突块(到头后从尾环绕)。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileMerge
impl RefUnwindSafe for FileMerge
impl Send for FileMerge
impl Sync for FileMerge
impl Unpin for FileMerge
impl UnsafeUnpin for FileMerge
impl UnwindSafe for FileMerge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more