diff --git a/crates/mcp/src/jsonrpc.rs b/crates/mcp/src/jsonrpc.rs index ab7d2ed..498d46f 100644 --- a/crates/mcp/src/jsonrpc.rs +++ b/crates/mcp/src/jsonrpc.rs @@ -53,7 +53,11 @@ pub enum Incoming { /// The error response line to send back: a parse error for invalid /// JSON, invalid request for anything that is not a single JSON-RPC 2.0 /// message, invalid params for params that are not an object. +/// +/// A leading byte order mark is dropped first: Windows PowerShell 5.1 +/// writes one when it pipes text into a native program. pub fn parse(line: &str) -> Result { + let line = line.strip_prefix('\u{feff}').unwrap_or(line); let value: Value = serde_json::from_str(line) .map_err(|e| error(&Value::Null, codes::PARSE_ERROR, &e.to_string(), None))?; let Value::Object(mut object) = value else { @@ -176,6 +180,10 @@ mod tests { }; assert_eq!(id, json!("a")); assert_eq!(params["k"], 1); + assert!(matches!( + parse("\u{feff}{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"ping\"}"), + Ok(Incoming::Request { .. }) + )); assert_eq!( parse(r#"{"jsonrpc":"2.0","method":"notifications/initialized"}"#).unwrap(), Incoming::Notification { diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json index 3b71016..a96d816 100644 --- a/ui/src/i18n/en.json +++ b/ui/src/i18n/en.json @@ -223,7 +223,7 @@ "problems.severity.hint": "Hint", "problems.severity.info": "Information", "problems.severity.warning": "Warning", - "problems.summary": "{errors} errors, {warnings} warnings, {infos} other", + "problems.summary": "Errors: {errors}, warnings: {warnings}, other: {infos}", "problems.toolWindow.title": "Problems", "project.empty.noFolder": "No folder is open.", "project.openFolder": "Open Folder…", diff --git a/ui/tests/problems/ProblemsToolWindow.test.ts b/ui/tests/problems/ProblemsToolWindow.test.ts index 1c91086..968aef3 100644 --- a/ui/tests/problems/ProblemsToolWindow.test.ts +++ b/ui/tests/problems/ProblemsToolWindow.test.ts @@ -211,7 +211,7 @@ describe("ProblemsToolWindow", () => { items: [diag(4, "warning", "Unused variable"), { ...diag(1, "error", "Undefined method"), code: "E12" }], }); await emit({ kind: "diagnosticsChanged", path: "a.php", items: [diag(0, "hint", "Could be final")] }); - expect(wrapper.get("[data-test=problems-status]").text()).toBe("1 errors, 1 warnings, 1 other"); + expect(wrapper.get("[data-test=problems-status]").text()).toBe("Errors: 1, warnings: 1, other: 1"); const files = wrapper.findAll("[data-test=problems-file]").map((f) => f.text()); expect(files[0]).toContain("a.php"); expect(files[1]).toContain("Service.php");