From 36f66d80113cb34ffbf06c4efde2153df3791f83 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Thu, 19 Nov 2026 13:56:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20Go=20=E8=AE=BE=E7=BD=AE=E9=A1=B5?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E8=B7=9F=E9=9A=8F=E8=AE=BE=E7=BD=AE=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E5=AE=BD=E5=BA=A6=E9=87=8D=E6=96=B0=E6=8E=92=E7=89=88?= =?UTF-8?q?=EF=BC=881.4.0=20=E9=A2=84=E5=8F=91=E5=B8=83=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 视图事件带 width 时,语言页四张卡片按宽度排列:放得下两张最窄卡片 (≥594)时两张一行,否则一张一行,卡片随宽度变宽、字号不变;构建系统页 的步骤卡片随宽度变宽,长 go 路径显示更多。 - 画布声明 on: ["resize"],宿主在宽度稳定后发 resize,后端按新宽度重画; 事件没有 width 时(桌面端 0.8.7、0.8.8)按最窄窗口排版且不声明 resize, 和 1.3.0 相同。 - 点亮的标签在选中底色上改用 $text 写字:accent 蓝字在深色外观下对比度 只有约 2.2:1。 - 后端 SDK 固定到 Lithe-core-rust#109(0b6da27);e2e 宿主固定到 1lck/Lithe-IDEA#2191 的分支提交 312a9c63a,设置视图测试带区域宽度, 并以 760 发 resize 检查重画。 - 版本 1.4.0,发布工作流把 v1.4.0 列为预发布;README、发布说明和功能 矩阵同步,并更正矩阵里“#2183 已按 min 缩放”的错误说法。 --- .github/workflows/release.yml | 6 +- README.md | 13 +- backend/Cargo.lock | 4 +- backend/Cargo.toml | 8 +- backend/src/language.rs | 202 +++++++++++++----- backend/src/main.rs | 185 ++++++++++++++-- backend/src/resolution.rs | 72 ++++--- backend/src/scene.rs | 12 +- docs/feature-matrix.md | 40 ++-- docs/releases/v1.4.0.md | 22 ++ ...ficial_go_plugin_settings_view_e2e_test.go | 48 ++++- e2e/host/lithe-host.json | 4 +- io.github.lithe-idea.go-support/plugin.json | 2 +- 13 files changed, 478 insertions(+), 140 deletions(-) create mode 100644 docs/releases/v1.4.0.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 29c66c0..5c35359 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,7 +85,11 @@ jobs: # v1.2.0 (type icons, 1lck/Lithe-IDEA#2169) and v1.3.0 (settings regions, # 1lck/Lithe-IDEA#2183) were published as pre-releases and switched to # stable once desktop 0.8.7 shipped both host changes. - PRERELEASE_TAGS: v0.0.1 v1.0.0 + # v1.4.0 lays the settings previews out at the view width and redraws + # them on resize (1lck/Lithe-IDEA#2191, Lithe-core-rust#109), which no + # desktop release has yet; older hosts send no width and get the 1.3.0 + # layout. It switches to stable once a desktop release ships #2191. + PRERELEASE_TAGS: v0.0.1 v1.0.0 v1.4.0 run: | prerelease=false for tag in $PRERELEASE_TAGS; do diff --git a/README.md b/README.md index e747adf..1a1065d 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,10 @@ gopls、go 和 dlv 仍然用你电脑上的。 > [Lithe-core-rust#104](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/104) 的 Core),桌面端 0.8.7 起包含它。 > 1.2.0 和 1.3.0 都作为正式版本发布并收录到 Lithe Store。桌面端 0.8.6 也支持 `ui` 0 和 `backend` 0, > Store 按 `requires` 挡不住它,但它不认识 `settingRegions`,安装或更新到 1.3.0 会失败,需要先把桌面端更新到 0.8.7 或更新版本。 +> 1.4.0 让这两个预览按设置窗口的实际宽度重新排版,窗口宽度变化后跟着重排;这要靠告诉插件视图宽度的桌面端 +> ([1lck/Lithe-IDEA#2191](https://github.com/1lck/Lithe-IDEA/pull/2191),固定了 +> [Lithe-core-rust#109](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/109) 的 Core),还没有桌面端版本包含它, +> 所以 1.4.0 作为预发布版本发布。桌面端 0.8.7、0.8.8 不发送宽度,1.4.0 在上面按最小设置窗口排版,和 1.3.0 相同。 ## 功能 @@ -261,7 +265,7 @@ CI 在 macOS、Windows x64 和 Windows ARM64 上跑这个脚本,Windows 上测 ```bash node scripts/build-backend.mjs darwin node scripts/package.mjs --platforms darwin -LITHE_TEST_GO_PLUGIN_ARCHIVE="$PWD/dist/go-support-1.3.0-darwin.zip" node scripts/e2e-host.mjs +LITHE_TEST_GO_PLUGIN_ARCHIVE="$PWD/dist/go-support-1.4.0-darwin.zip" node scripts/e2e-host.mjs ``` 插件包路径要写绝对路径。脚本把固定版本的宿主(只取 `desktop/` 和 `scripts/`)检出到 `.artifacts/lithe-host`, @@ -287,9 +291,10 @@ Lithe 主仓库的功能矩阵不收录插件能力,改动插件行为时在 3. `Release` 工作流会核对标签与版本一致、打包并发布 Release(说明里附 SHA-256 和 `docs/releases/v<版本>.md`)。`release.yml` 里 `PRERELEASE_TAGS` 列出的版本会标为预发布版本: - 目前是只能装进新版桌面端的 `v0.0.1` 和依赖宿主 #1954、#1964、#1971 的 `v1.0.0`; - `v1.0.1`、`v1.1.0`、`v1.2.0` 和 `v1.3.0` 是正式版本。`v1.2.0` 和 `v1.3.0` 先以预发布发布, - 桌面端 0.8.7 带上它们依赖的 #2169 和 #2183 后改为正式版本。 + 目前是只能装进新版桌面端的 `v0.0.1`、依赖宿主 #1954、#1964、#1971 的 `v1.0.0`, + 以及依赖宿主 #2191 的 `v1.4.0`;`v1.0.1`、`v1.1.0`、`v1.2.0` 和 `v1.3.0` 是正式版本。 + `v1.2.0` 和 `v1.3.0` 先以预发布发布,桌面端 0.8.7 带上它们依赖的 #2169 和 #2183 后改为正式版本; + `v1.4.0` 等发布了包含 #2191 的桌面端后同样改为正式版本。 4. Lithe Store 的自动追踪会发现稳定版本并开合并请求,合并后用户即可在 Lithe 中更新。自动追踪会跳过预发布版本; 需要收录时在 Store 中手工提交条目,并使用已发布 ZIP 的实际 SHA-256。 diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 9a21662..89b5b31 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -10,7 +10,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "go-support-backend" -version = "1.3.0" +version = "1.4.0" dependencies = [ "lithe-plugin-sdk", "serde_json", @@ -25,7 +25,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" [[package]] name = "lithe-plugin-sdk" version = "0.4.0" -source = "git+https://github.com/Lithe-IDEA/Lithe-core-rust?rev=545ca11fb971795a9937f0f60bcc29afebe3b8be#545ca11fb971795a9937f0f60bcc29afebe3b8be" +source = "git+https://github.com/Lithe-IDEA/Lithe-core-rust?rev=0b6da2725ded74de7c3b62b49d12c1947dc0a38a#0b6da2725ded74de7c3b62b49d12c1947dc0a38a" dependencies = [ "base64", "serde_json", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index ae402f3..7b79b67 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -2,7 +2,7 @@ name = "go-support-backend" description = "The Go Support plugin's backend: the previews its settings regions draw." # Kept equal to the plugin's version; scripts/package.mjs refuses a mismatch. -version = "1.3.0" +version = "1.4.0" edition = "2021" license = "Apache-2.0" rust-version = "1.87" @@ -14,9 +14,9 @@ path = "src/main.rs" [dependencies] # The Rust plugin SDK has no release tag yet; this is Lithe-core-rust main with -# the plugin views contract (Lithe-core-rust#104), the Core that host -# 1lck/Lithe-IDEA#2183 pins. -lithe-plugin-sdk = { git = "https://github.com/Lithe-IDEA/Lithe-core-rust", rev = "545ca11fb971795a9937f0f60bcc29afebe3b8be" } +# the view width and the resize event (Lithe-core-rust#109) on top of the +# plugin views contract (Lithe-core-rust#104). +lithe-plugin-sdk = { git = "https://github.com/Lithe-IDEA/Lithe-core-rust", rev = "0b6da2725ded74de7c3b62b49d12c1947dc0a38a" } serde_json = "1" [profile.release] diff --git a/backend/src/language.rs b/backend/src/language.rs index 4038e35..ea0f63a 100644 --- a/backend/src/language.rs +++ b/backend/src/language.rs @@ -1,14 +1,16 @@ //! The Go language page's preview: what each gopls option does to a piece of //! code, in four cards that follow the rows below them. //! -//! The scene is drawn for the region's width in the smallest settings -//! window, 613 points as measured in the host, so a unit is a point there. -//! The code in the editor-like boxes is laid out on the scene's own -//! monospace grid, so the marks on it line up in every host font. +//! The scene is as wide as the view the host reports, so a unit is a point: +//! the cards stand two to a row when two of the narrowest fit, else one above +//! the other, and widen with the window. A host that reports no width gets +//! the scene for the region in the smallest settings window, 613 points as +//! measured in the host. The code in the editor-like boxes is laid out on the +//! scene's own monospace grid, so the marks on it line up in every host font. use crate::scene::{ - code, column, group, pair, path, pill, rect, runs, squiggle, text, token, Node, - MONO_ADVANCE, + code, column, group, pair, path, pill, rect, runs, squiggle, text, text_width, token, Node, + MONO_ADVANCE, STRONG, }; use crate::settings::{Hover, Settings}; use crate::words::Words; @@ -19,22 +21,65 @@ pub const CANVAS_ID: &str = "gopls-preview"; /// The settings the cards show; a draft of any of them marks the preview. pub const SETTINGS: [&str; 4] = ["hoverKind", "usePlaceholders", "gofumpt", "staticcheck"]; -pub const WIDTH: f64 = 610.0; +/// The scene's width for a host that reports none. +pub const DEFAULT_WIDTH: f64 = 610.0; +/// The narrowest card: the longest Staticcheck line and its squiggle end 256 +/// units into the box, and the pill keeps room beside the longest title. A +/// view narrower than one such card is scaled down by the host. +pub const MIN_CARD_W: f64 = 292.0; const HEADER: f64 = 28.0; const GAP: f64 = 10.0; -const CARD_W: f64 = (WIDTH - GAP) / 2.0; /// A card's title row, the line under it that says what the value does, and /// the editor-like box below them. const TITLE_Y: f64 = 22.0; const NOTE_Y: f64 = 41.0; const BOX_X: f64 = 10.0; const BOX_Y: f64 = 50.0; -const BOX_W: f64 = CARD_W - 2.0 * BOX_X; -/// The box heights of the first row (hover, completion) and the second -/// (gofumpt, Staticcheck): the hover's full documentation needs the most. +/// The box heights of the hover and completion cards and of the gofumpt and +/// Staticcheck ones: the hover's full documentation needs the most. const BOX_H: [f64; 2] = [124.0, 108.0]; const CARD_H: [f64; 2] = [BOX_Y + BOX_H[0] + BOX_X, BOX_Y + BOX_H[1] + BOX_X]; -pub const HEIGHT: f64 = HEADER + CARD_H[0] + GAP + CARD_H[1]; + +/// Where the four cards go in a scene of a given width. +pub struct Layout { + pub width: f64, + /// Two when two of the narrowest cards fit side by side, else one. + pub columns: usize, + card_w: f64, +} + +impl Layout { + pub fn new(width: Option) -> Self { + let width = width.unwrap_or(DEFAULT_WIDTH).max(MIN_CARD_W); + let columns = if width >= 2.0 * MIN_CARD_W + GAP { 2 } else { 1 }; + let card_w = (width - (columns - 1) as f64 * GAP) / columns as f64; + Self { + width, + columns, + card_w, + } + } + + fn box_w(&self) -> f64 { + self.card_w - 2.0 * BOX_X + } + + /// The top-left corner of each card, row after row, and the scene's + /// height under the last row. The cards of a row are one height: the + /// hover and completion ones, or the gofumpt and Staticcheck ones. + fn places(&self) -> ([(f64, f64); 4], f64) { + let mut places = [(0.0, 0.0); 4]; + let mut y = HEADER; + for (index, place) in places.iter_mut().enumerate() { + let column = index % self.columns; + if index > 0 && column == 0 { + y += CARD_H[(index - 1) / 2] + GAP; + } + *place = (column as f64 * (self.card_w + GAP), y); + } + (places, y + CARD_H[1]) + } +} /// Code colors after the IDE themes Lithe's editor follows. fn keyword() -> Value { @@ -72,12 +117,17 @@ struct Card<'a> { preview: Vec, } -pub fn canvas(settings: &Settings, words: &Words) -> Value { +/// The preview for a view `width` points wide, or for the smallest settings +/// window when the host reports no width. A host that reports it sends +/// `resize` with the new width, and the scene is drawn again for it. +pub fn canvas(settings: &Settings, words: &Words, width: Option) -> Value { + let layout = Layout::new(width); + let box_w = layout.box_w(); let changed = settings.any_changed(&SETTINGS); let mut nodes = vec![ text(0.0, 17.0, words.preview_title, "strong"), text( - WIDTH, + layout.width, 17.0, if changed { words.includes_draft @@ -87,7 +137,8 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { "caption", ) .align("end") - .color(token(if changed { "$accent" } else { "$textMuted" })), + .color(token(if changed { "$accent" } else { "$textMuted" })) + .max_width(layout.width - text_width(words.preview_title, STRONG) - 16.0), ]; let hover = Hover::ALL .iter() @@ -111,7 +162,7 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { lit: true, note: words.hover_notes[hover], changed: settings.is_changed("hoverKind"), - preview: hover_preview(settings.hover), + preview: hover_preview(settings.hover, box_w), }, Card { title: words.completion_title, @@ -119,7 +170,7 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { lit: settings.placeholders, note: placeholders_note, changed: settings.is_changed("usePlaceholders"), - preview: completion_preview(settings.placeholders, words), + preview: completion_preview(settings.placeholders, words, box_w), }, Card { title: words.format_title, @@ -127,7 +178,7 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { lit: settings.gofumpt, note: gofumpt_note, changed: settings.is_changed("gofumpt"), - preview: format_preview(settings.gofumpt), + preview: format_preview(settings.gofumpt, box_w), }, Card { title: words.staticcheck_title, @@ -135,39 +186,42 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { lit: settings.staticcheck, note: staticcheck_note, changed: settings.is_changed("staticcheck"), - preview: staticcheck_preview(settings.staticcheck), + preview: staticcheck_preview(settings.staticcheck, box_w), }, ]; - for (index, card) in cards.into_iter().enumerate() { - let row = index / 2; - let x = (index % 2) as f64 * (CARD_W + GAP); - let y = HEADER + row as f64 * (CARD_H[0] + GAP); - nodes.push(group(x, y, draw(card, row))); + let (places, height) = layout.places(); + for (index, (card, (x, y))) in cards.into_iter().zip(places).enumerate() { + nodes.push(group(x, y, draw(card, index / 2, layout.card_w))); } - json!({ + let mut canvas = json!({ "type": "canvas", "id": CANVAS_ID, "label": words.preview_label, - "height": HEIGHT.ceil() as u64, - "viewBox": [0, 0, WIDTH, HEIGHT], + "height": height.ceil() as u64, + "viewBox": [0, 0, layout.width, height], "nodes": nodes.into_iter().map(Value::from).collect::>(), - }) + }); + if width.is_some() { + canvas["on"] = json!(["resize"]); + } + canvas } -/// A card in row `row`: its title, a pill with the value shown and, when -/// that value is a draft, an accent outline and a dot in front of the pill; -/// the line saying what the value does; then the preview in an editor-like -/// box. -fn draw(card: Card, row: usize) -> Vec { +/// A card `card_w` wide whose box is `BOX_H[kind]` tall: its title, a pill +/// with the value shown and, when that value is a draft, an accent outline +/// and a dot in front of the pill; the line saying what the value does; then +/// the preview in an editor-like box. A lit pill writes in `$text`: accent ink +/// on the selection fill falls to about 2:1 in Lithe's dark theme. +fn draw(card: Card, kind: usize, card_w: f64) -> Vec { let (fill, ink) = if card.lit { - (token("$selection"), token("$accent")) + (token("$selection"), token("$text")) } else { (token("$badge"), token("$textSecondary")) }; let (_, width) = pill(0.0, 0.0, card.value, fill.clone(), ink.clone()); - let pill_x = CARD_W - 12.0 - width; + let pill_x = card_w - 12.0 - width; let (pill, _) = pill(pill_x, 8.0, card.value, fill, ink); - let frame = rect(0.0, 0.0, CARD_W, CARD_H[row]) + let frame = rect(0.0, 0.0, card_w, CARD_H[kind]) .radius(8.0) .fill(token("$surface")); let mut nodes = vec![ @@ -180,8 +234,8 @@ fn draw(card: Card, row: usize) -> Vec { pill, text(12.0, NOTE_Y, card.note, "caption") .color(token("$textSecondary")) - .max_width(CARD_W - 24.0), - rect(BOX_X, BOX_Y, BOX_W, BOX_H[row]) + .max_width(card_w - 24.0), + rect(BOX_X, BOX_Y, card_w - 2.0 * BOX_X, BOX_H[kind]) .radius(6.0) .fill(editor()) .stroke(token("$line"), 1.0), @@ -197,14 +251,14 @@ fn draw(card: Card, row: usize) -> Vec { nodes } -/// A hover over `strings.Split`, with as much documentation as `hover` shows. -/// The documentation is Go's own, which gopls shows as it is, wrapped to the -/// popup. -fn hover_preview(hover: Hover) -> Vec { +/// A hover over `strings.Split` in a box `box_w` wide, with as much +/// documentation as `hover` shows. The documentation is Go's own, which gopls +/// shows as it is, wrapped to the popup. +fn hover_preview(hover: Hover, box_w: f64) -> Vec { const POPUP_X: f64 = 4.0; - const POPUP_W: f64 = BOX_W - 2.0 * POPUP_X; const INSET: f64 = 9.0; - const TEXT_W: f64 = POPUP_W - 2.0 * INSET; + let popup_w = box_w - 2.0 * POPUP_X; + let text_w = popup_w - 2.0 * INSET; let code_x = 10.0; let signature = || { runs( @@ -224,9 +278,9 @@ fn hover_preview(hover: Hover) -> Vec { let doc = |y: f64, line: &str| { text(INSET, y, line, "caption") .color(token("$textSecondary")) - .max_width(TEXT_W) + .max_width(text_w) }; - let divider = || rect(INSET, 21.0, TEXT_W, 1.0).fill(token("$line")); + let divider = || rect(INSET, 21.0, text_w, 1.0).fill(token("$line")); let synopsis = || { [ doc(34.0, "Split slices s into all substrings separated"), @@ -257,11 +311,11 @@ fn hover_preview(hover: Hover) -> Vec { "func strings.Split(s string, sep string) []string", "caption", ) - .max_width(TEXT_W)], + .max_width(text_w)], ), Hover::Signature => (22.0, vec![signature()]), }; - let mut frame = vec![rect(0.0, 0.0, POPUP_W, height) + let mut frame = vec![rect(0.0, 0.0, popup_w, height) .radius(6.0) .fill(popup()) .stroke(token("$line"), 1.0) @@ -285,17 +339,18 @@ fn hover_preview(hover: Hover) -> Vec { nodes } -/// Completing `strings.Spl`, with and without parameter placeholders. -fn completion_preview(placeholders: bool, words: &Words) -> Vec { +/// Completing `strings.Spl` in a box `box_w` wide, with and without +/// parameter placeholders. +fn completion_preview(placeholders: bool, words: &Words, box_w: f64) -> Vec { let code_x = 10.0; let label = |y: f64, words: &str| { text(code_x, y, words, "caption") .color(token("$textMuted")) - .max_width(BOX_W - 2.0 * code_x) + .max_width(box_w - 2.0 * code_x) }; let caret = |x: f64, y: f64| rect(x, y - 10.5, 1.2, 13.0).fill(plain()); let list_x = column(code_x, 9); - let list_w = BOX_W - list_x - 10.0; + let list_w = box_w - list_x - 10.0; let mut nodes = vec![label(17.0, words.before)]; nodes.extend(code(code_x, 35.0, &[("parts := strings.Spl", plain())])); nodes.extend([ @@ -387,9 +442,9 @@ fn numbered(lines: Vec>) -> Vec { nodes } -/// The same function as gofmt and as gofumpt format it; what gofumpt changes -/// is tinted. -fn format_preview(gofumpt: bool) -> Vec { +/// The same function as gofmt and as gofumpt format it, in a box `box_w` +/// wide; what gofumpt changes is tinted. +fn format_preview(gofumpt: bool, box_w: f64) -> Vec { let signature = vec![ ("func ", keyword()), ("save", function()), @@ -414,7 +469,7 @@ fn format_preview(gofumpt: bool) -> Vec { } let mut nodes = vec![ // The line the blank one closed up into, and the new octal literal. - rect(0.0, CODE_TOP + LINE - 12.0, BOX_W, LINE) + rect(0.0, CODE_TOP + LINE - 12.0, box_w, LINE) .fill(token("$success")) .opacity(0.08), rect(column(CODE_X, 23) - 2.0, CODE_TOP + LINE - 12.0, 5.0 * MONO_ADVANCE + 4.0, LINE) @@ -427,8 +482,8 @@ fn format_preview(gofumpt: bool) -> Vec { } /// A comparison staticcheck's SA6005 reports and gopls's default analyses -/// do not. The message is staticcheck's own. -fn staticcheck_preview(staticcheck: bool) -> Vec { +/// do not, in a box `box_w` wide. The message is staticcheck's own. +fn staticcheck_preview(staticcheck: bool, box_w: f64) -> Vec { let mut nodes = numbered(vec![ vec![ ("func ", keyword()), @@ -466,7 +521,7 @@ fn staticcheck_preview(staticcheck: bool) -> Vec { .stroke(token("$warning"), 1.0), ); } - let bar_w = BOX_W - 12.0; + let bar_w = box_w - 12.0; nodes.push(group( 6.0, CODE_TOP + 3.0 * LINE + 10.0, @@ -492,3 +547,32 @@ fn staticcheck_preview(staticcheck: bool) -> Vec { )); nodes } + +#[cfg(test)] +mod tests { + use super::*; + use crate::scene::CAPTION; + use crate::words; + + #[test] + fn every_title_keeps_its_room_beside_its_pill_in_the_narrowest_card() { + for language in ["en", "zh-Hans"] { + let words = words::for_language(language); + let hover = words + .hover_options + .iter() + .map(|value| (words.hover_title, *value)); + let switches = [words.completion_title, words.format_title, words.staticcheck_title] + .into_iter() + .flat_map(|title| [(title, words.on), (title, words.off)]); + for (title, value) in hover.chain(switches) { + // As `draw` places them: the pill 12 units from the card's + // right edge, the title from 12 units and 18 short of the pill. + let pill_x = MIN_CARD_W - 12.0 - (text_width(value, CAPTION) + 16.0); + let room = pill_x - 12.0 - 18.0; + let title_w = text_width(title, STRONG); + assert!(title_w <= room, "{language}: {title} ({title_w}) beside {value} ({room})"); + } + } + } +} diff --git a/backend/src/main.rs b/backend/src/main.rs index 168b69d..ac6a454 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -37,10 +37,10 @@ fn main() { } fn view(event: ViewEvent, context: &Context) -> Result { - let nodes = match event.kind { - ViewEventKind::Open | ViewEventKind::Settings => render(&event)?, - _ => return Ok(ViewResult::Unchanged), - }; + if !redraws(&event.kind) { + return Ok(ViewResult::Unchanged); + } + let nodes = render(&event)?; if nodes.1 > 0 { context .diagnostics() @@ -49,8 +49,18 @@ fn view(event: ViewEvent, context: &Context) -> Result bool { + matches!( + kind, + ViewEventKind::Open | ViewEventKind::Settings | ViewEventKind::Resize + ) +} + +/// The nodes of the event's region, laid out for the width the event +/// carries, and how many settings held a value the preview could not read +/// and shows as the default. fn render(event: &ViewEvent) -> Result<(Vec, u64), PluginError> { let ViewSurface::SettingRegion(region) = &event.surface else { return Err(unknown_region()); @@ -58,8 +68,8 @@ fn render(event: &ViewEvent) -> Result<(Vec, u64), PluginError> { let settings = Settings::read(event); let words = words::for_language(&event.language); let canvas = match region.as_str() { - LANGUAGE_REGION => language::canvas(&settings, words), - TOOLCHAIN_REGION => resolution::canvas(&settings, words), + LANGUAGE_REGION => language::canvas(&settings, words, event.width), + TOOLCHAIN_REGION => resolution::canvas(&settings, words, event.width), _ => return Err(unknown_region()), }; Ok((vec![canvas], settings.unrecognized)) @@ -78,20 +88,74 @@ mod tests { use serde_json::Map; fn event(region: &str, language: &str, effective: Value, draft: Value) -> ViewEvent { - ViewEvent::parse(&json!({ - "event": "settings", + event_at("settings", region, language, None, effective, draft) + } + + /// A `kind` event for `region`, with the view's width when the host + /// reports it. + fn event_at( + kind: &str, + region: &str, + language: &str, + width: Option, + effective: Value, + draft: Value, + ) -> ViewEvent { + let mut event = json!({ + "event": kind, "instance": "i1", "surface": { "settingRegionID": region }, "language": language, "settings": { "effective": effective, "draft": draft }, - })) - .unwrap() + }); + if let Some(width) = width { + event["width"] = json!(width); + } + ViewEvent::parse(&event).unwrap() } fn nodes(region: &str, language: &str, effective: Value, draft: Value) -> Vec { render(&event(region, language, effective, draft)).unwrap().0 } + fn nodes_at(region: &str, language: &str, width: f64, effective: Value, draft: Value) -> Vec { + let event = event_at("resize", region, language, Some(width), effective, draft); + render(&event).unwrap().0 + } + + /// How far right what `nodes` draws reaches, in view-box units, from a + /// parent at `x0`: rects, code characters, text that ends at its x and + /// text cut at a maximum width. Other text has no extent the plugin + /// knows, and paths are drawn inside the rects here. + fn right_edge(nodes: &[Value], x0: f64) -> f64 { + let mut edge: f64 = 0.0; + for node in nodes { + let x = x0 + node.get("x").and_then(Value::as_f64).unwrap_or(0.0); + let character = node["style"] == "monoSmall" + && node["text"].as_str().is_some_and(|text| text.chars().count() == 1); + let reach = match (node["type"].as_str(), node.get("align").and_then(Value::as_str)) { + (Some("rect"), _) => x + node["w"].as_f64().unwrap(), + (Some("text"), Some("end")) => x, + (Some("text"), None) if character => x + scene::MONO_ADVANCE, + (Some("text"), None) => node + .get("maxWidth") + .and_then(Value::as_f64) + .map_or(0.0, |width| x + width), + _ => 0.0, + }; + edge = edge.max(reach); + for key in ["children", "nodes"] { + if let Some(children) = node.get(key).and_then(Value::as_array) { + edge = edge.max(right_edge(children, x)); + } + } + } + edge + } + + /// Room for the rounding of positions and sizes to tenths. + const ROUNDING: f64 = 0.1; + /// Every node of a scene, the nested ones included. fn walk<'a>(node: &'a Value, out: &mut Vec<&'a Value>) { out.push(node); @@ -238,8 +302,14 @@ mod tests { /// pane. const REGION_WIDTHS: [(&str, f64); 2] = [(LANGUAGE_REGION, 613.0), (TOOLCHAIN_REGION, 344.0)]; + /// The narrowest scene of each region; a narrower view is scaled down. + const MIN_WIDTHS: [(&str, f64); 2] = [ + (LANGUAGE_REGION, language::MIN_CARD_W), + (TOOLCHAIN_REGION, resolution::MIN_WIDTH), + ]; + #[test] - fn each_scene_fits_its_region_one_unit_to_a_point() { + fn without_a_width_each_scene_fits_its_region_in_the_smallest_window() { for (region, width) in REGION_WIDTHS { for language in ["en", "zh-Hans"] { let nodes = nodes(region, language, json!({}), json!({})); @@ -253,10 +323,99 @@ mod tests { "{region}" ); assert!(nodes[0].get("pan").is_none()); + // A host that reports no width cannot send resize, and one + // from before resize existed rejects the word. + assert!(nodes[0].get("on").is_none(), "{region}"); + } + } + } + + #[test] + fn each_scene_is_as_wide_as_the_view_and_draws_inside_it() { + let widths = [330.0, 344.0, 480.0, 593.0, 594.0, 613.0, 900.0, 1400.0]; + for (region, _) in REGION_WIDTHS { + for language in ["en", "zh-Hans"] { + for (effective, draft) in settings_cases() { + for width in widths { + let nodes = nodes_at(region, language, width, effective.clone(), draft.clone()); + check_limits(&nodes); + let canvas = &nodes[0]; + let view_box = canvas["viewBox"].as_array().unwrap(); + assert_eq!(view_box[2].as_f64().unwrap(), width, "{region} at {width}"); + assert_eq!( + canvas["height"].as_f64().unwrap(), + view_box[3].as_f64().unwrap().ceil(), + "{region} at {width}" + ); + assert!(canvas.get("pan").is_none()); + assert_eq!(canvas["on"], json!(["resize"]), "{region} at {width}"); + let reach = right_edge(std::slice::from_ref(canvas), 0.0); + assert!(reach <= width + ROUNDING, "{region} {language} at {width}: {reach}"); + } + } } } } + #[test] + fn a_view_narrower_than_the_narrowest_scene_gets_the_narrowest() { + for (region, min) in MIN_WIDTHS { + let nodes = nodes_at(region, "en", 200.0, json!({}), json!({})); + assert_eq!(nodes[0]["viewBox"][2].as_f64().unwrap(), min, "{region}"); + } + } + + /// The x and the content's reach of each language card, the frame first + /// among each card's children. + fn cards(width: f64, language: &str) -> Vec<(f64, f64, f64)> { + let nodes = nodes_at( + LANGUAGE_REGION, + language, + width, + json!({ "usePlaceholders": true, "gofumpt": true, "staticcheck": true }), + json!({}), + ); + nodes[0]["nodes"] + .as_array() + .unwrap() + .iter() + .filter(|node| node["type"] == "group") + .map(|card| { + let children = card["children"].as_array().unwrap(); + let frame = children[0]["w"].as_f64().unwrap(); + (card["x"].as_f64().unwrap(), frame, right_edge(children, 0.0)) + }) + .collect() + } + + #[test] + fn the_cards_stand_two_to_a_row_only_when_two_of_the_narrowest_fit() { + let two = 2.0 * language::MIN_CARD_W + 10.0; + for language in ["en", "zh-Hans"] { + for (width, columns) in [(two - 1.0, 1), (two, 2), (1400.0, 2), (330.0, 1)] { + let cards = cards(width, language); + assert_eq!(cards.len(), 4); + let beside = cards.iter().filter(|(x, ..)| *x > 0.0).count(); + assert_eq!(beside, if columns == 2 { 2 } else { 0 }, "{language} at {width}"); + for (x, frame, reach) in cards { + assert!(reach <= frame + ROUNDING, "{language} at {width}: {reach} past {frame}"); + assert!(x + frame <= width + ROUNDING, "{language} at {width}"); + } + } + } + } + + #[test] + fn a_resize_draws_the_view_again_for_the_new_width() { + assert!(redraws(&ViewEventKind::Resize)); + assert!(redraws(&ViewEventKind::Open) && redraws(&ViewEventKind::Settings)); + assert!(!redraws(&ViewEventKind::Close) && !redraws(&ViewEventKind::Viewport)); + for (region, _) in REGION_WIDTHS { + let wide = nodes_at(region, "en", 760.0, json!({}), json!({})); + assert_eq!(wide[0]["viewBox"][2], json!(760.0), "{region}"); + } + } + #[test] fn each_region_draws_its_own_preview() { for (region, id) in [ diff --git a/backend/src/resolution.rs b/backend/src/resolution.rs index 6f0ef0d..1ca1929 100644 --- a/backend/src/resolution.rs +++ b/backend/src/resolution.rs @@ -8,34 +8,39 @@ //! //! The region sits in the build system page's detail pane, 344 points wide //! in the smallest settings window as measured in the host, so the steps -//! stand one above the other, numbered on a rail, and a unit is a point. +//! stand one above the other, numbered on a rail. The scene is as wide as +//! the view the host reports, so a unit is a point and the steps widen with +//! the window; a host that reports no width gets the smallest window's. -use crate::scene::{group, pair, path, pill, rect, tail, text, text_width, token, Node, CAPTION}; +use crate::scene::{ + group, pair, path, pill, rect, tail, text, text_width, token, Node, CAPTION, MONO_ADVANCE, +}; use crate::settings::Settings; use crate::words::Words; use serde_json::{json, Value}; pub const CANVAS_ID: &str = "go-resolution"; -pub const WIDTH: f64 = 340.0; +/// The scene's width for a host that reports none. +pub const DEFAULT_WIDTH: f64 = 340.0; +/// The narrowest scene: the row of uses fits it in both languages. A view +/// narrower than it is scaled down by the host. +pub const MIN_WIDTH: f64 = 330.0; const HEADER: f64 = 28.0; /// The middle of the rail of numbered dots left of the steps. const RAIL: f64 = 11.0; const DOT: f64 = 20.0; const STEP_X: f64 = 30.0; -const STEP_W: f64 = WIDTH - STEP_X; const STEP_H: f64 = 64.0; const STEP_GAP: f64 = 10.0; /// The middle of a step's title row, where its dot sits. const TITLE_MIDDLE: f64 = 17.0; +/// The left edge of a step's lines, and their room on its right. +const LINE_X: f64 = 12.0; /// The top of the row of what the program is used for. const USES_Y: f64 = HEADER + 3.0 * (STEP_H + STEP_GAP) + 4.0; pub const HEIGHT: f64 = USES_Y + 22.0; -/// How many characters of the set path a step shows; the end, which names -/// the program, is kept. -const PATH_ROOM: usize = 42; - /// A step's look: the step in force, a step left out, or one in the order. #[derive(Clone, Copy, PartialEq)] enum Look { @@ -65,7 +70,15 @@ enum Line<'a> { Path(String), } -pub fn canvas(settings: &Settings, words: &Words) -> Value { +/// The diagram for a view `width` points wide, or for the smallest settings +/// window when the host reports no width. A host that reports it sends +/// `resize` with the new width, and the scene is drawn again for it. +pub fn canvas(settings: &Settings, words: &Words, width: Option) -> Value { + let scene_w = width.unwrap_or(DEFAULT_WIDTH).max(MIN_WIDTH); + let step_w = scene_w - STEP_X; + // As many characters of the set path as a line has room for; the end, + // which names the program, is kept. + let path_room = ((step_w - 2.0 * LINE_X) / MONO_ADVANCE).floor() as usize; let changed = settings.is_changed("goExecutable"); let set = !settings.go_executable.is_empty(); let muted = || token("$textMuted"); @@ -76,7 +89,7 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { title: words.step_setting, lines: if set { [ - Line::Path(tail(&settings.go_executable, PATH_ROOM)), + Line::Path(tail(&settings.go_executable, path_room)), Line::Words(words.step_setting_strict, secondary()), ] } else { @@ -125,7 +138,7 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { let mut nodes = vec![text(0.0, 17.0, words.resolution_title, "strong")]; if changed { nodes.push( - text(WIDTH, 17.0, words.includes_draft, "caption") + text(scene_w, 17.0, words.includes_draft, "caption") .align("end") .color(token("$accent")), ); @@ -146,23 +159,27 @@ pub fn canvas(settings: &Settings, words: &Words) -> Value { rail }); } - nodes.push(draw(y, step)); + nodes.push(draw(y, step, step_w)); } nodes.extend(uses(words).0); - json!({ + let mut canvas = json!({ "type": "canvas", "id": CANVAS_ID, "label": words.resolution_label, "height": HEIGHT.ceil() as u64, - "viewBox": [0, 0, WIDTH, HEIGHT], + "viewBox": [0, 0, scene_w, HEIGHT], "nodes": nodes.into_iter().map(Value::from).collect::>(), - }) + }); + if width.is_some() { + canvas["on"] = json!(["resize"]); + } + canvas } -/// A step at `y`: its numbered dot on the rail and its card. -fn draw(y: f64, step: &Step) -> Node { +/// A step at `y`: its numbered dot on the rail and its card, `step_w` wide. +fn draw(y: f64, step: &Step, step_w: f64) -> Node { let in_use = step.look == Look::InUse; - let mut frame = rect(0.0, 0.0, STEP_W, STEP_H).radius(8.0); + let mut frame = rect(0.0, 0.0, step_w, STEP_H).radius(8.0); frame = if in_use { frame.fill(token("$selection")).stroke(token("$accent"), 1.5) } else { @@ -175,25 +192,26 @@ fn draw(y: f64, step: &Step) -> Node { }; let (fill, ink) = match step.chip.1 { Chip::Success => (pair("#E6F4EA", "#253A2B"), token("$success")), - Chip::Accent => (token("$selection"), token("$accent")), + // Accent ink on the selection fill falls to about 2:1 in the dark theme. + Chip::Accent => (token("$selection"), token("$text")), Chip::Neutral => (token("$badge"), token("$textSecondary")), }; let (_, chip_w) = pill(0.0, 0.0, step.chip.0, fill.clone(), ink.clone()); - let chip_x = STEP_W - 10.0 - chip_w; + let chip_x = step_w - 10.0 - chip_w; let (chip, _) = pill(chip_x, TITLE_MIDDLE - 10.0, step.chip.0, fill, ink); let mut card = vec![ frame, - text(12.0, TITLE_MIDDLE + 4.5, step.title, "strong").max_width(chip_x - 12.0 - 10.0), + text(LINE_X, TITLE_MIDDLE + 4.5, step.title, "strong").max_width(chip_x - LINE_X - 10.0), chip, ]; for (line, y) in step.lines.iter().zip([40.0, 55.0]) { card.push(match line { - Line::Words(words, color) => text(12.0, y, words, "caption") + Line::Words(words, color) => text(LINE_X, y, words, "caption") .color(color.clone()) - .max_width(STEP_W - 24.0), - Line::Path(value) => text(12.0, y, value, "monoSmall") + .max_width(step_w - 2.0 * LINE_X), + Line::Path(value) => text(LINE_X, y, value, "monoSmall") .color(token("$text")) - .max_width(STEP_W - 24.0), + .max_width(step_w - 2.0 * LINE_X), }); } let step_group = group( @@ -237,10 +255,10 @@ mod tests { use crate::words; #[test] - fn the_row_of_uses_fits_the_width_in_both_languages() { + fn the_row_of_uses_fits_the_narrowest_scene_in_both_languages() { for language in ["en", "zh-Hans"] { let (_, end) = uses(words::for_language(language)); - assert!(end <= WIDTH, "{language}: {end}"); + assert!(end <= MIN_WIDTH, "{language}: {end}"); } } } diff --git a/backend/src/scene.rs b/backend/src/scene.rs index fe2fec4..df76ab8 100644 --- a/backend/src/scene.rs +++ b/backend/src/scene.rs @@ -3,14 +3,18 @@ //! //! Coordinates are view-box units. A canvas without `pan` shows its whole //! view box, scaled to the view's width but never past its `height`, from -//! the top-left corner. Each scene is drawn for the width its region has in -//! the smallest settings window and is as tall as its view box, so one unit -//! is one point there, and a wider window shows it whole at the same size. +//! the top-left corner. Each scene is drawn for the width the host reports +//! and is as tall as its view box, so one unit is one point, and it lists +//! `resize` to be drawn again when the window's width changes. A host that +//! reports no width gets the scene for the smallest settings window, which a +//! wider window shows whole at the same size. use serde_json::{json, Map, Value}; -/// The pixel size of the host's `caption` text style at scale 1. +/// The pixel sizes of the host's `caption` and `strong` text styles at +/// scale 1. pub const CAPTION: f64 = 11.0; +pub const STRONG: f64 = 13.0; /// How far one character of `monoSmall` code advances in the scenes. /// diff --git a/docs/feature-matrix.md b/docs/feature-matrix.md index f926304..77ea7b5 100644 --- a/docs/feature-matrix.md +++ b/docs/feature-matrix.md @@ -23,7 +23,7 @@ | `go-support-plugin` | gopls 代码智能、Go Modules 构建、运行与 `go test` | implemented / pending | implemented / pending | 2026-11-15 macOS 宿主端到端测试通过;Windows ARM64、x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241) | | `go-debug-delve` | 用用户的 Delve 调试 Go 包 | implemented / pending | partial / pending | 2026-11-15 macOS 宿主端到端测试通过;Windows x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241);Windows ARM64 上 Delve 不支持 | | `go-run-configuration-types` | 「运行/调试配置」里的 Go 构建和 Go 测试 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(桌面端 0.8.8,宿主 d87f114);Windows 只有命令层面的 `scripts/test.mjs` | -| `go-settings-previews` | Go 语言设置页和 Go 构建系统页里插件自己画的预览 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(桌面端 0.8.8,宿主 d87f114);Windows 后端只在 CI 构建,没有在 Windows 版 Lithe 里运行过 | +| `go-settings-previews` | Go 语言设置页和 Go 构建系统页里插件自己画的预览 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(本地 1.4.0 包,宿主 312a9c63a,即 1lck/Lithe-IDEA#2191 的分支提交);Windows 后端只在 CI 构建,没有在 Windows 版 Lithe 里运行过 | | `go-project-generator` | 「新建项目」里的 Go 模块,GOROOT 选择和 Go 版本默认值 | implemented / pending | implemented / pending | 2026-11-15 macOS 宿主集成测试通过;Windows ARM64、x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241)(模板生成的模块能构建和测试) | ## go-support-plugin @@ -257,34 +257,48 @@ Core 6477e9a),Homebrew 的 Go 1.27.4。在宿主检出里运行 `internal/pr 设置了 `go` 路径时只有这一步“使用中”,其余“不使用”。 两个区域都读设置窗口里还没应用的草稿,草稿和已保存的值不同时预览先变、并标出“含未应用的修改”。画面中英文跟随设置窗口的语言, -浅色和深色外观用宿主的颜色标记或成对颜色。后端只读设置,不启动 gopls、go 或 dlv,也不写插件目录。 +浅色和深色外观用宿主的颜色标记或成对颜色;点亮的标签(“开”“一行”等)在选中底色上用 `$text` 写字,深色外观下也清楚。 +后端只读设置,不启动 gopls、go 或 dlv,也不写插件目录。 + +1.4.0 起场景按视图事件里的 `width` 排版:语言页放得下两张最窄的卡片(宽度至少 594)时两张一行,否则一张一行,卡片随宽度变宽, +文字和代码保持原来的字号;构建系统页的步骤卡片随宽度变宽。画布声明 `on: ["resize"]`,窗口宽度稳定后宿主发 `resize`, +后端按新宽度重画。事件里没有 `width` 时按最窄设置窗口的区域宽度画(语言页 610、构建系统页 340),也不声明 `resize`,和 1.3.0 相同。 **证据**: - `io.github.lithe-idea.go-support/plugin.json`:`settingRegions` 的 `language`、`toolchain`,`backend.launch`,`requires` 的 `backend: 0`、`ui: 0`, 权限 `backend.launch`、`ui.contribute`。 -- `backend/src/`:视图函数和场景;`cargo test --locked` 检查每个场景在两种语言下都在契约限制内、宽度与区域一致, +- `backend/src/`:视图函数和场景;`cargo test --locked` 检查每个场景在两种语言、各个宽度下都在契约限制内、viewBox 宽度等于事件宽度、 + 卡片内容不超出卡片,两张一行只在放得下两张最窄卡片时出现,没有宽度时退回最窄窗口的排版且不声明 `resize`, 以及各设置对预览的影响。CI 不跑 `cargo test`,只构建后端。 - `e2e/host/desktop/internal/workbench/official_go_plugin_settings_view_e2e_test.go`:经设置窗口自己的设置来源启动安装包里的后端, - 用中英文打开两个区域并发草稿事件,由 Core 校验每次回答。 + 用中英文打开两个区域并发草稿事件,事件带区域宽度,由 Core 校验每次回答;检查 viewBox 宽度等于区域宽度、画布高度放得下 viewBox、 + 不写 `pan` 并声明 `resize`;再以 760 的宽度发 `resize`,检查按新宽度重画且草稿标记仍在。 -**依赖的宿主能力**:插件视图和设置区域(1lck/Lithe-IDEA#2183,Core Lithe-core-rust#104),桌面端 0.8.7 起包含。桌面端 0.8.6 同样支持 `ui` 0 和 `backend` 0,Store 按 `requires` 挡不住它,但它不认识 `settingRegions`,装 1.3.0 会失败。画布不写 `pan` 时宿主按 -`min(宽/viewBox 宽, 高/viewBox 高)` 从左上角缩放(#2183 的 34afcaf11);场景按设置窗口最窄时区域的宽度画(语言页 610、构建系统页 340), -宽窗口里原样显示。 +**依赖的宿主能力**:插件视图和设置区域(1lck/Lithe-IDEA#2183,Core Lithe-core-rust#104),桌面端 0.8.7 起包含。桌面端 0.8.6 同样支持 `ui` 0 和 `backend` 0,Store 按 `requires` 挡不住它,但它不认识 `settingRegions`,装 1.3.0 及更新版本会失败。 +按宽度排版和 `resize` 需要视图事件带 `width` 的宿主(1lck/Lithe-IDEA#2191,固定 Core Lithe-core-rust#109),还没有桌面端版本包含: +这种宿主量好区域宽度才发 `open`,宽度稳定 400 ms 后给声明了 `resize` 的画布发 `resize`,画布不写 `pan` 时按 +`min(宽/viewBox 宽, 高/viewBox 高)` 从左上角显示整个 viewBox。桌面端 0.8.7、0.8.8 不发宽度,并按“区域宽/viewBox 宽”缩放画布, +宽窗口里画面跟着放大、下方被画布高度裁掉;1.4.0 在这两个版本上和 1.3.0 相同。 **限制**:代码按 SF Mono 的 7pt 字宽一个字符一个节点排版,选区、光标、输入框和波浪线才能对准字符;Windows 上 Consolas 的字更窄, -代码间距会比宿主自己画的略宽。 +代码间距会比宿主自己画的略宽。文字宽度按字号估算,不是宿主量出来的;卡片窄时较长的说明和诊断用省略号截断。 -**最近验证**:2026-11-19,macOS(Apple Silicon),`go-support-1.3.0-darwin.zip` 发布包,宿主 `d87f114`(桌面端 0.8.8,包含 #2183)。 -`TestOfficialGoPluginDrawsItsSettingsRegions` 通过:后端由宿主启动,两个区域在中英文下各画出一张画布,viewBox 宽度分别是 610 和 340, -标题和标签是对应语言,草稿让预览标出未应用的修改、让构建系统页的 `go` 路径一步变成“使用中”,安装目录的文件不变。 -另用宿主无头界面在最小宽度(900)和较宽窗口(1300)下截了中英文、浅色和深色、默认值和全部开启的 32 张图检查排版。没有做手工验收。 +**最近验证**:2026-11-19,macOS(Apple Silicon),本地构建的 `go-support-1.4.0-darwin.zip`(未发布),宿主 `312a9c63a` +(1lck/Lithe-IDEA#2191 的分支提交,固定 Core `0b6da27`)。`TestOfficialGoPluginDrawsItsSettingsRegions` 通过:后端由宿主启动, +两个区域在中英文下按宿主给的区域宽度各画出一张画布,声明 `resize`、不写 `pan`,标题和标签是对应语言,草稿让预览标出未应用的修改、 +让构建系统页的 `go` 路径一步变成“使用中”;以 760 的宽度发 `resize` 后按新宽度重画,草稿标记仍在;安装目录的文件不变。 +同一次运行里另外三个 workbench 测试和五个 projectgen 测试也通过。另把后端画出的场景放进宿主无头界面(设置窗口的浅色和深色配色)截图: +语言页 330、610、900,构建系统页 344、700,中英文、默认值和全部开启,共 40 张,没有裁切和重叠,深色下点亮的标签文字清楚。 +此前同一天 1.3.0 发布包在桌面端 0.8.8(`d87f114`)上通过同一测试。没有做手工验收。 **验证方法**(macOS): -1. 安装插件包,打开「设置 › 语言 › Go」:顶部出现四张预览卡片,浅色和深色外观下文字和代码都清楚,窗口拉宽时不被裁掉。 +1. 用包含 #2191 的桌面端安装插件包,打开「设置 › 语言 › Go」:顶部出现四张预览卡片,浅色和深色外观下文字、代码和点亮的标签都清楚。 + 拖宽、拖窄设置窗口,停下后预览按新宽度重新排版:放得下时两张一行,窄了一张一行,字号不变,不放大也不被裁掉。 2. 改悬停文档、参数占位符、gofumpt、Staticcheck,先不点应用:对应卡片立刻变化,标出“含未应用的修改”;点应用后标记消失。 3. 打开「设置 › 构建、执行、部署 › 构建工具 › Go」:预览列出查找 go 的顺序;填 `go` 路径后这一步变成“使用中”,其余“不使用”。 + 拖宽窗口后步骤卡片跟着变宽,较长的 `go` 路径显示得更多。 4. 界面语言换成中文,两个预览都显示中文。 ## Windows 安装包 diff --git a/docs/releases/v1.4.0.md b/docs/releases/v1.4.0.md new file mode 100644 index 0000000..310ce9f --- /dev/null +++ b/docs/releases/v1.4.0.md @@ -0,0 +1,22 @@ +1.4.0 让 Go 设置页的预览跟着设置窗口的宽度重新排版,不再随窗口放大或被裁掉。 + +功能: +- 「设置 › 语言 › Go」的四张预览卡片按窗口实际宽度排列:放得下两张时两张一行,窄了一张一行;卡片随窗口变宽,里面的文字和代码保持 Lithe 自己的字号。 +- 「构建工具 › Go」的查找顺序图跟着窗口变宽,设置的 go 路径较长时能显示更多。 +- 拖动窗口改变宽度后,宽度稳定下来,预览就按新宽度重新排版。 +- 深色外观下,点亮的标签(“开”“一行”等)文字改用正文颜色,不再是蓝底上的蓝字,看得清楚。 + +已知限制: +- 跟随窗口宽度需要包含 1lck/Lithe-IDEA#2191 的桌面端,这个版本还没有发布。桌面端 0.8.7、0.8.8 不告诉插件窗口宽度,预览和 1.3.0 一样按最小的设置窗口排版。 +- 需要桌面端 0.8.7 或更新版本(含插件视图 1lck/Lithe-IDEA#2183)。桌面端 0.8.6 不认识 `settingRegions`,安装或更新到这个版本会失败。 +- Windows 上代码的字距比 Lithe 自己画的略宽:预览按 SF Mono 的字宽排版代码,选区和波浪线才能对准字符。 + +验证: +- 后端测试检查两种语言下每个预览在各个宽度都画在视图以内、卡片内容不超出卡片,两张一行只在放得下两张最窄卡片时出现,宿主不给宽度时退回最小窗口的排版。 +- 在 macOS 上用 1lck/Lithe-IDEA#2191 的桌面端跑宿主端到端测试:两个预览在中英文下按宿主给的宽度画出、通过 Core 校验,窗口变宽后按新宽度重画,草稿仍然标出,插件安装目录不被写入;原有的构建、调试、运行配置和新建项目测试也都通过。 +- 把后端画出的预览放进宿主的无头界面,用设置窗口的浅色和深色配色截图,检查了几种窗口宽度下中英文、默认值和全部开启时的排版。 +- Windows 包的后端只在 CI 里构建,还没有在 Windows 版 Lithe 里打开过;状态见 `docs/feature-matrix.md`。 + +兼容性: +- 发布包按平台分开:`-darwin.zip`(Apple Silicon 和 Intel 通用)、`-windows-x64.zip`、`-windows-arm64.zip`。 +- 后端用到的第三方 crate 和许可证见包里的 `THIRD_PARTY_LICENSES.txt`。 diff --git a/e2e/host/desktop/internal/workbench/official_go_plugin_settings_view_e2e_test.go b/e2e/host/desktop/internal/workbench/official_go_plugin_settings_view_e2e_test.go index a3feb87..1db9b71 100644 --- a/e2e/host/desktop/internal/workbench/official_go_plugin_settings_view_e2e_test.go +++ b/e2e/host/desktop/internal/workbench/official_go_plugin_settings_view_e2e_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "os" + "slices" "strconv" "strings" "testing" @@ -17,10 +18,12 @@ import ( // This opt-in integration test installs the released Go Support archive and opens its two // settings regions as the settings window does: through the window's own settings source, // which starts the packaged backend, sends the region's view events and has Core check every -// answer. It needs neither go nor gopls, since the backend reads settings only. +// answer. Every event carries the region's width, as the window measures it, and a resize +// to a wider window draws the scene again at the new width. It needs neither go nor gopls, +// since the backend reads settings only. -// goRegion is one of the plugin's settings regions, the width its scene is drawn for and the -// words of its title and label in each language. +// goRegion is one of the plugin's settings regions, its width in the smallest settings window +// and the words of its title and label in each language. type goRegion struct { id string width float64 @@ -46,6 +49,7 @@ type drawnCanvas struct { Height float64 `json:"height"` ViewBox []float64 `json:"viewBox"` Pan json.RawMessage `json:"pan"` + On []string `json:"on"` Nodes []json.RawMessage `json:"nodes"` } @@ -103,6 +107,21 @@ func drawRegion(t *testing.T, ctx context.Context, sources pluginSettingsSources return nodes[0] } +// drawnAt checks that a region's canvas is drawn for a view width points wide: its view box +// is that wide, it shows whole at one unit to a point, and it listens for resize. +func drawnAt(t *testing.T, region string, canvas drawnCanvas, width float64) { + t.Helper() + if len(canvas.ViewBox) != 4 || canvas.ViewBox[2] != width || canvas.ViewBox[3] < 1 { + t.Fatalf("%s region: view box %v, want one %g wide", region, canvas.ViewBox, width) + } + if canvas.Height < canvas.ViewBox[3] || len(canvas.Pan) > 0 { + t.Fatalf("%s region: height %g, pan %s; the scene must show whole at one unit to a point", region, canvas.Height, canvas.Pan) + } + if !slices.Contains(canvas.On, "resize") { + t.Fatalf("%s region: on %v, want resize so the scene follows the window", region, canvas.On) + } +} + func TestOfficialGoPluginDrawsItsSettingsRegions(t *testing.T) { archive := os.Getenv("LITHE_TEST_GO_PLUGIN_ARCHIVE") if archive == "" { @@ -129,13 +148,9 @@ func TestOfficialGoPluginDrawsItsSettingsRegions(t *testing.T) { // host adds the saved ones, read from the installed plugin. opened := drawRegion(t, ctx, sources, editor, region.id, map[string]any{ "event": "open", "instance": "e2e-" + strconv.Itoa(instance), "language": language.Code(), + "width": region.width, }) - if len(opened.ViewBox) != 4 || opened.ViewBox[2] != region.width || opened.ViewBox[3] < 1 { - t.Fatalf("%s region: view box %v, want one %g wide", region.id, opened.ViewBox, region.width) - } - if opened.Height < opened.ViewBox[3] || len(opened.Pan) > 0 { - t.Fatalf("%s region: height %g, pan %s; the scene must show whole at one unit to a point", region.id, opened.Height, opened.Pan) - } + drawnAt(t, region.id, opened, region.width) words := sceneWords(t, opened.Nodes) for _, want := range region.words[language] { if !strings.Contains(words, want) && opened.Label != want { @@ -154,8 +169,9 @@ func TestOfficialGoPluginDrawsItsSettingsRegions(t *testing.T) { } drafted := drawRegion(t, ctx, sources, editor, region.id, map[string]any{ "event": "settings", "instance": "e2e-" + strconv.Itoa(instance), "language": language.Code(), - "settings": map[string]any{"effective": map[string]any{}, "draft": draft}, + "width": region.width, "settings": map[string]any{"effective": map[string]any{}, "draft": draft}, }) + drawnAt(t, region.id, drafted, region.width) draftWords := sceneWords(t, drafted.Nodes) if !strings.Contains(draftWords, draftNote) { t.Fatalf("%s region in %s: the draft %v is not marked; the scene says:\n%s", region.id, language.Code(), draft, draftWords) @@ -164,6 +180,18 @@ func TestOfficialGoPluginDrawsItsSettingsRegions(t *testing.T) { if region.id == "toolchain" && (strings.Contains(words, inUse) || !strings.Contains(draftWords, inUse)) { t.Fatalf("toolchain region in %s: only a set go executable is in use; saved:\n%s\ndrafted:\n%s", language.Code(), words, draftWords) } + + // The window widens: the host sends resize with the new width, and the plugin + // lays the same scene out again at it, the draft still marked. + const wider = 760 + resized := drawRegion(t, ctx, sources, editor, region.id, map[string]any{ + "event": "resize", "instance": "e2e-" + strconv.Itoa(instance), "language": language.Code(), + "width": wider, "settings": map[string]any{"effective": map[string]any{}, "draft": draft}, + }) + drawnAt(t, region.id, resized, wider) + if resizedWords := sceneWords(t, resized.Nodes); !strings.Contains(resizedWords, draftNote) { + t.Fatalf("%s region in %s: the resized scene lost the draft; it says:\n%s", region.id, language.Code(), resizedWords) + } } } if h.app.plugins.Host.Running(id) == nil { diff --git a/e2e/host/lithe-host.json b/e2e/host/lithe-host.json index 6c1257a..d88a3a5 100644 --- a/e2e/host/lithe-host.json +++ b/e2e/host/lithe-host.json @@ -1,12 +1,12 @@ { "repository": "https://github.com/1lck/Lithe-IDEA.git", - "revision": "d87f1142ae5d9b6196e324409730fba4aad27664", + "revision": "312a9c63a9b2f308457a03cd027e2b9ead789fb0", "packages": { "./internal/projectgen": "^TestGoPlugin", "./internal/workbench": "^TestOfficialGoPlugin(BuildsAndServesAModule|DebugsEachProjectOfAWorkspaceWithDelve|RunsGoBuildAndGoTestConfigurations|DrawsItsSettingsRegions)$" }, "requiredEnvironment": { - "LITHE_TEST_GO_PLUGIN_ARCHIVE": "go-support--darwin.zip to install, for example dist/go-support-1.3.0-darwin.zip" + "LITHE_TEST_GO_PLUGIN_ARCHIVE": "go-support--darwin.zip to install, for example dist/go-support-1.4.0-darwin.zip" }, "repositoryEnvironment": { "LITHE_PLUGIN_GO_DIR": "io.github.lithe-idea.go-support" diff --git a/io.github.lithe-idea.go-support/plugin.json b/io.github.lithe-idea.go-support/plugin.json index b535a9b..8e40cab 100644 --- a/io.github.lithe-idea.go-support/plugin.json +++ b/io.github.lithe-idea.go-support/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 0, "id": "io.github.lithe-idea.go-support", "displayName": "Go Support", - "version": "1.3.0", + "version": "1.4.0", "pluginAPIVersion": 0, "requires": { "backend": 0, From bc04127b043362e9e666c2447118c1b3e77c2eff Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Thu, 19 Nov 2026 14:12:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=89=88=E6=9C=AC=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=201.3.1=EF=BC=8C=E4=BD=9C=E4=B8=BA=E6=AD=A3=E5=BC=8F=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 跟随宽度排版按修复处理:1.3.0 的预览在宽窗口里被放大、下方被裁掉。 版本号 1.4.0 改为 1.3.1(plugin.json、Cargo.toml、Cargo.lock、 e2e 示例包名),发布说明改名为 docs/releases/v1.3.1.md,标题改为“修复”。 - 不发宽度的桌面端 0.8.7、0.8.8 上 1.3.1 退回 1.3.0 的排版,稳定宿主 可以用,所以 release.yml 的 PRERELEASE_TAGS 去掉这个版本,直接作为 正式版本发布;README 的版本说明和发布一节、功能矩阵同步。 --- .github/workflows/release.yml | 8 ++++---- README.md | 14 +++++++------- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- docs/feature-matrix.md | 8 ++++---- docs/releases/{v1.4.0.md => v1.3.1.md} | 4 ++-- e2e/host/lithe-host.json | 2 +- io.github.lithe-idea.go-support/plugin.json | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) rename docs/releases/{v1.4.0.md => v1.3.1.md} (96%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c35359..e293272 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,11 +85,11 @@ jobs: # v1.2.0 (type icons, 1lck/Lithe-IDEA#2169) and v1.3.0 (settings regions, # 1lck/Lithe-IDEA#2183) were published as pre-releases and switched to # stable once desktop 0.8.7 shipped both host changes. - # v1.4.0 lays the settings previews out at the view width and redraws + # v1.3.1 lays the settings previews out at the view width and redraws # them on resize (1lck/Lithe-IDEA#2191, Lithe-core-rust#109), which no - # desktop release has yet; older hosts send no width and get the 1.3.0 - # layout. It switches to stable once a desktop release ships #2191. - PRERELEASE_TAGS: v0.0.1 v1.0.0 v1.4.0 + # desktop release has yet. Desktop 0.8.7 and 0.8.8 send no width and get + # the 1.3.0 layout, so it is published as a stable release. + PRERELEASE_TAGS: v0.0.1 v1.0.0 run: | prerelease=false for tag in $PRERELEASE_TAGS; do diff --git a/README.md b/README.md index 1a1065d..891a18e 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ gopls、go 和 dlv 仍然用你电脑上的。 > [Lithe-core-rust#104](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/104) 的 Core),桌面端 0.8.7 起包含它。 > 1.2.0 和 1.3.0 都作为正式版本发布并收录到 Lithe Store。桌面端 0.8.6 也支持 `ui` 0 和 `backend` 0, > Store 按 `requires` 挡不住它,但它不认识 `settingRegions`,安装或更新到 1.3.0 会失败,需要先把桌面端更新到 0.8.7 或更新版本。 -> 1.4.0 让这两个预览按设置窗口的实际宽度重新排版,窗口宽度变化后跟着重排;这要靠告诉插件视图宽度的桌面端 +> 1.3.1 让这两个预览按设置窗口的实际宽度重新排版,窗口宽度变化后跟着重排;这要靠告诉插件视图宽度的桌面端 > ([1lck/Lithe-IDEA#2191](https://github.com/1lck/Lithe-IDEA/pull/2191),固定了 -> [Lithe-core-rust#109](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/109) 的 Core),还没有桌面端版本包含它, -> 所以 1.4.0 作为预发布版本发布。桌面端 0.8.7、0.8.8 不发送宽度,1.4.0 在上面按最小设置窗口排版,和 1.3.0 相同。 +> [Lithe-core-rust#109](https://github.com/Lithe-IDEA/Lithe-core-rust/pull/109) 的 Core),还没有桌面端版本包含它。 +> 桌面端 0.8.7、0.8.8 不发送宽度,1.3.1 在上面按最小设置窗口排版,和 1.3.0 相同,所以 1.3.1 作为正式版本发布。 ## 功能 @@ -265,7 +265,7 @@ CI 在 macOS、Windows x64 和 Windows ARM64 上跑这个脚本,Windows 上测 ```bash node scripts/build-backend.mjs darwin node scripts/package.mjs --platforms darwin -LITHE_TEST_GO_PLUGIN_ARCHIVE="$PWD/dist/go-support-1.4.0-darwin.zip" node scripts/e2e-host.mjs +LITHE_TEST_GO_PLUGIN_ARCHIVE="$PWD/dist/go-support-1.3.1-darwin.zip" node scripts/e2e-host.mjs ``` 插件包路径要写绝对路径。脚本把固定版本的宿主(只取 `desktop/` 和 `scripts/`)检出到 `.artifacts/lithe-host`, @@ -291,10 +291,10 @@ Lithe 主仓库的功能矩阵不收录插件能力,改动插件行为时在 3. `Release` 工作流会核对标签与版本一致、打包并发布 Release(说明里附 SHA-256 和 `docs/releases/v<版本>.md`)。`release.yml` 里 `PRERELEASE_TAGS` 列出的版本会标为预发布版本: - 目前是只能装进新版桌面端的 `v0.0.1`、依赖宿主 #1954、#1964、#1971 的 `v1.0.0`, - 以及依赖宿主 #2191 的 `v1.4.0`;`v1.0.1`、`v1.1.0`、`v1.2.0` 和 `v1.3.0` 是正式版本。 + 目前是只能装进新版桌面端的 `v0.0.1` 和依赖宿主 #1954、#1964、#1971 的 `v1.0.0`; + `v1.0.1`、`v1.1.0`、`v1.2.0`、`v1.3.0` 和 `v1.3.1` 是正式版本。 `v1.2.0` 和 `v1.3.0` 先以预发布发布,桌面端 0.8.7 带上它们依赖的 #2169 和 #2183 后改为正式版本; - `v1.4.0` 等发布了包含 #2191 的桌面端后同样改为正式版本。 + `v1.3.1` 的宽度排版要靠还没发布的 #2191,但不发宽度的桌面端上退回 1.3.0 的排版,所以直接作为正式版本发布。 4. Lithe Store 的自动追踪会发现稳定版本并开合并请求,合并后用户即可在 Lithe 中更新。自动追踪会跳过预发布版本; 需要收录时在 Store 中手工提交条目,并使用已发布 ZIP 的实际 SHA-256。 diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 89b5b31..84d19bc 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -10,7 +10,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "go-support-backend" -version = "1.4.0" +version = "1.3.1" dependencies = [ "lithe-plugin-sdk", "serde_json", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 7b79b67..6d99eb6 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -2,7 +2,7 @@ name = "go-support-backend" description = "The Go Support plugin's backend: the previews its settings regions draw." # Kept equal to the plugin's version; scripts/package.mjs refuses a mismatch. -version = "1.4.0" +version = "1.3.1" edition = "2021" license = "Apache-2.0" rust-version = "1.87" diff --git a/docs/feature-matrix.md b/docs/feature-matrix.md index 77ea7b5..e0cc53f 100644 --- a/docs/feature-matrix.md +++ b/docs/feature-matrix.md @@ -23,7 +23,7 @@ | `go-support-plugin` | gopls 代码智能、Go Modules 构建、运行与 `go test` | implemented / pending | implemented / pending | 2026-11-15 macOS 宿主端到端测试通过;Windows ARM64、x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241) | | `go-debug-delve` | 用用户的 Delve 调试 Go 包 | implemented / pending | partial / pending | 2026-11-15 macOS 宿主端到端测试通过;Windows x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241);Windows ARM64 上 Delve 不支持 | | `go-run-configuration-types` | 「运行/调试配置」里的 Go 构建和 Go 测试 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(桌面端 0.8.8,宿主 d87f114);Windows 只有命令层面的 `scripts/test.mjs` | -| `go-settings-previews` | Go 语言设置页和 Go 构建系统页里插件自己画的预览 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(本地 1.4.0 包,宿主 312a9c63a,即 1lck/Lithe-IDEA#2191 的分支提交);Windows 后端只在 CI 构建,没有在 Windows 版 Lithe 里运行过 | +| `go-settings-previews` | Go 语言设置页和 Go 构建系统页里插件自己画的预览 | implemented / pending | implemented / pending | 2026-11-19 macOS 宿主端到端测试通过(本地 1.3.1 包,宿主 312a9c63a,即 1lck/Lithe-IDEA#2191 的分支提交);Windows 后端只在 CI 构建,没有在 Windows 版 Lithe 里运行过 | | `go-project-generator` | 「新建项目」里的 Go 模块,GOROOT 选择和 Go 版本默认值 | implemented / pending | implemented / pending | 2026-11-15 macOS 宿主集成测试通过;Windows ARM64、x64 [原生 CI 通过](https://github.com/Lithe-IDEA/lithe-plugin-go/actions/runs/43728078241)(模板生成的模块能构建和测试) | ## go-support-plugin @@ -260,7 +260,7 @@ Core 6477e9a),Homebrew 的 Go 1.27.4。在宿主检出里运行 `internal/pr 浅色和深色外观用宿主的颜色标记或成对颜色;点亮的标签(“开”“一行”等)在选中底色上用 `$text` 写字,深色外观下也清楚。 后端只读设置,不启动 gopls、go 或 dlv,也不写插件目录。 -1.4.0 起场景按视图事件里的 `width` 排版:语言页放得下两张最窄的卡片(宽度至少 594)时两张一行,否则一张一行,卡片随宽度变宽, +1.3.1 起场景按视图事件里的 `width` 排版:语言页放得下两张最窄的卡片(宽度至少 594)时两张一行,否则一张一行,卡片随宽度变宽, 文字和代码保持原来的字号;构建系统页的步骤卡片随宽度变宽。画布声明 `on: ["resize"]`,窗口宽度稳定后宿主发 `resize`, 后端按新宽度重画。事件里没有 `width` 时按最窄设置窗口的区域宽度画(语言页 610、构建系统页 340),也不声明 `resize`,和 1.3.0 相同。 @@ -279,12 +279,12 @@ Core 6477e9a),Homebrew 的 Go 1.27.4。在宿主检出里运行 `internal/pr 按宽度排版和 `resize` 需要视图事件带 `width` 的宿主(1lck/Lithe-IDEA#2191,固定 Core Lithe-core-rust#109),还没有桌面端版本包含: 这种宿主量好区域宽度才发 `open`,宽度稳定 400 ms 后给声明了 `resize` 的画布发 `resize`,画布不写 `pan` 时按 `min(宽/viewBox 宽, 高/viewBox 高)` 从左上角显示整个 viewBox。桌面端 0.8.7、0.8.8 不发宽度,并按“区域宽/viewBox 宽”缩放画布, -宽窗口里画面跟着放大、下方被画布高度裁掉;1.4.0 在这两个版本上和 1.3.0 相同。 +宽窗口里画面跟着放大、下方被画布高度裁掉;1.3.1 在这两个版本上和 1.3.0 相同。 **限制**:代码按 SF Mono 的 7pt 字宽一个字符一个节点排版,选区、光标、输入框和波浪线才能对准字符;Windows 上 Consolas 的字更窄, 代码间距会比宿主自己画的略宽。文字宽度按字号估算,不是宿主量出来的;卡片窄时较长的说明和诊断用省略号截断。 -**最近验证**:2026-11-19,macOS(Apple Silicon),本地构建的 `go-support-1.4.0-darwin.zip`(未发布),宿主 `312a9c63a` +**最近验证**:2026-11-19,macOS(Apple Silicon),本地构建的 `go-support-1.3.1-darwin.zip`,宿主 `312a9c63a` (1lck/Lithe-IDEA#2191 的分支提交,固定 Core `0b6da27`)。`TestOfficialGoPluginDrawsItsSettingsRegions` 通过:后端由宿主启动, 两个区域在中英文下按宿主给的区域宽度各画出一张画布,声明 `resize`、不写 `pan`,标题和标签是对应语言,草稿让预览标出未应用的修改、 让构建系统页的 `go` 路径一步变成“使用中”;以 760 的宽度发 `resize` 后按新宽度重画,草稿标记仍在;安装目录的文件不变。 diff --git a/docs/releases/v1.4.0.md b/docs/releases/v1.3.1.md similarity index 96% rename from docs/releases/v1.4.0.md rename to docs/releases/v1.3.1.md index 310ce9f..f23d199 100644 --- a/docs/releases/v1.4.0.md +++ b/docs/releases/v1.3.1.md @@ -1,6 +1,6 @@ -1.4.0 让 Go 设置页的预览跟着设置窗口的宽度重新排版,不再随窗口放大或被裁掉。 +1.3.1 让 Go 设置页的预览跟着设置窗口的宽度重新排版,不再随窗口放大或被裁掉。 -功能: +修复: - 「设置 › 语言 › Go」的四张预览卡片按窗口实际宽度排列:放得下两张时两张一行,窄了一张一行;卡片随窗口变宽,里面的文字和代码保持 Lithe 自己的字号。 - 「构建工具 › Go」的查找顺序图跟着窗口变宽,设置的 go 路径较长时能显示更多。 - 拖动窗口改变宽度后,宽度稳定下来,预览就按新宽度重新排版。 diff --git a/e2e/host/lithe-host.json b/e2e/host/lithe-host.json index d88a3a5..2f017f7 100644 --- a/e2e/host/lithe-host.json +++ b/e2e/host/lithe-host.json @@ -6,7 +6,7 @@ "./internal/workbench": "^TestOfficialGoPlugin(BuildsAndServesAModule|DebugsEachProjectOfAWorkspaceWithDelve|RunsGoBuildAndGoTestConfigurations|DrawsItsSettingsRegions)$" }, "requiredEnvironment": { - "LITHE_TEST_GO_PLUGIN_ARCHIVE": "go-support--darwin.zip to install, for example dist/go-support-1.4.0-darwin.zip" + "LITHE_TEST_GO_PLUGIN_ARCHIVE": "go-support--darwin.zip to install, for example dist/go-support-1.3.1-darwin.zip" }, "repositoryEnvironment": { "LITHE_PLUGIN_GO_DIR": "io.github.lithe-idea.go-support" diff --git a/io.github.lithe-idea.go-support/plugin.json b/io.github.lithe-idea.go-support/plugin.json index 8e40cab..7072160 100644 --- a/io.github.lithe-idea.go-support/plugin.json +++ b/io.github.lithe-idea.go-support/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 0, "id": "io.github.lithe-idea.go-support", "displayName": "Go Support", - "version": "1.4.0", + "version": "1.3.1", "pluginAPIVersion": 0, "requires": { "backend": 0,