Skip to content
Merged

Dev #105

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions crates/aether-core/src/buffer/piece_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,22 @@ impl PieceTable {
let file = File::open(path)?;
let mmap = unsafe { Mmap::map(&file)? };
let len = mmap.len();
let line_breaks = count_line_breaks(&mmap);
// 单次扫描构建行起始偏移表(替代 count_line_breaks + rebuild_line_index
// 的双重全文件扫描,打开大文件时省一半时间;SIMD 查找每次从上次位置继续,
// 总体仍是一次遍历)
let mut line_starts = Vec::new();
line_starts.push(0); // 第0行从字节0开始
let mut offset = 0usize;
while offset < len {
match crate::simd_utils::find_byte_simd(&mmap[offset..], b'\n') {
Some(pos) => {
line_starts.push(offset + pos + 1); // 下一行起始
offset += pos + 1; // 跳过已找到的换行符
}
None => break,
}
}
let line_breaks = (line_starts.len() - 1) as u32;
let pieces = vec![Piece {
source: Source::Original,
start: 0,
Expand All @@ -421,14 +436,14 @@ impl PieceTable {
original: Some(Arc::new(mmap)),
add_buffer: Vec::new(),
pieces,
line_index: LineIndex::new(),
line_index: LineIndex::from_line_starts(line_starts),
piece_offset_cache: Vec::new(),
len_chars: len,
len_lines: line_breaks as usize + 1,
edit_count: 0,
coalesce_threshold: 32,
};
pt.rebuild_line_index();
pt.rebuild_piece_offset_cache();
Ok(pt)
}

Expand Down
6 changes: 6 additions & 0 deletions crates/aether-core/src/char_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
/// - 0:组合标记、控制字符、格式控制符(零宽度)
/// - 1:窄字符(拉丁、希腊、西里尔等)
/// - 2:宽字符(CJK、全角、Emoji)
/// - 4:Tab 字符(制表符占 4 格)
pub fn char_width(c: char) -> usize {
let cp = c as u32;

// Tab 字符特殊处理:占 4 格
if cp == 0x09 {
return 4;
}

// ===== 零宽度字符 =====
if is_zero_width(cp) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion crates/aether-render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ aether-core = { path = "../aether-core" }
rustc-hash = "2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
windows = { version = "0.58", features = ["Win32_Graphics_Direct2D", "Win32_Graphics_Direct2D_Common", "Win32_Graphics_Dxgi", "Win32_Graphics_Dxgi_Common", "Win32_Graphics_DirectWrite", "Win32_Graphics_Gdi", "Win32_Foundation", "Foundation_Numerics", "Win32_System_Performance", "Win32_System_SystemInformation", "Win32_UI_HiDpi"] }
windows = { version = "0.58", features = ["Win32_Graphics_Direct2D", "Win32_Graphics_Direct2D_Common", "Win32_Graphics_Dxgi", "Win32_Graphics_Dxgi_Common", "Win32_Graphics_DirectWrite", "Win32_Graphics_Gdi", "Win32_Foundation", "Foundation_Numerics", "Win32_System_Performance", "Win32_System_SystemInformation", "Win32_UI_HiDpi", "Win32_Graphics_Direct3D11", "Win32_Graphics_Direct3D", "Win32_Graphics_Direct3D_Fxc", "Win32_Graphics_Hlsl"] }
12 changes: 11 additions & 1 deletion crates/aether-render/src/d2d/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,17 @@ impl RenderTarget {
},
geometricMask: ManuallyDrop::new(Some(group_as_geometry)),
maskAntialiasMode: windows::Win32::Graphics::Direct2D::D2D1_ANTIALIAS_MODE_ALIASED,
maskTransform: Matrix3x2::default(),
// 单位矩阵:保持掩码几何在原始坐标空间。
// 注意:Matrix3x2::default() 为全零矩阵(退化变换),会把掩码塌缩为单点,
// 导致裁剪帧内所有绘制被丢弃(多矩形脏矩形重绘不生效)。
maskTransform: Matrix3x2 {
M11: 1.0,
M12: 0.0,
M21: 0.0,
M22: 1.0,
M31: 0.0,
M32: 0.0,
},
opacity: 1.0,
opacityBrush: ManuallyDrop::new(None),
layerOptions: windows::Win32::Graphics::Direct2D::D2D1_LAYER_OPTIONS_NONE,
Expand Down
Loading
Loading