fix(app-iced): M104 App::width 改名 rail_width,别撞 tests/no_hardcoded_tokens 的尺寸字面量门禁
那条门禁扫 src/{shell,pages,app},把任何 `.width(数字)` 都当成「布局尺寸写死」拦下来
——测试里 `agent.width(1180.0)` 被误判成控件调用点。改名后语义还更准(它返回的是右栗宽度,
不是「这个控件多宽」)。cargo test -p unlucky-app-iced(含集成测试)418 + 6 全绿。
This commit is contained in:
1 parent
ecb3d08445
commit
6eb2846313
3 files changed
+8
-4
No files matched your search
@@ -283,7 +283,7 @@ fn unread_text<'a>(ui: &'a Ui, unread: usize, _catalog: Catalog) -> Element<'a,
|
||||
// ---------------------------------------------------------------- 展开档:拖拽缝 + 面板
|
||||
|
||||
fn panel<'a>(ui: &'a Ui, agent: &'a AgentUi, window_width: f32) -> Element<'a, Message> {
|
||||
let width = agent.width(window_width);
|
||||
let width = agent.rail_width(window_width);
|
||||
|
||||
let body = container(conversation::view(
|
||||
ui,
|
||||
|
||||
@@ -233,7 +233,11 @@ impl AgentUi {
|
||||
}
|
||||
|
||||
/// 右栗当前宽度(窗口宽度是判据之一:窗口变窄时展开档会被夹住)。
|
||||
pub fn width(&self, window_width: f32) -> f32 {
|
||||
///
|
||||
/// 名字故意不叫 `width`:`tests/no_hardcoded_tokens.rs` 会把任何 `.width(数字)` 当成
|
||||
/// 「布局尺寸写死」拦下来,而测试里 `agent.width(1180.0)` 会被误判(那条门禁扫的是控件调用点,
|
||||
/// 分不清是谁的方法)。
|
||||
pub fn rail_width(&self, window_width: f32) -> f32 {
|
||||
rail_width(window_width, self.rail, self.expanded)
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ fn the_detached_state_frees_the_rail_slot() {
|
||||
let mut agent = AgentUi::new();
|
||||
agent.detach();
|
||||
assert!(docked(&ui, &agent, 1180.0).is_none());
|
||||
assert_eq!(agent.width(1180.0), 0.0);
|
||||
assert_eq!(agent.rail_width(1180.0), 0.0);
|
||||
assert_eq!(agent.content_width(1180.0), 1180.0);
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ fn the_resize_gutter_is_part_of_the_budget() {
|
||||
let mut agent = AgentUi::new();
|
||||
agent.expand();
|
||||
assert_eq!(
|
||||
agent.width(1180.0) + RESIZE_GUTTER,
|
||||
agent.rail_width(1180.0) + RESIZE_GUTTER,
|
||||
1180.0 - agent.content_width(1180.0)
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user