id
int64 0
886
| original_context
stringlengths 648
56.6k
| modified_context
stringlengths 587
47.6k
| omitted_context
sequencelengths 0
19
| omitted_index
sequencelengths 0
19
| metadata
dict |
---|---|---|---|---|---|
200 | diff --git a/compiler/CHANGELOG.md b/compiler/CHANGELOG.md
new file mode 100644
index 0000000000000..022d066b2202f
--- /dev/null
+++ b/compiler/CHANGELOG.md
@@ -0,0 +1,59 @@
+## 19.1.0-rc.1 (April 21, 2025)
+
+## eslint-plugin-react-hooks
+* Temporarily disable ref access in render validation [#32839](https://github.com/facebook/react/pull/32839) by [@poteto](https://github.com/poteto)
+* Fix type error with recommended config [#32666](https://github.com/facebook/react/pull/32666) by [@niklasholm](https://github.com/niklasholm)
+* Merge rule from eslint-plugin-react-compiler into `react-hooks` plugin [#32416](https://github.com/facebook/react/pull/32416) by [@michaelfaith](https://github.com/michaelfaith)
+* Add dev dependencies for typescript migration [#32279](https://github.com/facebook/react/pull/32279) by [@michaelfaith](https://github.com/michaelfaith)
+* Support v9 context api [#32045](https://github.com/facebook/react/pull/32045) by [@michaelfaith](https://github.com/michaelfaith)
+* Support eslint 8+ flat plugin syntax out of the box for eslint-plugin-react-compiler [#32120](https://github.com/facebook/react/pull/32120) by [@orta](https://github.com/orta)
+
+## babel-plugin-react-compiler
+* Support satisfies operator [#32742](https://github.com/facebook/react/pull/32742) by [@rodrigofariow](https://github.com/rodrigofariow)
+* Fix inferEffectDependencies lint false positives [#32769](https://github.com/facebook/react/pull/32769) by [@mofeiZ](https://github.com/mofeiZ)
+* Fix hoisting of let declarations [#32724](https://github.com/facebook/react/pull/32724) by [@mofeiZ](https://github.com/mofeiZ)
+* Avoid failing builds when import specifiers conflict or shadow vars [#32663](https://github.com/facebook/react/pull/32663) by [@mofeiZ](https://github.com/mofeiZ)
+* Optimize components declared with arrow function and implicit return and `compilationMode: 'infer'` [#31792](https://github.com/facebook/react/pull/31792) by [@dimaMachina](https://github.com/dimaMachina)
+* Validate static components [#32683](https://github.com/facebook/react/pull/32683) by [@josephsavona](https://github.com/josephsavona)
+* Hoist dependencies from functions more conservatively [#32616](https://github.com/facebook/react/pull/32616) by [@mofeiZ](https://github.com/mofeiZ)
+* Implement NumericLiteral as ObjectPropertyKey [#31791](https://github.com/facebook/react/pull/31791) by [@dimaMachina](https://github.com/dimaMachina)
+* Avoid bailouts when inserting gating [#32598](https://github.com/facebook/react/pull/32598) by [@mofeiZ](https://github.com/mofeiZ)
+* Stop bailing out early for hoisted gated functions [#32597](https://github.com/facebook/react/pull/32597) by [@mofeiZ](https://github.com/mofeiZ)
+* Add shape for Array.from [#32522](https://github.com/facebook/react/pull/32522) by [@mofeiZ](https://github.com/mofeiZ)
+* Patch array and argument spread mutability [#32521](https://github.com/facebook/react/pull/32521) by [@mofeiZ](https://github.com/mofeiZ)
+* Make CompilerError compatible with reflection [#32539](https://github.com/facebook/react/pull/32539) by [@poteto](https://github.com/poteto)
+* Add simple walltime measurement [#32331](https://github.com/facebook/react/pull/32331) by [@poteto](https://github.com/poteto)
+* Improve error messages for unhandled terminal and instruction kinds [#32324](https://github.com/facebook/react/pull/32324) by [@inottn](https://github.com/inottn)
+* Handle TSInstantiationExpression in lowerExpression [#32302](https://github.com/facebook/react/pull/32302) by [@inottn](https://github.com/inottn)
+* Fix invalid Array.map type [#32095](https://github.com/facebook/react/pull/32095) by [@mofeiZ](https://github.com/mofeiZ)
+* Patch for JSX escape sequences in @babel/generator [#32131](https://github.com/facebook/react/pull/32131) by [@mofeiZ](https://github.com/mofeiZ)
+* `JSXText` emits incorrect with bracket [#32138](https://github.com/facebook/react/pull/32138) by [@himself65](https://github.com/himself65)
+* Validation against calling impure functions [#31960](https://github.com/facebook/react/pull/31960) by [@josephsavona](https://github.com/josephsavona)
+* Always target node [#32091](https://github.com/facebook/react/pull/32091) by [@poteto](https://github.com/poteto)
+* Patch compilationMode:infer object method edge case [#32055](https://github.com/facebook/react/pull/32055) by [@mofeiZ](https://github.com/mofeiZ)
+* Generate ts defs [#31994](https://github.com/facebook/react/pull/31994) by [@poteto](https://github.com/poteto)
+* Relax react peer dep requirement [#31915](https://github.com/facebook/react/pull/31915) by [@poteto](https://github.com/poteto)
+* Allow type cast expressions with refs [#31871](https://github.com/facebook/react/pull/31871) by [@josephsavona](https://github.com/josephsavona)
+* Add shape for global Object.keys [#31583](https://github.com/facebook/react/pull/31583) by [@mofeiZ](https://github.com/mofeiZ)
+* Optimize method calls w props receiver [#31775](https://github.com/facebook/react/pull/31775) by [@josephsavona](https://github.com/josephsavona)
+* Fix dropped ref with spread props in InlineJsxTransform [#31726](https://github.com/facebook/react/pull/31726) by [@jackpope](https://github.com/jackpope)
+* Support for non-declatation for in/of iterators [#31710](https://github.com/facebook/react/pull/31710) by [@mvitousek](https://github.com/mvitousek)
+* Support for context variable loop iterators [#31709](https://github.com/facebook/react/pull/31709) by [@mvitousek](https://github.com/mvitousek)
+* Replace deprecated dependency in `eslint-plugin-react-compiler` [#31629](https://github.com/facebook/react/pull/31629) by [@rakleed](https://github.com/rakleed)
+* Support enableRefAsProp in jsx transform [#31558](https://github.com/facebook/react/pull/31558) by [@jackpope](https://github.com/jackpope)
+* Fix: ref.current now correctly reactive [#31521](https://github.com/facebook/react/pull/31521) by [@mofeiZ](https://github.com/mofeiZ)
+* Outline JSX with non-jsx children [#31442](https://github.com/facebook/react/pull/31442) by [@gsathya](https://github.com/gsathya)
+* Outline jsx with duplicate attributes [#31441](https://github.com/facebook/react/pull/31441) by [@gsathya](https://github.com/gsathya)
+* Store original and new prop names [#31440](https://github.com/facebook/react/pull/31440) by [@gsathya](https://github.com/gsathya)
+* Stabilize compiler output: sort deps and decls by name [#31362](https://github.com/facebook/react/pull/31362) by [@mofeiZ](https://github.com/mofeiZ)
+* Bugfix for hoistable deps for nested functions [#31345](https://github.com/facebook/react/pull/31345) by [@mofeiZ](https://github.com/mofeiZ)
+* Remove compiler runtime-compat fixture library [#31430](https://github.com/facebook/react/pull/31430) by [@poteto](https://github.com/poteto)
+* Wrap inline jsx transform codegen in conditional [#31267](https://github.com/facebook/react/pull/31267) by [@jackpope](https://github.com/jackpope)
+* Check if local identifier is a hook when resolving globals [#31384](https://github.com/facebook/react/pull/31384) by [@poteto](https://github.com/poteto)
+* Handle member expr as computed property [#31344](https://github.com/facebook/react/pull/31344) by [@gsathya](https://github.com/gsathya)
+* Fix to ref access check to ban ref?.current [#31360](https://github.com/facebook/react/pull/31360) by [@mvitousek](https://github.com/mvitousek)
+* InlineJSXTransform transforms jsx inside function expressions [#31282](https://github.com/facebook/react/pull/31282) by [@josephsavona](https://github.com/josephsavona)
+
+## Other
+* Add shebang to banner [#32225](https://github.com/facebook/react/pull/32225) by [@Jeremy-Hibiki](https://github.com/Jeremy-Hibiki)
+* remove terser from react-compiler-runtime build [#31326](https://github.com/facebook/react/pull/31326) by [@henryqdineen](https://github.com/henryqdineen)
| diff --git a/compiler/CHANGELOG.md b/compiler/CHANGELOG.md
new file mode 100644
index 0000000000000..022d066b2202f
--- /dev/null
+++ b/compiler/CHANGELOG.md
@@ -0,0 +1,59 @@
+## 19.1.0-rc.1 (April 21, 2025)
+## eslint-plugin-react-hooks
+* Temporarily disable ref access in render validation [#32839](https://github.com/facebook/react/pull/32839) by [@poteto](https://github.com/poteto)
+* Fix type error with recommended config [#32666](https://github.com/facebook/react/pull/32666) by [@niklasholm](https://github.com/niklasholm)
+* Merge rule from eslint-plugin-react-compiler into `react-hooks` plugin [#32416](https://github.com/facebook/react/pull/32416) by [@michaelfaith](https://github.com/michaelfaith)
+* Add dev dependencies for typescript migration [#32279](https://github.com/facebook/react/pull/32279) by [@michaelfaith](https://github.com/michaelfaith)
+* Support v9 context api [#32045](https://github.com/facebook/react/pull/32045) by [@michaelfaith](https://github.com/michaelfaith)
+* Support eslint 8+ flat plugin syntax out of the box for eslint-plugin-react-compiler [#32120](https://github.com/facebook/react/pull/32120) by [@orta](https://github.com/orta)
+## babel-plugin-react-compiler
+* Support satisfies operator [#32742](https://github.com/facebook/react/pull/32742) by [@rodrigofariow](https://github.com/rodrigofariow)
+* Fix inferEffectDependencies lint false positives [#32769](https://github.com/facebook/react/pull/32769) by [@mofeiZ](https://github.com/mofeiZ)
+* Fix hoisting of let declarations [#32724](https://github.com/facebook/react/pull/32724) by [@mofeiZ](https://github.com/mofeiZ)
+* Optimize components declared with arrow function and implicit return and `compilationMode: 'infer'` [#31792](https://github.com/facebook/react/pull/31792) by [@dimaMachina](https://github.com/dimaMachina)
+* Validate static components [#32683](https://github.com/facebook/react/pull/32683) by [@josephsavona](https://github.com/josephsavona)
+* Hoist dependencies from functions more conservatively [#32616](https://github.com/facebook/react/pull/32616) by [@mofeiZ](https://github.com/mofeiZ)
+* Implement NumericLiteral as ObjectPropertyKey [#31791](https://github.com/facebook/react/pull/31791) by [@dimaMachina](https://github.com/dimaMachina)
+* Stop bailing out early for hoisted gated functions [#32597](https://github.com/facebook/react/pull/32597) by [@mofeiZ](https://github.com/mofeiZ)
+* Add shape for Array.from [#32522](https://github.com/facebook/react/pull/32522) by [@mofeiZ](https://github.com/mofeiZ)
+* Patch array and argument spread mutability [#32521](https://github.com/facebook/react/pull/32521) by [@mofeiZ](https://github.com/mofeiZ)
+* Make CompilerError compatible with reflection [#32539](https://github.com/facebook/react/pull/32539) by [@poteto](https://github.com/poteto)
+* Add simple walltime measurement [#32331](https://github.com/facebook/react/pull/32331) by [@poteto](https://github.com/poteto)
+* Improve error messages for unhandled terminal and instruction kinds [#32324](https://github.com/facebook/react/pull/32324) by [@inottn](https://github.com/inottn)
+* Handle TSInstantiationExpression in lowerExpression [#32302](https://github.com/facebook/react/pull/32302) by [@inottn](https://github.com/inottn)
+* Patch for JSX escape sequences in @babel/generator [#32131](https://github.com/facebook/react/pull/32131) by [@mofeiZ](https://github.com/mofeiZ)
+* `JSXText` emits incorrect with bracket [#32138](https://github.com/facebook/react/pull/32138) by [@himself65](https://github.com/himself65)
+* Always target node [#32091](https://github.com/facebook/react/pull/32091) by [@poteto](https://github.com/poteto)
+* Patch compilationMode:infer object method edge case [#32055](https://github.com/facebook/react/pull/32055) by [@mofeiZ](https://github.com/mofeiZ)
+* Generate ts defs [#31994](https://github.com/facebook/react/pull/31994) by [@poteto](https://github.com/poteto)
+* Relax react peer dep requirement [#31915](https://github.com/facebook/react/pull/31915) by [@poteto](https://github.com/poteto)
+* Allow type cast expressions with refs [#31871](https://github.com/facebook/react/pull/31871) by [@josephsavona](https://github.com/josephsavona)
+* Fix dropped ref with spread props in InlineJsxTransform [#31726](https://github.com/facebook/react/pull/31726) by [@jackpope](https://github.com/jackpope)
+* Support for context variable loop iterators [#31709](https://github.com/facebook/react/pull/31709) by [@mvitousek](https://github.com/mvitousek)
+* Replace deprecated dependency in `eslint-plugin-react-compiler` [#31629](https://github.com/facebook/react/pull/31629) by [@rakleed](https://github.com/rakleed)
+* Support enableRefAsProp in jsx transform [#31558](https://github.com/facebook/react/pull/31558) by [@jackpope](https://github.com/jackpope)
+* Fix: ref.current now correctly reactive [#31521](https://github.com/facebook/react/pull/31521) by [@mofeiZ](https://github.com/mofeiZ)
+* Outline JSX with non-jsx children [#31442](https://github.com/facebook/react/pull/31442) by [@gsathya](https://github.com/gsathya)
+* Outline jsx with duplicate attributes [#31441](https://github.com/facebook/react/pull/31441) by [@gsathya](https://github.com/gsathya)
+* Stabilize compiler output: sort deps and decls by name [#31362](https://github.com/facebook/react/pull/31362) by [@mofeiZ](https://github.com/mofeiZ)
+* Bugfix for hoistable deps for nested functions [#31345](https://github.com/facebook/react/pull/31345) by [@mofeiZ](https://github.com/mofeiZ)
+* Remove compiler runtime-compat fixture library [#31430](https://github.com/facebook/react/pull/31430) by [@poteto](https://github.com/poteto)
+* Wrap inline jsx transform codegen in conditional [#31267](https://github.com/facebook/react/pull/31267) by [@jackpope](https://github.com/jackpope)
+* Check if local identifier is a hook when resolving globals [#31384](https://github.com/facebook/react/pull/31384) by [@poteto](https://github.com/poteto)
+* Handle member expr as computed property [#31344](https://github.com/facebook/react/pull/31344) by [@gsathya](https://github.com/gsathya)
+* Fix to ref access check to ban ref?.current [#31360](https://github.com/facebook/react/pull/31360) by [@mvitousek](https://github.com/mvitousek)
+* InlineJSXTransform transforms jsx inside function expressions [#31282](https://github.com/facebook/react/pull/31282) by [@josephsavona](https://github.com/josephsavona)
+## Other
+* Add shebang to banner [#32225](https://github.com/facebook/react/pull/32225) by [@Jeremy-Hibiki](https://github.com/Jeremy-Hibiki)
+* remove terser from react-compiler-runtime build [#31326](https://github.com/facebook/react/pull/31326) by [@henryqdineen](https://github.com/henryqdineen) | [
"+* Avoid failing builds when import specifiers conflict or shadow vars [#32663](https://github.com/facebook/react/pull/32663) by [@mofeiZ](https://github.com/mofeiZ)",
"+* Avoid bailouts when inserting gating [#32598](https://github.com/facebook/react/pull/32598) by [@mofeiZ](https://github.com/mofeiZ)",
"+* Fix invalid Array.map type [#32095](https://github.com/facebook/react/pull/32095) by [@mofeiZ](https://github.com/mofeiZ)",
"+* Validation against calling impure functions [#31960](https://github.com/facebook/react/pull/31960) by [@josephsavona](https://github.com/josephsavona)",
"+* Add shape for global Object.keys [#31583](https://github.com/facebook/react/pull/31583) by [@mofeiZ](https://github.com/mofeiZ)",
"+* Optimize method calls w props receiver [#31775](https://github.com/facebook/react/pull/31775) by [@josephsavona](https://github.com/josephsavona)",
"+* Support for non-declatation for in/of iterators [#31710](https://github.com/facebook/react/pull/31710) by [@mvitousek](https://github.com/mvitousek)",
"+* Store original and new prop names [#31440](https://github.com/facebook/react/pull/31440) by [@gsathya](https://github.com/gsathya)"
] | [
20,
25,
33,
36,
42,
43,
45,
52
] | {
"additions": 59,
"author": "poteto",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32983",
"issue_id": 32983,
"merged_at": "2025-04-24T20:20:02Z",
"omission_probability": 0.1,
"pr_number": 32983,
"repo": "facebook/react",
"title": "[compiler] Add changelog",
"total_changes": 59
} |
201 | diff --git a/compiler/packages/react-forgive/server/src/compiler/index.ts b/compiler/packages/react-forgive/server/src/compiler/index.ts
index 3723785cfbebd..fe192c62132b6 100644
--- a/compiler/packages/react-forgive/server/src/compiler/index.ts
+++ b/compiler/packages/react-forgive/server/src/compiler/index.ts
@@ -33,6 +33,8 @@ export async function compile({
plugins: ['typescript', 'jsx'],
},
sourceType: 'module',
+ configFile: false,
+ babelrc: false,
});
if (ast == null) {
return null;
@@ -48,6 +50,8 @@ export async function compile({
plugins,
sourceType: 'module',
sourceFileName: file,
+ configFile: false,
+ babelrc: false,
});
if (result?.code == null) {
throw new Error(
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 0b43e9fcd2945..fd4ffd99886c9 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -132,7 +132,7 @@ connection.onInitialized(() => {
});
documents.onDidChangeContent(async event => {
- connection.console.info(`Changed: ${event.document.uri}`);
+ connection.console.info(`Compiling: ${event.document.uri}`);
resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
@@ -143,8 +143,11 @@ documents.onDidChangeContent(async event => {
options: compilerOptions,
});
} catch (err) {
+ connection.console.error('Failed to compile');
if (err instanceof Error) {
- connection.console.error(err.stack ?? '');
+ connection.console.error(err.stack ?? err.message);
+ } else {
+ connection.console.error(JSON.stringify(err, null, 2));
}
}
}
@@ -192,7 +195,6 @@ connection.onCodeLensResolve(lens => {
});
connection.onCodeAction(params => {
- connection.console.log('onCodeAction');
const codeActions: Array<CodeAction> = [];
for (const codeActionEvent of codeActionEvents) {
if (
@@ -242,6 +244,7 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
});
function resetState() {
+ connection.console.debug('Clearing state');
compiledFns.clear();
autoDepsDecorations = [];
codeActionEvents = [];
| diff --git a/compiler/packages/react-forgive/server/src/compiler/index.ts b/compiler/packages/react-forgive/server/src/compiler/index.ts
index 3723785cfbebd..fe192c62132b6 100644
--- a/compiler/packages/react-forgive/server/src/compiler/index.ts
+++ b/compiler/packages/react-forgive/server/src/compiler/index.ts
@@ -33,6 +33,8 @@ export async function compile({
plugins: ['typescript', 'jsx'],
},
if (ast == null) {
return null;
@@ -48,6 +50,8 @@ export async function compile({
plugins,
sourceFileName: file,
if (result?.code == null) {
throw new Error(
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 0b43e9fcd2945..fd4ffd99886c9 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -132,7 +132,7 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
- connection.console.info(`Changed: ${event.document.uri}`);
+ connection.console.info(`Compiling: ${event.document.uri}`);
resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
@@ -143,8 +143,11 @@ documents.onDidChangeContent(async event => {
options: compilerOptions,
});
} catch (err) {
+ connection.console.error('Failed to compile');
if (err instanceof Error) {
+ } else {
+ connection.console.error(JSON.stringify(err, null, 2));
}
}
}
@@ -192,7 +195,6 @@ connection.onCodeLensResolve(lens => {
connection.onCodeAction(params => {
- connection.console.log('onCodeAction');
const codeActions: Array<CodeAction> = [];
for (const codeActionEvent of codeActionEvents) {
if (
@@ -242,6 +244,7 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
function resetState() {
+ connection.console.debug('Clearing state');
compiledFns.clear();
autoDepsDecorations = [];
codeActionEvents = []; | [
"- connection.console.error(err.stack ?? '');",
"+ connection.console.error(err.stack ?? err.message);"
] | [
41,
42
] | {
"additions": 10,
"author": "poteto",
"deletions": 3,
"html_url": "https://github.com/facebook/react/pull/33011",
"issue_id": 33011,
"merged_at": "2025-04-24T17:30:17Z",
"omission_probability": 0.1,
"pr_number": 33011,
"repo": "facebook/react",
"title": "[forgive][ez] Tweak logging",
"total_changes": 13
} |
202 | diff --git a/compiler/apps/playground/yarn.lock b/compiler/apps/playground/yarn.lock
index f95738b1099d2..f40fffe675519 100644
--- a/compiler/apps/playground/yarn.lock
+++ b/compiler/apps/playground/yarn.lock
@@ -1249,14 +1249,14 @@ camelcase-css@^2.0.1:
integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==
caniuse-lite@^1.0.30001579:
- version "1.0.30001669"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz#fda8f1d29a8bfdc42de0c170d7f34a9cf19ed7a3"
- integrity sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==
+ version "1.0.30001715"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001715.tgz"
+ integrity sha512-7ptkFGMm2OAOgvZpwgA4yjQ5SQbrNVGdRjzH0pBdy1Fasvcr+KAeECmbCAECzTuDuoX0FCY8KzUxjf9+9kfZEw==
caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001663:
- version "1.0.30001664"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz#d588d75c9682d3301956b05a3749652a80677df4"
- integrity sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==
+ version "1.0.30001715"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001715.tgz"
+ integrity sha512-7ptkFGMm2OAOgvZpwgA4yjQ5SQbrNVGdRjzH0pBdy1Fasvcr+KAeECmbCAECzTuDuoX0FCY8KzUxjf9+9kfZEw==
chalk@^2.4.2:
version "2.4.2"
diff --git a/compiler/yarn.lock b/compiler/yarn.lock
index 410651315da39..9e4ee0d8ca8bc 100644
--- a/compiler/yarn.lock
+++ b/compiler/yarn.lock
@@ -4341,15 +4341,10 @@ camelcase@^6.0.0, camelcase@^6.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
-caniuse-lite@^1.0.30001489:
- version "1.0.30001581"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001581.tgz"
- integrity sha512-whlTkwhqV2tUmP3oYhtNfaWGYHDdS3JYFQBKXxcUR9qqPWsRhFHhoISO2Xnl/g0xyKzht9mI1LZpiNWfMzHixQ==
-
-caniuse-lite@^1.0.30001688:
- version "1.0.30001690"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz#f2d15e3aaf8e18f76b2b8c1481abde063b8104c8"
- integrity sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==
+caniuse-lite@^1.0.30001489, caniuse-lite@^1.0.30001688:
+ version "1.0.30001715"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001715.tgz"
+ integrity sha512-7ptkFGMm2OAOgvZpwgA4yjQ5SQbrNVGdRjzH0pBdy1Fasvcr+KAeECmbCAECzTuDuoX0FCY8KzUxjf9+9kfZEw==
[email protected], chalk@^2.0.0, chalk@^2.4.2:
version "2.4.2"
| diff --git a/compiler/apps/playground/yarn.lock b/compiler/apps/playground/yarn.lock
index f95738b1099d2..f40fffe675519 100644
--- a/compiler/apps/playground/yarn.lock
+++ b/compiler/apps/playground/yarn.lock
@@ -1249,14 +1249,14 @@ camelcase-css@^2.0.1:
integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==
caniuse-lite@^1.0.30001579:
- version "1.0.30001669"
- integrity sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==
caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001663:
- version "1.0.30001664"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz#d588d75c9682d3301956b05a3749652a80677df4"
- integrity sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==
chalk@^2.4.2:
diff --git a/compiler/yarn.lock b/compiler/yarn.lock
index 410651315da39..9e4ee0d8ca8bc 100644
--- a/compiler/yarn.lock
+++ b/compiler/yarn.lock
@@ -4341,15 +4341,10 @@ camelcase@^6.0.0, camelcase@^6.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
-caniuse-lite@^1.0.30001489:
- version "1.0.30001581"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001581.tgz"
- integrity sha512-whlTkwhqV2tUmP3oYhtNfaWGYHDdS3JYFQBKXxcUR9qqPWsRhFHhoISO2Xnl/g0xyKzht9mI1LZpiNWfMzHixQ==
-
- version "1.0.30001690"
+caniuse-lite@^1.0.30001489, caniuse-lite@^1.0.30001688:
[email protected], chalk@^2.0.0, chalk@^2.4.2: | [
"- resolved \"https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz#fda8f1d29a8bfdc42de0c170d7f34a9cf19ed7a3\"",
"-caniuse-lite@^1.0.30001688:",
"- resolved \"https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz#f2d15e3aaf8e18f76b2b8c1481abde063b8104c8\"",
"- integrity sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w=="
] | [
9,
38,
40,
41
] | {
"additions": 10,
"author": "poteto",
"deletions": 15,
"html_url": "https://github.com/facebook/react/pull/33013",
"issue_id": 33013,
"merged_at": "2025-04-24T17:50:03Z",
"omission_probability": 0.1,
"pr_number": 33013,
"repo": "facebook/react",
"title": "[chore] Update caniuse-lite",
"total_changes": 25
} |
203 | diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
index 622b7f72dad9b..34347f10b8fdf 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
@@ -469,6 +469,23 @@ export function compileProgram(
}
}
+ /**
+ * Otherwise if 'use no forget/memo' is present, we still run the code through the compiler
+ * for validation but we don't mutate the babel AST. This allows us to flag if there is an
+ * unused 'use no forget/memo' directive.
+ */
+ if (pass.opts.ignoreUseNoForget === false && optOutDirectives.length > 0) {
+ for (const directive of optOutDirectives) {
+ pass.opts.logger?.logEvent(pass.filename, {
+ kind: 'CompileSkip',
+ fnLoc: fn.node.body.loc ?? null,
+ reason: `Skipped due to '${directive.value.value}' directive.`,
+ loc: directive.loc ?? null,
+ });
+ }
+ return null;
+ }
+
pass.opts.logger?.logEvent(pass.filename, {
kind: 'CompileSuccess',
fnLoc: fn.node.loc ?? null,
@@ -492,23 +509,6 @@ export function compileProgram(
return null;
}
- /**
- * Otherwise if 'use no forget/memo' is present, we still run the code through the compiler
- * for validation but we don't mutate the babel AST. This allows us to flag if there is an
- * unused 'use no forget/memo' directive.
- */
- if (pass.opts.ignoreUseNoForget === false && optOutDirectives.length > 0) {
- for (const directive of optOutDirectives) {
- pass.opts.logger?.logEvent(pass.filename, {
- kind: 'CompileSkip',
- fnLoc: fn.node.body.loc ?? null,
- reason: `Skipped due to '${directive.value.value}' directive.`,
- loc: directive.loc ?? null,
- });
- }
- return null;
- }
-
if (!pass.opts.noEmit) {
return compileResult.compiledFn;
}
diff --git a/compiler/packages/react-forgive/server/src/compiler/index.ts b/compiler/packages/react-forgive/server/src/compiler/index.ts
index 3723785cfbebd..fe192c62132b6 100644
--- a/compiler/packages/react-forgive/server/src/compiler/index.ts
+++ b/compiler/packages/react-forgive/server/src/compiler/index.ts
@@ -33,6 +33,8 @@ export async function compile({
plugins: ['typescript', 'jsx'],
},
sourceType: 'module',
+ configFile: false,
+ babelrc: false,
});
if (ast == null) {
return null;
@@ -48,6 +50,8 @@ export async function compile({
plugins,
sourceType: 'module',
sourceFileName: file,
+ configFile: false,
+ babelrc: false,
});
if (result?.code == null) {
throw new Error(
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 0b43e9fcd2945..fd4ffd99886c9 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -132,7 +132,7 @@ connection.onInitialized(() => {
});
documents.onDidChangeContent(async event => {
- connection.console.info(`Changed: ${event.document.uri}`);
+ connection.console.info(`Compiling: ${event.document.uri}`);
resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
@@ -143,8 +143,11 @@ documents.onDidChangeContent(async event => {
options: compilerOptions,
});
} catch (err) {
+ connection.console.error('Failed to compile');
if (err instanceof Error) {
- connection.console.error(err.stack ?? '');
+ connection.console.error(err.stack ?? err.message);
+ } else {
+ connection.console.error(JSON.stringify(err, null, 2));
}
}
}
@@ -192,7 +195,6 @@ connection.onCodeLensResolve(lens => {
});
connection.onCodeAction(params => {
- connection.console.log('onCodeAction');
const codeActions: Array<CodeAction> = [];
for (const codeActionEvent of codeActionEvents) {
if (
@@ -242,6 +244,7 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
});
function resetState() {
+ connection.console.debug('Clearing state');
compiledFns.clear();
autoDepsDecorations = [];
codeActionEvents = [];
| diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
index 622b7f72dad9b..34347f10b8fdf 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts
@@ -469,6 +469,23 @@ export function compileProgram(
+ * Otherwise if 'use no forget/memo' is present, we still run the code through the compiler
+ * unused 'use no forget/memo' directive.
+ */
+ if (pass.opts.ignoreUseNoForget === false && optOutDirectives.length > 0) {
+ for (const directive of optOutDirectives) {
+ pass.opts.logger?.logEvent(pass.filename, {
+ kind: 'CompileSkip',
+ fnLoc: fn.node.body.loc ?? null,
+ reason: `Skipped due to '${directive.value.value}' directive.`,
+ loc: directive.loc ?? null,
+ });
+ }
+ return null;
+ }
+
pass.opts.logger?.logEvent(pass.filename, {
kind: 'CompileSuccess',
fnLoc: fn.node.loc ?? null,
@@ -492,23 +509,6 @@ export function compileProgram(
return null;
- * Otherwise if 'use no forget/memo' is present, we still run the code through the compiler
- * for validation but we don't mutate the babel AST. This allows us to flag if there is an
- * unused 'use no forget/memo' directive.
- */
- if (pass.opts.ignoreUseNoForget === false && optOutDirectives.length > 0) {
- for (const directive of optOutDirectives) {
- pass.opts.logger?.logEvent(pass.filename, {
- kind: 'CompileSkip',
- fnLoc: fn.node.body.loc ?? null,
- reason: `Skipped due to '${directive.value.value}' directive.`,
- loc: directive.loc ?? null,
- });
- }
- return null;
- }
-
if (!pass.opts.noEmit) {
return compileResult.compiledFn;
diff --git a/compiler/packages/react-forgive/server/src/compiler/index.ts b/compiler/packages/react-forgive/server/src/compiler/index.ts
index 3723785cfbebd..fe192c62132b6 100644
--- a/compiler/packages/react-forgive/server/src/compiler/index.ts
+++ b/compiler/packages/react-forgive/server/src/compiler/index.ts
@@ -33,6 +33,8 @@ export async function compile({
plugins: ['typescript', 'jsx'],
},
if (ast == null) {
return null;
@@ -48,6 +50,8 @@ export async function compile({
plugins,
sourceFileName: file,
if (result?.code == null) {
throw new Error(
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 0b43e9fcd2945..fd4ffd99886c9 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -132,7 +132,7 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
- connection.console.info(`Changed: ${event.document.uri}`);
+ connection.console.info(`Compiling: ${event.document.uri}`);
resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
@@ -143,8 +143,11 @@ documents.onDidChangeContent(async event => {
options: compilerOptions,
});
} catch (err) {
+ connection.console.error('Failed to compile');
if (err instanceof Error) {
- connection.console.error(err.stack ?? '');
+ connection.console.error(err.stack ?? err.message);
+ } else {
+ connection.console.error(JSON.stringify(err, null, 2));
}
@@ -192,7 +195,6 @@ connection.onCodeLensResolve(lens => {
connection.onCodeAction(params => {
- connection.console.log('onCodeAction');
const codeActions: Array<CodeAction> = [];
for (const codeActionEvent of codeActionEvents) {
if (
@@ -242,6 +244,7 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
function resetState() {
+ connection.console.debug('Clearing state');
compiledFns.clear();
autoDepsDecorations = [];
codeActionEvents = []; | [
"+ /**",
"+ * for validation but we don't mutate the babel AST. This allows us to flag if there is an",
"- /**"
] | [
8,
10,
32
] | {
"additions": 27,
"author": "poteto",
"deletions": 20,
"html_url": "https://github.com/facebook/react/pull/33012",
"issue_id": 33012,
"merged_at": "2025-04-24T17:30:36Z",
"omission_probability": 0.1,
"pr_number": 33012,
"repo": "facebook/react",
"title": "[compiler] Emit CompileSkip before CompileSuccess event",
"total_changes": 47
} |
204 | diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index 5ede6fec5ce58..0adbf3077c285 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -183,7 +183,8 @@ export type LoggerEvent =
| CompileSkipEvent
| PipelineErrorEvent
| TimingEvent
- | AutoDepsDecorationsEvent;
+ | AutoDepsDecorationsEvent
+ | AutoDepsEligibleEvent;
export type CompileErrorEvent = {
kind: 'CompileError';
@@ -222,9 +223,14 @@ export type TimingEvent = {
};
export type AutoDepsDecorationsEvent = {
kind: 'AutoDepsDecorations';
- useEffectCallExpr: t.SourceLocation;
+ fnLoc: t.SourceLocation;
decorations: Array<t.SourceLocation>;
};
+export type AutoDepsEligibleEvent = {
+ kind: 'AutoDepsEligible';
+ fnLoc: t.SourceLocation;
+ depArrayLoc: t.SourceLocation;
+};
export type Logger = {
logEvent: (filename: string | null, event: LoggerEvent) => void;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 275a1a91b154c..472e4cfae3cdc 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -230,7 +230,7 @@ export function inferEffectDependencies(fn: HIRFunction): void {
if (typeof value.loc !== 'symbol') {
fn.env.logger?.logEvent(fn.env.filename, {
kind: 'AutoDepsDecorations',
- useEffectCallExpr: value.loc,
+ fnLoc: value.loc,
decorations,
});
}
@@ -258,6 +258,30 @@ export function inferEffectDependencies(fn: HIRFunction): void {
rewriteInstrs.set(instr.id, newInstructions);
fn.env.inferredEffectLocations.add(callee.loc);
}
+ } else if (
+ value.args.length >= 2 &&
+ value.args.length - 1 === autodepFnLoads.get(callee.identifier.id) &&
+ value.args[0].kind === 'Identifier'
+ ) {
+ const penultimateArg = value.args[value.args.length - 2];
+ const depArrayArg = value.args[value.args.length - 1];
+ if (
+ depArrayArg.kind !== 'Spread' &&
+ penultimateArg.kind !== 'Spread' &&
+ typeof depArrayArg.loc !== 'symbol' &&
+ typeof penultimateArg.loc !== 'symbol' &&
+ typeof value.loc !== 'symbol'
+ ) {
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsEligible',
+ fnLoc: value.loc,
+ depArrayLoc: {
+ ...depArrayArg.loc,
+ start: penultimateArg.loc.end,
+ end: depArrayArg.loc.end,
+ },
+ });
+ }
}
}
}
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 6432e3efc6aea..edb6d63f02507 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -7,10 +7,13 @@
import {TextDocument} from 'vscode-languageserver-textdocument';
import {
+ CodeAction,
+ CodeActionKind,
CodeLens,
createConnection,
type InitializeParams,
type InitializeResult,
+ Position,
ProposedFeatures,
TextDocuments,
TextDocumentSyncKind,
@@ -29,7 +32,12 @@ import {
AutoDepsDecorationsRequest,
mapCompilerEventToLSPEvent,
} from './requests/autodepsdecorations';
-import {isPositionWithinRange} from './utils/range';
+import {
+ isPositionWithinRange,
+ isRangeWithinRange,
+ Range,
+ sourceLocationToRange,
+} from './utils/range';
const SUPPORTED_LANGUAGE_IDS = new Set([
'javascript',
@@ -44,6 +52,15 @@ const documents = new TextDocuments(TextDocument);
let compilerOptions: PluginOptions | null = null;
let compiledFns: Set<CompileSuccessEvent> = new Set();
let autoDepsDecorations: Array<AutoDepsDecorationsLSPEvent> = [];
+let codeActionEvents: Array<CodeActionLSPEvent> = [];
+
+type CodeActionLSPEvent = {
+ title: string;
+ kind: CodeActionKind;
+ newText: string;
+ anchorRange: Range;
+ editRange: {start: Position; end: Position};
+};
connection.onInitialize((_params: InitializeParams) => {
// TODO(@poteto) get config fr
@@ -85,6 +102,16 @@ connection.onInitialize((_params: InitializeParams) => {
if (event.kind === 'AutoDepsDecorations') {
autoDepsDecorations.push(mapCompilerEventToLSPEvent(event));
}
+ if (event.kind === 'AutoDepsEligible') {
+ const depArrayLoc = sourceLocationToRange(event.depArrayLoc);
+ codeActionEvents.push({
+ title: 'Use React Compiler inferred dependency array',
+ kind: CodeActionKind.QuickFix,
+ newText: '',
+ anchorRange: sourceLocationToRange(event.fnLoc),
+ editRange: {start: depArrayLoc[0], end: depArrayLoc[1]},
+ });
+ }
},
},
};
@@ -92,6 +119,7 @@ connection.onInitialize((_params: InitializeParams) => {
capabilities: {
textDocumentSync: TextDocumentSyncKind.Full,
codeLensProvider: {resolveProvider: true},
+ codeActionProvider: {resolveProvider: true},
},
};
return result;
@@ -103,21 +131,25 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
connection.console.info(`Changed: ${event.document.uri}`);
- compiledFns.clear();
- autoDepsDecorations = [];
+ resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
- await compile({
- text,
- file: event.document.uri,
- options: compilerOptions,
- });
+ try {
+ await compile({
+ text,
+ file: event.document.uri,
+ options: compilerOptions,
+ });
+ } catch (err) {
+ if (err instanceof Error) {
+ connection.console.error(err.stack ?? '');
+ }
+ }
}
});
connection.onDidChangeWatchedFiles(change => {
- compiledFns.clear();
- autoDepsDecorations = [];
+ resetState();
connection.console.log(
change.changes.map(c => `File changed: ${c.uri}`).join('\n'),
);
@@ -157,6 +189,44 @@ connection.onCodeLensResolve(lens => {
return lens;
});
+connection.onCodeAction(params => {
+ connection.console.log('onCodeAction');
+ connection.console.log(JSON.stringify(params, null, 2));
+ const codeActions: Array<CodeAction> = [];
+ for (const codeActionEvent of codeActionEvents) {
+ if (
+ isRangeWithinRange(
+ [params.range.start, params.range.end],
+ codeActionEvent.anchorRange,
+ )
+ ) {
+ codeActions.push(
+ CodeAction.create(
+ codeActionEvent.title,
+ {
+ changes: {
+ [params.textDocument.uri]: [
+ {
+ newText: codeActionEvent.newText,
+ range: codeActionEvent.editRange,
+ },
+ ],
+ },
+ },
+ codeActionEvent.kind,
+ ),
+ );
+ }
+ }
+ return codeActions;
+});
+
+connection.onCodeActionResolve(codeAction => {
+ connection.console.log('onCodeActionResolve');
+ connection.console.log(JSON.stringify(codeAction, null, 2));
+ return codeAction;
+});
+
connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
const position = params.position;
connection.console.debug('Client hovering on: ' + JSON.stringify(position));
@@ -168,6 +238,12 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
return null;
});
+function resetState() {
+ compiledFns.clear();
+ autoDepsDecorations = [];
+ codeActionEvents = [];
+}
+
documents.listen(connection);
connection.listen();
connection.console.info(`React Analyzer running in node ${process.version}`);
diff --git a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
index 43f4ac1fb9a2b..6f3a4051fb941 100644
--- a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
+++ b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
@@ -22,7 +22,7 @@ export function mapCompilerEventToLSPEvent(
event: AutoDepsDecorationsEvent,
): AutoDepsDecorationsLSPEvent {
return {
- useEffectCallExpr: sourceLocationToRange(event.useEffectCallExpr),
+ useEffectCallExpr: sourceLocationToRange(event.fnLoc),
decorations: event.decorations.map(sourceLocationToRange),
};
}
diff --git a/compiler/packages/react-forgive/server/src/utils/range.ts b/compiler/packages/react-forgive/server/src/utils/range.ts
index e0665ba8fe8c2..8a16f1bc096a4 100644
--- a/compiler/packages/react-forgive/server/src/utils/range.ts
+++ b/compiler/packages/react-forgive/server/src/utils/range.ts
@@ -2,6 +2,7 @@ import * as t from '@babel/types';
import {type Position} from 'vscode-languageserver/node';
export type Range = [Position, Position];
+
export function isPositionWithinRange(
position: Position,
[start, end]: Range,
@@ -9,6 +10,21 @@ export function isPositionWithinRange(
return position.line >= start.line && position.line <= end.line;
}
+export function isRangeWithinRange(aRange: Range, bRange: Range): boolean {
+ const startComparison = comparePositions(aRange[0], bRange[0]);
+ const endComparison = comparePositions(aRange[1], bRange[1]);
+ return startComparison >= 0 && endComparison <= 0;
+}
+
+function comparePositions(a: Position, b: Position): number {
+ const lineComparison = a.line - b.line;
+ if (lineComparison === 0) {
+ return a.character - b.character;
+ } else {
+ return lineComparison;
+ }
+}
+
export function sourceLocationToRange(
loc: t.SourceLocation,
): [Position, Position] {
| diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index 5ede6fec5ce58..0adbf3077c285 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -183,7 +183,8 @@ export type LoggerEvent =
| CompileSkipEvent
| PipelineErrorEvent
| TimingEvent
- | AutoDepsDecorationsEvent;
+ | AutoDepsDecorationsEvent
+ | AutoDepsEligibleEvent;
export type CompileErrorEvent = {
kind: 'CompileError';
@@ -222,9 +223,14 @@ export type TimingEvent = {
export type AutoDepsDecorationsEvent = {
kind: 'AutoDepsDecorations';
- useEffectCallExpr: t.SourceLocation;
decorations: Array<t.SourceLocation>;
+export type AutoDepsEligibleEvent = {
+ kind: 'AutoDepsEligible';
+ depArrayLoc: t.SourceLocation;
export type Logger = {
logEvent: (filename: string | null, event: LoggerEvent) => void;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 275a1a91b154c..472e4cfae3cdc 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -230,7 +230,7 @@ export function inferEffectDependencies(fn: HIRFunction): void {
if (typeof value.loc !== 'symbol') {
fn.env.logger?.logEvent(fn.env.filename, {
kind: 'AutoDepsDecorations',
- useEffectCallExpr: value.loc,
+ fnLoc: value.loc,
decorations,
});
}
@@ -258,6 +258,30 @@ export function inferEffectDependencies(fn: HIRFunction): void {
rewriteInstrs.set(instr.id, newInstructions);
fn.env.inferredEffectLocations.add(callee.loc);
}
+ } else if (
+ value.args.length >= 2 &&
+ value.args.length - 1 === autodepFnLoads.get(callee.identifier.id) &&
+ value.args[0].kind === 'Identifier'
+ ) {
+ const penultimateArg = value.args[value.args.length - 2];
+ const depArrayArg = value.args[value.args.length - 1];
+ if (
+ depArrayArg.kind !== 'Spread' &&
+ penultimateArg.kind !== 'Spread' &&
+ typeof depArrayArg.loc !== 'symbol' &&
+ typeof penultimateArg.loc !== 'symbol' &&
+ typeof value.loc !== 'symbol'
+ ) {
+ kind: 'AutoDepsEligible',
+ fnLoc: value.loc,
+ depArrayLoc: {
+ ...depArrayArg.loc,
+ start: penultimateArg.loc.end,
+ end: depArrayArg.loc.end,
+ },
+ }
}
}
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 6432e3efc6aea..edb6d63f02507 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -7,10 +7,13 @@
import {TextDocument} from 'vscode-languageserver-textdocument';
import {
+ CodeAction,
+ CodeActionKind,
CodeLens,
createConnection,
type InitializeParams,
type InitializeResult,
+ Position,
ProposedFeatures,
TextDocuments,
TextDocumentSyncKind,
@@ -29,7 +32,12 @@ import {
AutoDepsDecorationsRequest,
mapCompilerEventToLSPEvent,
} from './requests/autodepsdecorations';
-import {isPositionWithinRange} from './utils/range';
+import {
+ isPositionWithinRange,
+ isRangeWithinRange,
+ Range,
+ sourceLocationToRange,
+} from './utils/range';
const SUPPORTED_LANGUAGE_IDS = new Set([
'javascript',
@@ -44,6 +52,15 @@ const documents = new TextDocuments(TextDocument);
let compilerOptions: PluginOptions | null = null;
let compiledFns: Set<CompileSuccessEvent> = new Set();
let autoDepsDecorations: Array<AutoDepsDecorationsLSPEvent> = [];
+let codeActionEvents: Array<CodeActionLSPEvent> = [];
+type CodeActionLSPEvent = {
+ title: string;
+ newText: string;
+ anchorRange: Range;
+ editRange: {start: Position; end: Position};
connection.onInitialize((_params: InitializeParams) => {
// TODO(@poteto) get config fr
@@ -85,6 +102,16 @@ connection.onInitialize((_params: InitializeParams) => {
if (event.kind === 'AutoDepsDecorations') {
autoDepsDecorations.push(mapCompilerEventToLSPEvent(event));
+ if (event.kind === 'AutoDepsEligible') {
+ const depArrayLoc = sourceLocationToRange(event.depArrayLoc);
+ codeActionEvents.push({
+ title: 'Use React Compiler inferred dependency array',
+ kind: CodeActionKind.QuickFix,
+ newText: '',
+ anchorRange: sourceLocationToRange(event.fnLoc),
+ editRange: {start: depArrayLoc[0], end: depArrayLoc[1]},
+ });
+ }
},
@@ -92,6 +119,7 @@ connection.onInitialize((_params: InitializeParams) => {
capabilities: {
textDocumentSync: TextDocumentSyncKind.Full,
codeLensProvider: {resolveProvider: true},
+ codeActionProvider: {resolveProvider: true},
return result;
@@ -103,21 +131,25 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
connection.console.info(`Changed: ${event.document.uri}`);
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
- await compile({
- text,
- file: event.document.uri,
- options: compilerOptions,
- });
+ await compile({
+ text,
+ file: event.document.uri,
+ options: compilerOptions,
+ });
+ } catch (err) {
+ if (err instanceof Error) {
+ connection.console.error(err.stack ?? '');
+ }
}
connection.onDidChangeWatchedFiles(change => {
connection.console.log(
change.changes.map(c => `File changed: ${c.uri}`).join('\n'),
);
@@ -157,6 +189,44 @@ connection.onCodeLensResolve(lens => {
return lens;
+connection.onCodeAction(params => {
+ connection.console.log('onCodeAction');
+ connection.console.log(JSON.stringify(params, null, 2));
+ const codeActions: Array<CodeAction> = [];
+ for (const codeActionEvent of codeActionEvents) {
+ if (
+ isRangeWithinRange(
+ [params.range.start, params.range.end],
+ codeActionEvent.anchorRange,
+ )
+ ) {
+ codeActions.push(
+ CodeAction.create(
+ codeActionEvent.title,
+ changes: {
+ [params.textDocument.uri]: [
+ newText: codeActionEvent.newText,
+ range: codeActionEvent.editRange,
+ },
+ ],
+ },
+ },
+ codeActionEvent.kind,
+ ),
+ );
+connection.onCodeActionResolve(codeAction => {
+ connection.console.log('onCodeActionResolve');
+ connection.console.log(JSON.stringify(codeAction, null, 2));
connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
const position = params.position;
connection.console.debug('Client hovering on: ' + JSON.stringify(position));
@@ -168,6 +238,12 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
return null;
+function resetState() {
+ compiledFns.clear();
+ autoDepsDecorations = [];
documents.listen(connection);
connection.listen();
connection.console.info(`React Analyzer running in node ${process.version}`);
diff --git a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
index 43f4ac1fb9a2b..6f3a4051fb941 100644
--- a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
+++ b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
@@ -22,7 +22,7 @@ export function mapCompilerEventToLSPEvent(
event: AutoDepsDecorationsEvent,
): AutoDepsDecorationsLSPEvent {
return {
+ useEffectCallExpr: sourceLocationToRange(event.fnLoc),
decorations: event.decorations.map(sourceLocationToRange),
diff --git a/compiler/packages/react-forgive/server/src/utils/range.ts b/compiler/packages/react-forgive/server/src/utils/range.ts
index e0665ba8fe8c2..8a16f1bc096a4 100644
--- a/compiler/packages/react-forgive/server/src/utils/range.ts
+++ b/compiler/packages/react-forgive/server/src/utils/range.ts
@@ -2,6 +2,7 @@ import * as t from '@babel/types';
import {type Position} from 'vscode-languageserver/node';
export type Range = [Position, Position];
export function isPositionWithinRange(
position: Position,
[start, end]: Range,
@@ -9,6 +10,21 @@ export function isPositionWithinRange(
return position.line >= start.line && position.line <= end.line;
+export function isRangeWithinRange(aRange: Range, bRange: Range): boolean {
+ const startComparison = comparePositions(aRange[0], bRange[0]);
+ const endComparison = comparePositions(aRange[1], bRange[1]);
+ return startComparison >= 0 && endComparison <= 0;
+function comparePositions(a: Position, b: Position): number {
+ const lineComparison = a.line - b.line;
+ if (lineComparison === 0) {
+ return a.character - b.character;
+ } else {
+ return lineComparison;
export function sourceLocationToRange(
loc: t.SourceLocation,
): [Position, Position] { | [
"+ fn.env.logger?.logEvent(fn.env.filename, {",
"+ });",
"+ kind: CodeActionKind;",
"+ try {",
"+ {",
"+ {",
"+ return codeActions;",
"+ return codeAction;",
"+ codeActionEvents = [];",
"- useEffectCallExpr: sourceLocationToRange(event.useEffectCallExpr),"
] | [
61,
69,
114,
161,
200,
203,
215,
221,
234,
248
] | {
"additions": 136,
"author": "poteto",
"deletions": 14,
"html_url": "https://github.com/facebook/react/pull/33001",
"issue_id": 33001,
"merged_at": "2025-04-24T01:32:11Z",
"omission_probability": 0.1,
"pr_number": 33001,
"repo": "facebook/react",
"title": "[forgive] Don't crash if we couldn't compile",
"total_changes": 150
} |
205 | diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index 5ede6fec5ce58..0adbf3077c285 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -183,7 +183,8 @@ export type LoggerEvent =
| CompileSkipEvent
| PipelineErrorEvent
| TimingEvent
- | AutoDepsDecorationsEvent;
+ | AutoDepsDecorationsEvent
+ | AutoDepsEligibleEvent;
export type CompileErrorEvent = {
kind: 'CompileError';
@@ -222,9 +223,14 @@ export type TimingEvent = {
};
export type AutoDepsDecorationsEvent = {
kind: 'AutoDepsDecorations';
- useEffectCallExpr: t.SourceLocation;
+ fnLoc: t.SourceLocation;
decorations: Array<t.SourceLocation>;
};
+export type AutoDepsEligibleEvent = {
+ kind: 'AutoDepsEligible';
+ fnLoc: t.SourceLocation;
+ depArrayLoc: t.SourceLocation;
+};
export type Logger = {
logEvent: (filename: string | null, event: LoggerEvent) => void;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 275a1a91b154c..472e4cfae3cdc 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -230,7 +230,7 @@ export function inferEffectDependencies(fn: HIRFunction): void {
if (typeof value.loc !== 'symbol') {
fn.env.logger?.logEvent(fn.env.filename, {
kind: 'AutoDepsDecorations',
- useEffectCallExpr: value.loc,
+ fnLoc: value.loc,
decorations,
});
}
@@ -258,6 +258,30 @@ export function inferEffectDependencies(fn: HIRFunction): void {
rewriteInstrs.set(instr.id, newInstructions);
fn.env.inferredEffectLocations.add(callee.loc);
}
+ } else if (
+ value.args.length >= 2 &&
+ value.args.length - 1 === autodepFnLoads.get(callee.identifier.id) &&
+ value.args[0].kind === 'Identifier'
+ ) {
+ const penultimateArg = value.args[value.args.length - 2];
+ const depArrayArg = value.args[value.args.length - 1];
+ if (
+ depArrayArg.kind !== 'Spread' &&
+ penultimateArg.kind !== 'Spread' &&
+ typeof depArrayArg.loc !== 'symbol' &&
+ typeof penultimateArg.loc !== 'symbol' &&
+ typeof value.loc !== 'symbol'
+ ) {
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsEligible',
+ fnLoc: value.loc,
+ depArrayLoc: {
+ ...depArrayArg.loc,
+ start: penultimateArg.loc.end,
+ end: depArrayArg.loc.end,
+ },
+ });
+ }
}
}
}
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 6432e3efc6aea..e4b75df19442a 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -7,10 +7,13 @@
import {TextDocument} from 'vscode-languageserver-textdocument';
import {
+ CodeAction,
+ CodeActionKind,
CodeLens,
createConnection,
type InitializeParams,
type InitializeResult,
+ Position,
ProposedFeatures,
TextDocuments,
TextDocumentSyncKind,
@@ -29,7 +32,12 @@ import {
AutoDepsDecorationsRequest,
mapCompilerEventToLSPEvent,
} from './requests/autodepsdecorations';
-import {isPositionWithinRange} from './utils/range';
+import {
+ isPositionWithinRange,
+ isRangeWithinRange,
+ Range,
+ sourceLocationToRange,
+} from './utils/range';
const SUPPORTED_LANGUAGE_IDS = new Set([
'javascript',
@@ -44,6 +52,15 @@ const documents = new TextDocuments(TextDocument);
let compilerOptions: PluginOptions | null = null;
let compiledFns: Set<CompileSuccessEvent> = new Set();
let autoDepsDecorations: Array<AutoDepsDecorationsLSPEvent> = [];
+let codeActionEvents: Array<CodeActionLSPEvent> = [];
+
+type CodeActionLSPEvent = {
+ title: string;
+ kind: CodeActionKind;
+ newText: string;
+ anchorRange: Range;
+ editRange: {start: Position; end: Position};
+};
connection.onInitialize((_params: InitializeParams) => {
// TODO(@poteto) get config fr
@@ -85,6 +102,16 @@ connection.onInitialize((_params: InitializeParams) => {
if (event.kind === 'AutoDepsDecorations') {
autoDepsDecorations.push(mapCompilerEventToLSPEvent(event));
}
+ if (event.kind === 'AutoDepsEligible') {
+ const depArrayLoc = sourceLocationToRange(event.depArrayLoc);
+ codeActionEvents.push({
+ title: 'Use React Compiler inferred dependency array',
+ kind: CodeActionKind.QuickFix,
+ newText: '',
+ anchorRange: sourceLocationToRange(event.fnLoc),
+ editRange: {start: depArrayLoc[0], end: depArrayLoc[1]},
+ });
+ }
},
},
};
@@ -92,6 +119,7 @@ connection.onInitialize((_params: InitializeParams) => {
capabilities: {
textDocumentSync: TextDocumentSyncKind.Full,
codeLensProvider: {resolveProvider: true},
+ codeActionProvider: {resolveProvider: true},
},
};
return result;
@@ -103,8 +131,7 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
connection.console.info(`Changed: ${event.document.uri}`);
- compiledFns.clear();
- autoDepsDecorations = [];
+ resetState();
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
await compile({
@@ -116,8 +143,7 @@ documents.onDidChangeContent(async event => {
});
connection.onDidChangeWatchedFiles(change => {
- compiledFns.clear();
- autoDepsDecorations = [];
+ resetState();
connection.console.log(
change.changes.map(c => `File changed: ${c.uri}`).join('\n'),
);
@@ -157,6 +183,44 @@ connection.onCodeLensResolve(lens => {
return lens;
});
+connection.onCodeAction(params => {
+ connection.console.log('onCodeAction');
+ connection.console.log(JSON.stringify(params, null, 2));
+ const codeActions: Array<CodeAction> = [];
+ for (const codeActionEvent of codeActionEvents) {
+ if (
+ isRangeWithinRange(
+ [params.range.start, params.range.end],
+ codeActionEvent.anchorRange,
+ )
+ ) {
+ codeActions.push(
+ CodeAction.create(
+ codeActionEvent.title,
+ {
+ changes: {
+ [params.textDocument.uri]: [
+ {
+ newText: codeActionEvent.newText,
+ range: codeActionEvent.editRange,
+ },
+ ],
+ },
+ },
+ codeActionEvent.kind,
+ ),
+ );
+ }
+ }
+ return codeActions;
+});
+
+connection.onCodeActionResolve(codeAction => {
+ connection.console.log('onCodeActionResolve');
+ connection.console.log(JSON.stringify(codeAction, null, 2));
+ return codeAction;
+});
+
connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
const position = params.position;
connection.console.debug('Client hovering on: ' + JSON.stringify(position));
@@ -168,6 +232,12 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
return null;
});
+function resetState() {
+ compiledFns.clear();
+ autoDepsDecorations = [];
+ codeActionEvents = [];
+}
+
documents.listen(connection);
connection.listen();
connection.console.info(`React Analyzer running in node ${process.version}`);
diff --git a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
index 43f4ac1fb9a2b..6f3a4051fb941 100644
--- a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
+++ b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
@@ -22,7 +22,7 @@ export function mapCompilerEventToLSPEvent(
event: AutoDepsDecorationsEvent,
): AutoDepsDecorationsLSPEvent {
return {
- useEffectCallExpr: sourceLocationToRange(event.useEffectCallExpr),
+ useEffectCallExpr: sourceLocationToRange(event.fnLoc),
decorations: event.decorations.map(sourceLocationToRange),
};
}
diff --git a/compiler/packages/react-forgive/server/src/utils/range.ts b/compiler/packages/react-forgive/server/src/utils/range.ts
index e0665ba8fe8c2..8a16f1bc096a4 100644
--- a/compiler/packages/react-forgive/server/src/utils/range.ts
+++ b/compiler/packages/react-forgive/server/src/utils/range.ts
@@ -2,6 +2,7 @@ import * as t from '@babel/types';
import {type Position} from 'vscode-languageserver/node';
export type Range = [Position, Position];
+
export function isPositionWithinRange(
position: Position,
[start, end]: Range,
@@ -9,6 +10,21 @@ export function isPositionWithinRange(
return position.line >= start.line && position.line <= end.line;
}
+export function isRangeWithinRange(aRange: Range, bRange: Range): boolean {
+ const startComparison = comparePositions(aRange[0], bRange[0]);
+ const endComparison = comparePositions(aRange[1], bRange[1]);
+ return startComparison >= 0 && endComparison <= 0;
+}
+
+function comparePositions(a: Position, b: Position): number {
+ const lineComparison = a.line - b.line;
+ if (lineComparison === 0) {
+ return a.character - b.character;
+ } else {
+ return lineComparison;
+ }
+}
+
export function sourceLocationToRange(
loc: t.SourceLocation,
): [Position, Position] {
| diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index 5ede6fec5ce58..0adbf3077c285 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -183,7 +183,8 @@ export type LoggerEvent =
| CompileSkipEvent
| PipelineErrorEvent
| TimingEvent
- | AutoDepsDecorationsEvent;
+ | AutoDepsDecorationsEvent
+ | AutoDepsEligibleEvent;
export type CompileErrorEvent = {
kind: 'CompileError';
@@ -222,9 +223,14 @@ export type TimingEvent = {
export type AutoDepsDecorationsEvent = {
kind: 'AutoDepsDecorations';
- useEffectCallExpr: t.SourceLocation;
decorations: Array<t.SourceLocation>;
+export type AutoDepsEligibleEvent = {
+ kind: 'AutoDepsEligible';
+ depArrayLoc: t.SourceLocation;
export type Logger = {
logEvent: (filename: string | null, event: LoggerEvent) => void;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 275a1a91b154c..472e4cfae3cdc 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -230,7 +230,7 @@ export function inferEffectDependencies(fn: HIRFunction): void {
if (typeof value.loc !== 'symbol') {
fn.env.logger?.logEvent(fn.env.filename, {
kind: 'AutoDepsDecorations',
- useEffectCallExpr: value.loc,
+ fnLoc: value.loc,
decorations,
});
}
@@ -258,6 +258,30 @@ export function inferEffectDependencies(fn: HIRFunction): void {
rewriteInstrs.set(instr.id, newInstructions);
fn.env.inferredEffectLocations.add(callee.loc);
}
+ } else if (
+ value.args.length >= 2 &&
+ value.args[0].kind === 'Identifier'
+ ) {
+ const penultimateArg = value.args[value.args.length - 2];
+ const depArrayArg = value.args[value.args.length - 1];
+ if (
+ penultimateArg.kind !== 'Spread' &&
+ typeof depArrayArg.loc !== 'symbol' &&
+ typeof penultimateArg.loc !== 'symbol' &&
+ ) {
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsEligible',
+ fnLoc: value.loc,
+ depArrayLoc: {
+ ...depArrayArg.loc,
+ start: penultimateArg.loc.end,
+ end: depArrayArg.loc.end,
+ },
+ });
+ }
}
}
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 6432e3efc6aea..e4b75df19442a 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -7,10 +7,13 @@
import {TextDocument} from 'vscode-languageserver-textdocument';
import {
+ CodeAction,
+ CodeActionKind,
CodeLens,
createConnection,
type InitializeParams,
type InitializeResult,
+ Position,
ProposedFeatures,
TextDocuments,
TextDocumentSyncKind,
@@ -29,7 +32,12 @@ import {
AutoDepsDecorationsRequest,
mapCompilerEventToLSPEvent,
} from './requests/autodepsdecorations';
-import {isPositionWithinRange} from './utils/range';
+import {
+ isPositionWithinRange,
+ isRangeWithinRange,
+ Range,
+} from './utils/range';
const SUPPORTED_LANGUAGE_IDS = new Set([
'javascript',
@@ -44,6 +52,15 @@ const documents = new TextDocuments(TextDocument);
let compilerOptions: PluginOptions | null = null;
let compiledFns: Set<CompileSuccessEvent> = new Set();
let autoDepsDecorations: Array<AutoDepsDecorationsLSPEvent> = [];
+let codeActionEvents: Array<CodeActionLSPEvent> = [];
+type CodeActionLSPEvent = {
+ title: string;
+ kind: CodeActionKind;
+ newText: string;
+ anchorRange: Range;
+ editRange: {start: Position; end: Position};
connection.onInitialize((_params: InitializeParams) => {
// TODO(@poteto) get config fr
@@ -85,6 +102,16 @@ connection.onInitialize((_params: InitializeParams) => {
if (event.kind === 'AutoDepsDecorations') {
autoDepsDecorations.push(mapCompilerEventToLSPEvent(event));
+ if (event.kind === 'AutoDepsEligible') {
+ const depArrayLoc = sourceLocationToRange(event.depArrayLoc);
+ codeActionEvents.push({
+ title: 'Use React Compiler inferred dependency array',
+ newText: '',
+ anchorRange: sourceLocationToRange(event.fnLoc),
+ editRange: {start: depArrayLoc[0], end: depArrayLoc[1]},
+ });
},
@@ -92,6 +119,7 @@ connection.onInitialize((_params: InitializeParams) => {
capabilities: {
textDocumentSync: TextDocumentSyncKind.Full,
codeLensProvider: {resolveProvider: true},
return result;
@@ -103,8 +131,7 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
connection.console.info(`Changed: ${event.document.uri}`);
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
await compile({
@@ -116,8 +143,7 @@ documents.onDidChangeContent(async event => {
connection.onDidChangeWatchedFiles(change => {
connection.console.log(
change.changes.map(c => `File changed: ${c.uri}`).join('\n'),
);
@@ -157,6 +183,44 @@ connection.onCodeLensResolve(lens => {
return lens;
+connection.onCodeAction(params => {
+ connection.console.log('onCodeAction');
+ connection.console.log(JSON.stringify(params, null, 2));
+ const codeActions: Array<CodeAction> = [];
+ for (const codeActionEvent of codeActionEvents) {
+ if (
+ isRangeWithinRange(
+ [params.range.start, params.range.end],
+ codeActionEvent.anchorRange,
+ )
+ ) {
+ codeActions.push(
+ CodeAction.create(
+ codeActionEvent.title,
+ {
+ changes: {
+ [params.textDocument.uri]: [
+ {
+ newText: codeActionEvent.newText,
+ range: codeActionEvent.editRange,
+ },
+ ],
+ },
+ codeActionEvent.kind,
+ ),
+ );
+ }
+ return codeActions;
+connection.onCodeActionResolve(codeAction => {
+ connection.console.log('onCodeActionResolve');
+ connection.console.log(JSON.stringify(codeAction, null, 2));
+ return codeAction;
connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
const position = params.position;
connection.console.debug('Client hovering on: ' + JSON.stringify(position));
@@ -168,6 +232,12 @@ connection.onRequest(AutoDepsDecorationsRequest.type, async params => {
return null;
+function resetState() {
+ compiledFns.clear();
+ autoDepsDecorations = [];
+ codeActionEvents = [];
documents.listen(connection);
connection.listen();
connection.console.info(`React Analyzer running in node ${process.version}`);
diff --git a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
index 43f4ac1fb9a2b..6f3a4051fb941 100644
--- a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
+++ b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts
@@ -22,7 +22,7 @@ export function mapCompilerEventToLSPEvent(
event: AutoDepsDecorationsEvent,
): AutoDepsDecorationsLSPEvent {
return {
- useEffectCallExpr: sourceLocationToRange(event.useEffectCallExpr),
+ useEffectCallExpr: sourceLocationToRange(event.fnLoc),
decorations: event.decorations.map(sourceLocationToRange),
diff --git a/compiler/packages/react-forgive/server/src/utils/range.ts b/compiler/packages/react-forgive/server/src/utils/range.ts
index e0665ba8fe8c2..8a16f1bc096a4 100644
--- a/compiler/packages/react-forgive/server/src/utils/range.ts
+++ b/compiler/packages/react-forgive/server/src/utils/range.ts
@@ -2,6 +2,7 @@ import * as t from '@babel/types';
import {type Position} from 'vscode-languageserver/node';
export type Range = [Position, Position];
export function isPositionWithinRange(
position: Position,
[start, end]: Range,
@@ -9,6 +10,21 @@ export function isPositionWithinRange(
return position.line >= start.line && position.line <= end.line;
+export function isRangeWithinRange(aRange: Range, bRange: Range): boolean {
+ const startComparison = comparePositions(aRange[0], bRange[0]);
+ const endComparison = comparePositions(aRange[1], bRange[1]);
+ return startComparison >= 0 && endComparison <= 0;
+function comparePositions(a: Position, b: Position): number {
+ const lineComparison = a.line - b.line;
+ if (lineComparison === 0) {
+ return a.character - b.character;
+ } else {
+ return lineComparison;
export function sourceLocationToRange(
loc: t.SourceLocation,
): [Position, Position] { | [
"+ value.args.length - 1 === autodepFnLoads.get(callee.identifier.id) &&",
"+ depArrayArg.kind !== 'Spread' &&",
"+ typeof value.loc !== 'symbol'",
"+ sourceLocationToRange,",
"+ kind: CodeActionKind.QuickFix,",
"+ }",
"+ codeActionProvider: {resolveProvider: true},",
"+ },"
] | [
49,
55,
59,
101,
130,
135,
143,
193
] | {
"additions": 125,
"author": "poteto",
"deletions": 9,
"html_url": "https://github.com/facebook/react/pull/33000",
"issue_id": 33000,
"merged_at": "2025-04-24T01:31:57Z",
"omission_probability": 0.1,
"pr_number": 33000,
"repo": "facebook/react",
"title": "[forgive] Add code action to remove dependency array",
"total_changes": 134
} |
206 | diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index db55673fa133a..25f67deb974f1 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -222,8 +222,8 @@ export type TimingEvent = {
};
export type AutoDepsDecorations = {
kind: 'AutoDepsDecorations';
- useEffectCallExpr: t.SourceLocation | null;
- decorations: Array<t.SourceLocation | null>;
+ useEffectCallExpr: t.SourceLocation;
+ decorations: Array<t.SourceLocation>;
};
export type Logger = {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index e14b1af11598b..7eb17bcbcb4ef 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -1,3 +1,11 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import * as t from '@babel/types';
import {CompilerError, SourceLocation} from '..';
import {
ArrayExpression,
@@ -212,14 +220,20 @@ export function inferEffectDependencies(fn: HIRFunction): void {
}
// For LSP autodeps feature.
- fn.env.logger?.logEvent(fn.env.filename, {
- kind: 'AutoDepsDecorations',
- useEffectCallExpr:
- typeof value.loc !== 'symbol' ? value.loc : null,
- decorations: collectDepUsages(usedDeps, fnExpr.value).map(loc =>
- typeof loc !== 'symbol' ? loc : null,
- ),
- });
+ const decorations: Array<t.SourceLocation> = [];
+ for (const loc of collectDepUsages(usedDeps, fnExpr.value)) {
+ if (typeof loc === 'symbol') {
+ continue;
+ }
+ decorations.push(loc);
+ }
+ if (typeof value.loc !== 'symbol') {
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsDecorations',
+ useEffectCallExpr: value.loc,
+ decorations,
+ });
+ }
newInstructions.push({
id: makeInstructionId(0),
diff --git a/compiler/packages/react-forgive/client/src/extension.ts b/compiler/packages/react-forgive/client/src/extension.ts
index 402f298fd74c5..0a7ae394354de 100644
--- a/compiler/packages/react-forgive/client/src/extension.ts
+++ b/compiler/packages/react-forgive/client/src/extension.ts
@@ -1,17 +1,22 @@
import * as path from 'path';
-import {ExtensionContext, window as Window} from 'vscode';
+import * as vscode from 'vscode';
import {
LanguageClient,
LanguageClientOptions,
+ Position,
ServerOptions,
TransportKind,
} from 'vscode-languageclient/node';
let client: LanguageClient;
-export function activate(context: ExtensionContext) {
+export function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath(path.join('dist', 'server.js'));
+ const documentSelector = [
+ {scheme: 'file', language: 'javascriptreact'},
+ {scheme: 'file', language: 'typescriptreact'},
+ ];
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
@@ -27,10 +32,7 @@ export function activate(context: ExtensionContext) {
};
const clientOptions: LanguageClientOptions = {
- documentSelector: [
- {scheme: 'file', language: 'javascriptreact'},
- {scheme: 'file', language: 'typescriptreact'},
- ],
+ documentSelector,
progressOnInitialization: true,
};
@@ -43,12 +45,38 @@ export function activate(context: ExtensionContext) {
clientOptions,
);
} catch {
- Window.showErrorMessage(
+ vscode.window.showErrorMessage(
`React Analyzer couldn't be started. See the output channel for details.`,
);
return;
}
+ vscode.languages.registerHoverProvider(documentSelector, {
+ provideHover(_document, position, _token) {
+ client
+ .sendRequest('react/autodepsdecorations', position)
+ .then((decorations: Array<[Position, Position]>) => {
+ for (const [start, end] of decorations) {
+ const range = new vscode.Range(
+ new vscode.Position(start.line, start.character),
+ new vscode.Position(end.line, end.character),
+ );
+ const vscodeDecoration =
+ vscode.window.createTextEditorDecorationType({
+ backgroundColor: 'red',
+ });
+ vscode.window.activeTextEditor?.setDecorations(vscodeDecoration, [
+ {
+ range,
+ hoverMessage: 'hehe',
+ },
+ ]);
+ }
+ });
+ return null;
+ },
+ });
+
client.registerProposedFeatures();
client.start();
}
diff --git a/compiler/packages/react-forgive/server/src/custom-requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/custom-requests/autodepsdecorations.ts
new file mode 100644
index 0000000000000..e05bac5c0fd5a
--- /dev/null
+++ b/compiler/packages/react-forgive/server/src/custom-requests/autodepsdecorations.ts
@@ -0,0 +1,18 @@
+import {AutoDepsDecorations} from 'babel-plugin-react-compiler/src/Entrypoint';
+import {Position} from 'vscode-languageserver-textdocument';
+import {sourceLocationToRange} from '../utils/lsp-adapter';
+
+export type Range = [Position, Position];
+export type AutoDepsDecorationsLSPEvent = {
+ useEffectCallExpr: Range;
+ decorations: Array<Range>;
+};
+
+export function mapCompilerEventToLSPEvent(
+ event: AutoDepsDecorations,
+): AutoDepsDecorationsLSPEvent {
+ return {
+ useEffectCallExpr: sourceLocationToRange(event.useEffectCallExpr),
+ decorations: event.decorations.map(sourceLocationToRange),
+ };
+}
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 395969c5e06bf..c4b4f72c295ad 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-import {TextDocument} from 'vscode-languageserver-textdocument';
+import {Position, TextDocument} from 'vscode-languageserver-textdocument';
import {
CodeLens,
createConnection,
@@ -24,6 +24,10 @@ import {
LoggerEvent,
} from 'babel-plugin-react-compiler/src/Entrypoint/Options';
import {babelLocationToRange, getRangeFirstCharacter} from './compiler/compat';
+import {
+ AutoDepsDecorationsLSPEvent,
+ mapCompilerEventToLSPEvent,
+} from './custom-requests/autodepsdecorations';
const SUPPORTED_LANGUAGE_IDS = new Set([
'javascript',
@@ -37,17 +41,48 @@ const documents = new TextDocuments(TextDocument);
let compilerOptions: PluginOptions | null = null;
let compiledFns: Set<CompileSuccessEvent> = new Set();
+let autoDepsDecorations: Array<AutoDepsDecorationsLSPEvent> = [];
connection.onInitialize((_params: InitializeParams) => {
// TODO(@poteto) get config fr
compilerOptions = resolveReactConfig('.') ?? defaultOptions;
compilerOptions = {
...compilerOptions,
+ environment: {
+ ...compilerOptions.environment,
+ inferEffectDependencies: [
+ {
+ function: {
+ importSpecifierName: 'useEffect',
+ source: 'react',
+ },
+ numRequiredArgs: 1,
+ },
+ {
+ function: {
+ importSpecifierName: 'useSpecialEffect',
+ source: 'shared-runtime',
+ },
+ numRequiredArgs: 2,
+ },
+ {
+ function: {
+ importSpecifierName: 'default',
+ source: 'useEffectWrapper',
+ },
+ numRequiredArgs: 1,
+ },
+ ],
+ },
logger: {
logEvent(_filename: string | null, event: LoggerEvent) {
+ connection.console.info(`Received event: ${event.kind}`);
if (event.kind === 'CompileSuccess') {
compiledFns.add(event);
}
+ if (event.kind === 'AutoDepsDecorations') {
+ autoDepsDecorations.push(mapCompilerEventToLSPEvent(event));
+ }
},
},
};
@@ -67,6 +102,7 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
connection.console.info(`Changed: ${event.document.uri}`);
compiledFns.clear();
+ autoDepsDecorations = [];
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
await compile({
@@ -79,6 +115,7 @@ documents.onDidChangeContent(async event => {
connection.onDidChangeWatchedFiles(change => {
compiledFns.clear();
+ autoDepsDecorations = [];
connection.console.log(
change.changes.map(c => `File changed: ${c.uri}`).join('\n'),
);
@@ -118,6 +155,25 @@ connection.onCodeLensResolve(lens => {
return lens;
});
+connection.onRequest('react/autodepsdecorations', (position: Position) => {
+ connection.console.log('Client hovering on: ' + JSON.stringify(position));
+ connection.console.log(JSON.stringify(autoDepsDecorations, null, 2));
+
+ for (const dec of autoDepsDecorations) {
+ // TODO: extract to helper
+ if (
+ position.line >= dec.useEffectCallExpr[0].line &&
+ position.line <= dec.useEffectCallExpr[1].line
+ ) {
+ connection.console.log(
+ 'found decoration: ' + JSON.stringify(dec.decorations),
+ );
+ return dec.decorations;
+ }
+ }
+ return null;
+});
+
documents.listen(connection);
connection.listen();
connection.console.info(`React Analyzer running in node ${process.version}`);
diff --git a/compiler/packages/react-forgive/server/src/utils/lsp-adapter.ts b/compiler/packages/react-forgive/server/src/utils/lsp-adapter.ts
new file mode 100644
index 0000000000000..3a6b92320995b
--- /dev/null
+++ b/compiler/packages/react-forgive/server/src/utils/lsp-adapter.ts
@@ -0,0 +1,11 @@
+import * as t from '@babel/types';
+import {Position} from 'vscode-languageserver/node';
+
+export function sourceLocationToRange(
+ loc: t.SourceLocation,
+): [Position, Position] {
+ return [
+ {line: loc.start.line - 1, character: loc.start.column},
+ {line: loc.end.line - 1, character: loc.end.column},
+ ];
+}
| diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index db55673fa133a..25f67deb974f1 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -222,8 +222,8 @@ export type TimingEvent = {
export type AutoDepsDecorations = {
kind: 'AutoDepsDecorations';
- useEffectCallExpr: t.SourceLocation | null;
- decorations: Array<t.SourceLocation | null>;
+ useEffectCallExpr: t.SourceLocation;
+ decorations: Array<t.SourceLocation>;
export type Logger = {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index e14b1af11598b..7eb17bcbcb4ef 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -1,3 +1,11 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
import {CompilerError, SourceLocation} from '..';
ArrayExpression,
@@ -212,14 +220,20 @@ export function inferEffectDependencies(fn: HIRFunction): void {
}
// For LSP autodeps feature.
- fn.env.logger?.logEvent(fn.env.filename, {
- kind: 'AutoDepsDecorations',
- useEffectCallExpr:
- typeof value.loc !== 'symbol' ? value.loc : null,
- typeof loc !== 'symbol' ? loc : null,
- ),
- });
+ const decorations: Array<t.SourceLocation> = [];
+ if (typeof loc === 'symbol') {
+ continue;
+ }
+ decorations.push(loc);
+ if (typeof value.loc !== 'symbol') {
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsDecorations',
+ useEffectCallExpr: value.loc,
+ decorations,
newInstructions.push({
id: makeInstructionId(0),
diff --git a/compiler/packages/react-forgive/client/src/extension.ts b/compiler/packages/react-forgive/client/src/extension.ts
index 402f298fd74c5..0a7ae394354de 100644
--- a/compiler/packages/react-forgive/client/src/extension.ts
+++ b/compiler/packages/react-forgive/client/src/extension.ts
@@ -1,17 +1,22 @@
import * as path from 'path';
-import {ExtensionContext, window as Window} from 'vscode';
+import * as vscode from 'vscode';
LanguageClient,
LanguageClientOptions,
+ Position,
ServerOptions,
TransportKind,
} from 'vscode-languageclient/node';
let client: LanguageClient;
-export function activate(context: ExtensionContext) {
+export function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath(path.join('dist', 'server.js'));
+ {scheme: 'file', language: 'javascriptreact'},
+ {scheme: 'file', language: 'typescriptreact'},
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
@@ -27,10 +32,7 @@ export function activate(context: ExtensionContext) {
const clientOptions: LanguageClientOptions = {
- documentSelector: [
- {scheme: 'file', language: 'javascriptreact'},
- {scheme: 'file', language: 'typescriptreact'},
+ documentSelector,
progressOnInitialization: true,
@@ -43,12 +45,38 @@ export function activate(context: ExtensionContext) {
clientOptions,
} catch {
- Window.showErrorMessage(
+ vscode.window.showErrorMessage(
`React Analyzer couldn't be started. See the output channel for details.`,
return;
}
+ vscode.languages.registerHoverProvider(documentSelector, {
+ provideHover(_document, position, _token) {
+ client
+ .sendRequest('react/autodepsdecorations', position)
+ .then((decorations: Array<[Position, Position]>) => {
+ for (const [start, end] of decorations) {
+ const range = new vscode.Range(
+ new vscode.Position(end.line, end.character),
+ );
+ const vscodeDecoration =
+ vscode.window.createTextEditorDecorationType({
+ backgroundColor: 'red',
+ vscode.window.activeTextEditor?.setDecorations(vscodeDecoration, [
+ {
+ range,
+ hoverMessage: 'hehe',
+ },
+ ]);
+ }
+ });
+ });
client.registerProposedFeatures();
client.start();
}
diff --git a/compiler/packages/react-forgive/server/src/custom-requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/custom-requests/autodepsdecorations.ts
index 0000000000000..e05bac5c0fd5a
+++ b/compiler/packages/react-forgive/server/src/custom-requests/autodepsdecorations.ts
@@ -0,0 +1,18 @@
+import {AutoDepsDecorations} from 'babel-plugin-react-compiler/src/Entrypoint';
+import {Position} from 'vscode-languageserver-textdocument';
+import {sourceLocationToRange} from '../utils/lsp-adapter';
+export type Range = [Position, Position];
+export type AutoDepsDecorationsLSPEvent = {
+ useEffectCallExpr: Range;
+ decorations: Array<Range>;
+};
+export function mapCompilerEventToLSPEvent(
+ event: AutoDepsDecorations,
+): AutoDepsDecorationsLSPEvent {
+ useEffectCallExpr: sourceLocationToRange(event.useEffectCallExpr),
+ decorations: event.decorations.map(sourceLocationToRange),
+ };
diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts
index 395969c5e06bf..c4b4f72c295ad 100644
--- a/compiler/packages/react-forgive/server/src/index.ts
+++ b/compiler/packages/react-forgive/server/src/index.ts
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
+import {Position, TextDocument} from 'vscode-languageserver-textdocument';
CodeLens,
createConnection,
@@ -24,6 +24,10 @@ import {
LoggerEvent,
} from 'babel-plugin-react-compiler/src/Entrypoint/Options';
import {babelLocationToRange, getRangeFirstCharacter} from './compiler/compat';
+import {
+ AutoDepsDecorationsLSPEvent,
+} from './custom-requests/autodepsdecorations';
const SUPPORTED_LANGUAGE_IDS = new Set([
'javascript',
@@ -37,17 +41,48 @@ const documents = new TextDocuments(TextDocument);
let compilerOptions: PluginOptions | null = null;
let compiledFns: Set<CompileSuccessEvent> = new Set();
+let autoDepsDecorations: Array<AutoDepsDecorationsLSPEvent> = [];
connection.onInitialize((_params: InitializeParams) => {
// TODO(@poteto) get config fr
compilerOptions = resolveReactConfig('.') ?? defaultOptions;
compilerOptions = {
...compilerOptions,
+ environment: {
+ ...compilerOptions.environment,
+ inferEffectDependencies: [
+ importSpecifierName: 'useEffect',
+ source: 'react',
+ source: 'shared-runtime',
+ numRequiredArgs: 2,
+ importSpecifierName: 'default',
+ source: 'useEffectWrapper',
+ ],
logger: {
logEvent(_filename: string | null, event: LoggerEvent) {
+ connection.console.info(`Received event: ${event.kind}`);
if (event.kind === 'CompileSuccess') {
compiledFns.add(event);
}
+ if (event.kind === 'AutoDepsDecorations') {
+ autoDepsDecorations.push(mapCompilerEventToLSPEvent(event));
+ }
},
},
@@ -67,6 +102,7 @@ connection.onInitialized(() => {
documents.onDidChangeContent(async event => {
connection.console.info(`Changed: ${event.document.uri}`);
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
const text = event.document.getText();
await compile({
@@ -79,6 +115,7 @@ documents.onDidChangeContent(async event => {
connection.onDidChangeWatchedFiles(change => {
connection.console.log(
change.changes.map(c => `File changed: ${c.uri}`).join('\n'),
);
@@ -118,6 +155,25 @@ connection.onCodeLensResolve(lens => {
return lens;
});
+ connection.console.log(JSON.stringify(autoDepsDecorations, null, 2));
+ for (const dec of autoDepsDecorations) {
+ // TODO: extract to helper
+ if (
+ position.line >= dec.useEffectCallExpr[0].line &&
+ position.line <= dec.useEffectCallExpr[1].line
+ ) {
+ connection.console.log(
+ 'found decoration: ' + JSON.stringify(dec.decorations),
+ }
+ }
+ return null;
+});
documents.listen(connection);
connection.listen();
connection.console.info(`React Analyzer running in node ${process.version}`);
diff --git a/compiler/packages/react-forgive/server/src/utils/lsp-adapter.ts b/compiler/packages/react-forgive/server/src/utils/lsp-adapter.ts
index 0000000000000..3a6b92320995b
+++ b/compiler/packages/react-forgive/server/src/utils/lsp-adapter.ts
@@ -0,0 +1,11 @@
+import {Position} from 'vscode-languageserver/node';
+export function sourceLocationToRange(
+ loc: t.SourceLocation,
+): [Position, Position] {
+ return [
+ {line: loc.start.line - 1, character: loc.start.column},
+ {line: loc.end.line - 1, character: loc.end.column}, | [
"- decorations: collectDepUsages(usedDeps, fnExpr.value).map(loc =>",
"+ for (const loc of collectDepUsages(usedDeps, fnExpr.value)) {",
"+ const documentSelector = [",
"- ],",
"+ new vscode.Position(start.line, start.character),",
"+ return null;",
"+ return {",
"-import {TextDocument} from 'vscode-languageserver-textdocument';",
"+ mapCompilerEventToLSPEvent,",
"+ importSpecifierName: 'useSpecialEffect',",
"+connection.onRequest('react/autodepsdecorations', (position: Position) => {",
"+ connection.console.log('Client hovering on: ' + JSON.stringify(position));",
"+ );",
"+ return dec.decorations;"
] | [
39,
44,
82,
96,
119,
134,
160,
173,
184,
212,
258,
259,
270,
271
] | {
"additions": 145,
"author": "poteto",
"deletions": 18,
"html_url": "https://github.com/facebook/react/pull/32998",
"issue_id": 32998,
"merged_at": "2025-04-24T01:21:44Z",
"omission_probability": 0.1,
"pr_number": 32998,
"repo": "facebook/react",
"title": "[forgive] Hacky first pass at adding decorations for inferred deps",
"total_changes": 163
} |
207 | diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index e0c670c5641cd..db55673fa133a 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -182,7 +182,8 @@ export type LoggerEvent =
| CompileDiagnosticEvent
| CompileSkipEvent
| PipelineErrorEvent
- | TimingEvent;
+ | TimingEvent
+ | AutoDepsDecorations;
export type CompileErrorEvent = {
kind: 'CompileError';
@@ -219,6 +220,11 @@ export type TimingEvent = {
kind: 'Timing';
measurement: PerformanceMeasure;
};
+export type AutoDepsDecorations = {
+ kind: 'AutoDepsDecorations';
+ useEffectCallExpr: t.SourceLocation | null;
+ decorations: Array<t.SourceLocation | null>;
+};
export type Logger = {
logEvent: (filename: string | null, event: LoggerEvent) => void;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts
index 61f57f68cfeb9..8dfdc76978cc2 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts
@@ -392,6 +392,11 @@ function runWithEnvironment(
if (env.config.inferEffectDependencies) {
inferEffectDependencies(hir);
+ log({
+ kind: 'hir',
+ name: 'InferEffectDependencies',
+ value: hir,
+ });
}
if (env.config.inlineJsxTransform) {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 0d27ac7ca0f69..e14b1af11598b 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -188,6 +188,7 @@ export function inferEffectDependencies(fn: HIRFunction): void {
* the `infer-effect-deps/pruned-nonreactive-obj` fixture for an
* explanation.
*/
+ const usedDeps = [];
for (const dep of scopeInfo.deps) {
if (
((isUseRefType(dep.identifier) ||
@@ -207,8 +208,19 @@ export function inferEffectDependencies(fn: HIRFunction): void {
);
newInstructions.push(...instructions);
effectDeps.push(place);
+ usedDeps.push(dep);
}
+ // For LSP autodeps feature.
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsDecorations',
+ useEffectCallExpr:
+ typeof value.loc !== 'symbol' ? value.loc : null,
+ decorations: collectDepUsages(usedDeps, fnExpr.value).map(loc =>
+ typeof loc !== 'symbol' ? loc : null,
+ ),
+ });
+
newInstructions.push({
id: makeInstructionId(0),
loc: GeneratedSource,
@@ -340,3 +352,31 @@ function inferReactiveIdentifiers(fn: HIRFunction): Set<IdentifierId> {
}
return reactiveIds;
}
+
+function collectDepUsages(
+ deps: Array<ReactiveScopeDependency>,
+ fnExpr: FunctionExpression,
+): Array<SourceLocation> {
+ const identifiers: Map<IdentifierId, ReactiveScopeDependency> = new Map();
+ const loadedDeps: Set<IdentifierId> = new Set();
+ const sourceLocations = [];
+ for (const dep of deps) {
+ identifiers.set(dep.identifier.id, dep);
+ }
+
+ for (const [, block] of fnExpr.loweredFunc.func.body.blocks) {
+ for (const instr of block.instructions) {
+ if (instr.value.kind === 'LoadLocal') {
+ loadedDeps.add(instr.lvalue.identifier.id);
+ }
+ for (const place of eachInstructionOperand(instr)) {
+ if (loadedDeps.has(place.identifier.id)) {
+ // TODO(@jbrown215): handle member exprs!!
+ sourceLocations.push(place.identifier.loc);
+ }
+ }
+ }
+ }
+
+ return sourceLocations;
+}
| diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
index e0c670c5641cd..db55673fa133a 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
@@ -182,7 +182,8 @@ export type LoggerEvent =
| CompileDiagnosticEvent
| CompileSkipEvent
| PipelineErrorEvent
- | TimingEvent;
+ | TimingEvent
+ | AutoDepsDecorations;
export type CompileErrorEvent = {
kind: 'CompileError';
@@ -219,6 +220,11 @@ export type TimingEvent = {
kind: 'Timing';
measurement: PerformanceMeasure;
};
+export type AutoDepsDecorations = {
+ kind: 'AutoDepsDecorations';
+ useEffectCallExpr: t.SourceLocation | null;
+ decorations: Array<t.SourceLocation | null>;
+};
export type Logger = {
logEvent: (filename: string | null, event: LoggerEvent) => void;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts
index 61f57f68cfeb9..8dfdc76978cc2 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts
@@ -392,6 +392,11 @@ function runWithEnvironment(
if (env.config.inferEffectDependencies) {
inferEffectDependencies(hir);
+ log({
+ kind: 'hir',
+ name: 'InferEffectDependencies',
+ value: hir,
+ });
if (env.config.inlineJsxTransform) {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 0d27ac7ca0f69..e14b1af11598b 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -188,6 +188,7 @@ export function inferEffectDependencies(fn: HIRFunction): void {
* the `infer-effect-deps/pruned-nonreactive-obj` fixture for an
* explanation.
*/
+ const usedDeps = [];
for (const dep of scopeInfo.deps) {
if (
((isUseRefType(dep.identifier) ||
@@ -207,8 +208,19 @@ export function inferEffectDependencies(fn: HIRFunction): void {
);
newInstructions.push(...instructions);
effectDeps.push(place);
+ usedDeps.push(dep);
}
+ // For LSP autodeps feature.
+ fn.env.logger?.logEvent(fn.env.filename, {
+ kind: 'AutoDepsDecorations',
+ useEffectCallExpr:
+ typeof value.loc !== 'symbol' ? value.loc : null,
+ decorations: collectDepUsages(usedDeps, fnExpr.value).map(loc =>
+ ),
+ });
newInstructions.push({
id: makeInstructionId(0),
loc: GeneratedSource,
@@ -340,3 +352,31 @@ function inferReactiveIdentifiers(fn: HIRFunction): Set<IdentifierId> {
return reactiveIds;
}
+function collectDepUsages(
+ deps: Array<ReactiveScopeDependency>,
+ fnExpr: FunctionExpression,
+): Array<SourceLocation> {
+ const identifiers: Map<IdentifierId, ReactiveScopeDependency> = new Map();
+ const loadedDeps: Set<IdentifierId> = new Set();
+ const sourceLocations = [];
+ for (const dep of deps) {
+ identifiers.set(dep.identifier.id, dep);
+ if (instr.value.kind === 'LoadLocal') {
+ loadedDeps.add(instr.lvalue.identifier.id);
+ for (const place of eachInstructionOperand(instr)) {
+ if (loadedDeps.has(place.identifier.id)) {
+ // TODO(@jbrown215): handle member exprs!!
+ }
+ }
+ return sourceLocations;
+} | [
"+ typeof loc !== 'symbol' ? loc : null,",
"+ for (const [, block] of fnExpr.loweredFunc.func.body.blocks) {",
"+ for (const instr of block.instructions) {",
"+ sourceLocations.push(place.identifier.loc);"
] | [
67,
90,
91,
98
] | {
"additions": 52,
"author": "poteto",
"deletions": 1,
"html_url": "https://github.com/facebook/react/pull/32997",
"issue_id": 32997,
"merged_at": "2025-04-24T00:51:38Z",
"omission_probability": 0.1,
"pr_number": 32997,
"repo": "facebook/react",
"title": "[forgive] Emit AutoDepsDecoration event when inferring effect deps",
"total_changes": 53
} |
208 | diff --git a/packages/react-reconciler/src/ReactFiberSuspenseContext.js b/packages/react-reconciler/src/ReactFiberSuspenseContext.js
index 7bc365e84a383..8f712b1b106fc 100644
--- a/packages/react-reconciler/src/ReactFiberSuspenseContext.js
+++ b/packages/react-reconciler/src/ReactFiberSuspenseContext.js
@@ -11,7 +11,6 @@ import type {SuspenseProps} from 'shared/ReactTypes';
import type {Fiber} from './ReactInternalTypes';
import type {StackCursor} from './ReactFiberStack';
import type {SuspenseState} from './ReactFiberSuspenseComponent';
-import type {OffscreenState} from './ReactFiberOffscreenComponent';
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
import {createCursor, push, pop} from './ReactFiberStack';
@@ -115,19 +114,10 @@ export function pushOffscreenSuspenseHandler(fiber: Fiber): void {
// into separate functions for Suspense and Offscreen.
pushSuspenseListContext(fiber, suspenseStackCursor.current);
push(suspenseHandlerStackCursor, fiber, fiber);
- if (shellBoundary !== null) {
- // A parent boundary is showing a fallback, so we've already rendered
- // deeper than the shell.
- } else {
- const current = fiber.alternate;
- if (current !== null) {
- const prevState: OffscreenState = current.memoizedState;
- if (prevState !== null) {
- // This is the first boundary in the stack that's already showing
- // a fallback. So everything outside is considered the shell.
- shellBoundary = fiber;
- }
- }
+ if (shellBoundary === null) {
+ // We're rendering hidden content. If it suspends, we can handle it by
+ // just not committing the offscreen boundary.
+ shellBoundary = fiber;
}
} else {
// This is a LegacyHidden component.
| diff --git a/packages/react-reconciler/src/ReactFiberSuspenseContext.js b/packages/react-reconciler/src/ReactFiberSuspenseContext.js
index 7bc365e84a383..8f712b1b106fc 100644
--- a/packages/react-reconciler/src/ReactFiberSuspenseContext.js
+++ b/packages/react-reconciler/src/ReactFiberSuspenseContext.js
@@ -11,7 +11,6 @@ import type {SuspenseProps} from 'shared/ReactTypes';
import type {Fiber} from './ReactInternalTypes';
import type {StackCursor} from './ReactFiberStack';
import type {SuspenseState} from './ReactFiberSuspenseComponent';
-import type {OffscreenState} from './ReactFiberOffscreenComponent';
import {enableSuspenseAvoidThisFallback} from 'shared/ReactFeatureFlags';
import {createCursor, push, pop} from './ReactFiberStack';
@@ -115,19 +114,10 @@ export function pushOffscreenSuspenseHandler(fiber: Fiber): void {
// into separate functions for Suspense and Offscreen.
pushSuspenseListContext(fiber, suspenseStackCursor.current);
push(suspenseHandlerStackCursor, fiber, fiber);
- // deeper than the shell.
- } else {
- const current = fiber.alternate;
- const prevState: OffscreenState = current.memoizedState;
- if (prevState !== null) {
- // This is the first boundary in the stack that's already showing
- // a fallback. So everything outside is considered the shell.
- shellBoundary = fiber;
- }
- }
+ // We're rendering hidden content. If it suspends, we can handle it by
+ // just not committing the offscreen boundary.
+ shellBoundary = fiber;
}
} else {
// This is a LegacyHidden component. | [
"- if (shellBoundary !== null) {",
"- // A parent boundary is showing a fallback, so we've already rendered",
"- if (current !== null) {",
"+ if (shellBoundary === null) {"
] | [
16,
17,
21,
29
] | {
"additions": 4,
"author": "sebmarkbage",
"deletions": 14,
"html_url": "https://github.com/facebook/react/pull/32844",
"issue_id": 32844,
"merged_at": "2025-04-22T23:39:09Z",
"omission_probability": 0.1,
"pr_number": 32844,
"repo": "facebook/react",
"title": "Set hidden Offscreen to the shellBoundary regardless of previous state",
"total_changes": 18
} |
209 | diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 2d29781dfee97..2e6f4f2d4d43d 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -1127,6 +1127,61 @@ export function clearSuspenseBoundaryFromContainer(
retryIfBlockedOn(container);
}
+function hideOrUnhideSuspenseBoundary(
+ suspenseInstance: SuspenseInstance,
+ isHidden: boolean,
+) {
+ let node: Node = suspenseInstance;
+ // Unhide all nodes within this suspense boundary.
+ let depth = 0;
+ do {
+ const nextNode = node.nextSibling;
+ if (node.nodeType === ELEMENT_NODE) {
+ const instance = ((node: any): HTMLElement & {_stashedDisplay?: string});
+ if (isHidden) {
+ instance._stashedDisplay = instance.style.display;
+ instance.style.display = 'none';
+ } else {
+ instance.style.display = instance._stashedDisplay || '';
+ if (instance.getAttribute('style') === '') {
+ instance.removeAttribute('style');
+ }
+ }
+ } else if (node.nodeType === TEXT_NODE) {
+ const textNode = ((node: any): Text & {_stashedText?: string});
+ if (isHidden) {
+ textNode._stashedText = textNode.nodeValue;
+ textNode.nodeValue = '';
+ } else {
+ textNode.nodeValue = textNode._stashedText || '';
+ }
+ }
+ if (nextNode && nextNode.nodeType === COMMENT_NODE) {
+ const data = ((nextNode: any).data: string);
+ if (data === SUSPENSE_END_DATA) {
+ if (depth === 0) {
+ return;
+ } else {
+ depth--;
+ }
+ } else if (
+ data === SUSPENSE_START_DATA ||
+ data === SUSPENSE_PENDING_START_DATA ||
+ data === SUSPENSE_FALLBACK_START_DATA
+ ) {
+ depth++;
+ }
+ // TODO: Should we hide preamble contribution in this case?
+ }
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
+ node = nextNode;
+ } while (node);
+}
+
+export function hideSuspenseBoundary(suspenseInstance: SuspenseInstance): void {
+ hideOrUnhideSuspenseBoundary(suspenseInstance, true);
+}
+
export function hideInstance(instance: Instance): void {
// TODO: Does this work for all element types? What about MathML? Should we
// pass host context to this method?
@@ -1144,6 +1199,12 @@ export function hideTextInstance(textInstance: TextInstance): void {
textInstance.nodeValue = '';
}
+export function unhideSuspenseBoundary(
+ suspenseInstance: SuspenseInstance,
+): void {
+ hideOrUnhideSuspenseBoundary(suspenseInstance, false);
+}
+
export function unhideInstance(instance: Instance, props: Props): void {
instance = ((instance: any): HTMLElement);
const styleProp = props[STYLE];
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 86a0ceb42e84a..b651c85a8d8f8 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -3945,4 +3945,94 @@ describe('ReactDOMServerPartialHydration', () => {
"onRecoverableError: Hydration failed because the server rendered text didn't match the client.",
]);
});
+
+ it('hides a dehydrated suspense boundary if the parent resuspends', async () => {
+ let suspend = false;
+ let resolve;
+ const promise = new Promise(resolvePromise => (resolve = resolvePromise));
+ const ref = React.createRef();
+
+ function Child({text}) {
+ if (suspend) {
+ throw promise;
+ } else {
+ return text;
+ }
+ }
+
+ function Sibling({resuspend}) {
+ if (suspend && resuspend) {
+ throw promise;
+ } else {
+ return null;
+ }
+ }
+
+ function Component({text}) {
+ return (
+ <Suspense>
+ <Child text={text} />
+ <span ref={ref}>World</span>
+ </Suspense>
+ );
+ }
+
+ function App({text, resuspend}) {
+ const memoized = React.useMemo(() => <Component text={text} />, [text]);
+ return (
+ <div>
+ <Suspense fallback="Loading...">
+ {memoized}
+ <Sibling resuspend={resuspend} />
+ </Suspense>
+ </div>
+ );
+ }
+
+ suspend = false;
+ const finalHTML = ReactDOMServer.renderToString(<App text="Hello" />);
+ const container = document.createElement('div');
+ container.innerHTML = finalHTML;
+
+ // On the client we don't have all data yet but we want to start
+ // hydrating anyway.
+ suspend = true;
+ const root = ReactDOMClient.hydrateRoot(container, <App text="Hello" />, {
+ onRecoverableError(error) {
+ Scheduler.log('onRecoverableError: ' + normalizeError(error.message));
+ if (error.cause) {
+ Scheduler.log('Cause: ' + normalizeError(error.cause.message));
+ }
+ },
+ });
+ await waitForAll([]);
+
+ expect(ref.current).toBe(null); // Still dehydrated
+ const span = container.getElementsByTagName('span')[0];
+ const textNode = span.previousSibling;
+ expect(textNode.nodeValue).toBe('Hello');
+ expect(span.textContent).toBe('World');
+
+ // Render an update, that resuspends the parent boundary.
+ // Flushing now now hide the text content.
+ await act(() => {
+ root.render(<App text="Hello" resuspend={true} />);
+ });
+
+ expect(ref.current).toBe(null);
+ expect(span.style.display).toBe('none');
+ expect(textNode.nodeValue).toBe('');
+
+ // Unsuspending shows the content.
+ await act(async () => {
+ suspend = false;
+ resolve();
+ await promise;
+ });
+
+ expect(textNode.nodeValue).toBe('Hello');
+ expect(span.textContent).toBe('World');
+ expect(span.style.display).toBe('');
+ expect(ref.current).toBe(span);
+ });
});
diff --git a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js
index 2ca49f677de1f..4548e30ec65ac 100644
--- a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js
+++ b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js
@@ -41,8 +41,10 @@ import {
insertBefore,
insertInContainerBefore,
replaceContainerChildren,
+ hideSuspenseBoundary,
hideInstance,
hideTextInstance,
+ unhideSuspenseBoundary,
unhideInstance,
unhideTextInstance,
commitHydratedContainer,
@@ -152,6 +154,27 @@ export function commitHostResetTextContent(finishedWork: Fiber) {
}
}
+export function commitShowHideSuspenseBoundary(node: Fiber, isHidden: boolean) {
+ try {
+ const instance = node.stateNode;
+ if (isHidden) {
+ if (__DEV__) {
+ runWithFiberInDEV(node, hideSuspenseBoundary, instance);
+ } else {
+ hideSuspenseBoundary(instance);
+ }
+ } else {
+ if (__DEV__) {
+ runWithFiberInDEV(node, unhideSuspenseBoundary, node.stateNode);
+ } else {
+ unhideSuspenseBoundary(node.stateNode);
+ }
+ }
+ } catch (error) {
+ captureCommitPhaseError(node, node.return, error);
+ }
+}
+
export function commitShowHideHostInstance(node: Fiber, isHidden: boolean) {
try {
const instance = node.stateNode;
diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js
index 92e6883c8c652..8065432370add 100644
--- a/packages/react-reconciler/src/ReactFiberCommitWork.js
+++ b/packages/react-reconciler/src/ReactFiberCommitWork.js
@@ -227,6 +227,7 @@ import {
commitHostUpdate,
commitHostTextUpdate,
commitHostResetTextContent,
+ commitShowHideSuspenseBoundary,
commitShowHideHostInstance,
commitShowHideHostTextInstance,
commitHostPlacement,
@@ -1158,6 +1159,10 @@ function hideOrUnhideAllChildren(finishedWork: Fiber, isHidden: boolean) {
if (hostSubtreeRoot === null) {
commitShowHideHostTextInstance(node, isHidden);
}
+ } else if (node.tag === DehydratedFragment) {
+ if (hostSubtreeRoot === null) {
+ commitShowHideSuspenseBoundary(node, isHidden);
+ }
} else if (
(node.tag === OffscreenComponent ||
node.tag === LegacyHiddenComponent) &&
diff --git a/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js b/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
index 0bb85246dfe24..fb190d410bba0 100644
--- a/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
+++ b/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
@@ -44,6 +44,8 @@ export const commitHydratedContainer = shim;
export const commitHydratedSuspenseInstance = shim;
export const clearSuspenseBoundary = shim;
export const clearSuspenseBoundaryFromContainer = shim;
+export const hideSuspenseBoundary = shim;
+export const unhideSuspenseBoundary = shim;
export const shouldDeleteUnhydratedTailInstances = shim;
export const diffHydratedPropsForDevWarnings = shim;
export const diffHydratedTextForDevWarnings = shim;
diff --git a/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js b/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
index f890a78a80e71..983b20ab33dc7 100644
--- a/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
+++ b/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
@@ -220,6 +220,8 @@ export const commitHydratedSuspenseInstance =
export const clearSuspenseBoundary = $$$config.clearSuspenseBoundary;
export const clearSuspenseBoundaryFromContainer =
$$$config.clearSuspenseBoundaryFromContainer;
+export const hideSuspenseBoundary = $$$config.hideSuspenseBoundary;
+export const unhideSuspenseBoundary = $$$config.unhideSuspenseBoundary;
export const shouldDeleteUnhydratedTailInstances =
$$$config.shouldDeleteUnhydratedTailInstances;
export const diffHydratedPropsForDevWarnings =
| diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 2d29781dfee97..2e6f4f2d4d43d 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -1127,6 +1127,61 @@ export function clearSuspenseBoundaryFromContainer(
retryIfBlockedOn(container);
+function hideOrUnhideSuspenseBoundary(
+ isHidden: boolean,
+) {
+ let node: Node = suspenseInstance;
+ // Unhide all nodes within this suspense boundary.
+ let depth = 0;
+ do {
+ const nextNode = node.nextSibling;
+ if (node.nodeType === ELEMENT_NODE) {
+ instance._stashedDisplay = instance.style.display;
+ instance.style.display = 'none';
+ instance.style.display = instance._stashedDisplay || '';
+ instance.removeAttribute('style');
+ } else if (node.nodeType === TEXT_NODE) {
+ textNode._stashedText = textNode.nodeValue;
+ textNode.nodeValue = '';
+ textNode.nodeValue = textNode._stashedText || '';
+ if (nextNode && nextNode.nodeType === COMMENT_NODE) {
+ const data = ((nextNode: any).data: string);
+ if (data === SUSPENSE_END_DATA) {
+ return;
+ } else {
+ } else if (
+ data === SUSPENSE_START_DATA ||
+ data === SUSPENSE_PENDING_START_DATA ||
+ data === SUSPENSE_FALLBACK_START_DATA
+ ) {
+ depth++;
+ // TODO: Should we hide preamble contribution in this case?
+ // $FlowFixMe[incompatible-type] we bail out when we get a null
+ node = nextNode;
+ } while (node);
+export function hideSuspenseBoundary(suspenseInstance: SuspenseInstance): void {
+ hideOrUnhideSuspenseBoundary(suspenseInstance, true);
export function hideInstance(instance: Instance): void {
// TODO: Does this work for all element types? What about MathML? Should we
// pass host context to this method?
@@ -1144,6 +1199,12 @@ export function hideTextInstance(textInstance: TextInstance): void {
textInstance.nodeValue = '';
+export function unhideSuspenseBoundary(
+): void {
+ hideOrUnhideSuspenseBoundary(suspenseInstance, false);
export function unhideInstance(instance: Instance, props: Props): void {
instance = ((instance: any): HTMLElement);
const styleProp = props[STYLE];
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 86a0ceb42e84a..b651c85a8d8f8 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -3945,4 +3945,94 @@ describe('ReactDOMServerPartialHydration', () => {
"onRecoverableError: Hydration failed because the server rendered text didn't match the client.",
]);
});
+ it('hides a dehydrated suspense boundary if the parent resuspends', async () => {
+ let suspend = false;
+ let resolve;
+ const promise = new Promise(resolvePromise => (resolve = resolvePromise));
+ const ref = React.createRef();
+ function Child({text}) {
+ return text;
+ function Sibling({resuspend}) {
+ if (suspend && resuspend) {
+ return null;
+ function Component({text}) {
+ <Child text={text} />
+ <span ref={ref}>World</span>
+ </Suspense>
+ function App({text, resuspend}) {
+ const memoized = React.useMemo(() => <Component text={text} />, [text]);
+ <div>
+ <Suspense fallback="Loading...">
+ {memoized}
+ <Sibling resuspend={resuspend} />
+ </Suspense>
+ </div>
+ suspend = false;
+ const container = document.createElement('div');
+ container.innerHTML = finalHTML;
+ // On the client we don't have all data yet but we want to start
+ // hydrating anyway.
+ suspend = true;
+ const root = ReactDOMClient.hydrateRoot(container, <App text="Hello" />, {
+ onRecoverableError(error) {
+ Scheduler.log('onRecoverableError: ' + normalizeError(error.message));
+ if (error.cause) {
+ Scheduler.log('Cause: ' + normalizeError(error.cause.message));
+ },
+ await waitForAll([]);
+ expect(ref.current).toBe(null); // Still dehydrated
+ const span = container.getElementsByTagName('span')[0];
+ const textNode = span.previousSibling;
+ // Render an update, that resuspends the parent boundary.
+ // Flushing now now hide the text content.
+ await act(() => {
+ root.render(<App text="Hello" resuspend={true} />);
+ expect(ref.current).toBe(null);
+ expect(span.style.display).toBe('none');
+ expect(textNode.nodeValue).toBe('');
+ // Unsuspending shows the content.
+ await act(async () => {
+ suspend = false;
+ resolve();
+ await promise;
+ expect(span.style.display).toBe('');
+ expect(ref.current).toBe(span);
+ });
});
diff --git a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js
index 2ca49f677de1f..4548e30ec65ac 100644
--- a/packages/react-reconciler/src/ReactFiberCommitHostEffects.js
+++ b/packages/react-reconciler/src/ReactFiberCommitHostEffects.js
@@ -41,8 +41,10 @@ import {
insertBefore,
insertInContainerBefore,
replaceContainerChildren,
+ hideSuspenseBoundary,
hideInstance,
hideTextInstance,
+ unhideSuspenseBoundary,
unhideInstance,
unhideTextInstance,
commitHydratedContainer,
@@ -152,6 +154,27 @@ export function commitHostResetTextContent(finishedWork: Fiber) {
}
+export function commitShowHideSuspenseBoundary(node: Fiber, isHidden: boolean) {
+ try {
+ const instance = node.stateNode;
+ if (isHidden) {
+ runWithFiberInDEV(node, hideSuspenseBoundary, instance);
+ hideSuspenseBoundary(instance);
+ } else {
+ runWithFiberInDEV(node, unhideSuspenseBoundary, node.stateNode);
+ unhideSuspenseBoundary(node.stateNode);
+ } catch (error) {
+ captureCommitPhaseError(node, node.return, error);
+ }
export function commitShowHideHostInstance(node: Fiber, isHidden: boolean) {
try {
const instance = node.stateNode;
diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js
index 92e6883c8c652..8065432370add 100644
--- a/packages/react-reconciler/src/ReactFiberCommitWork.js
+++ b/packages/react-reconciler/src/ReactFiberCommitWork.js
@@ -227,6 +227,7 @@ import {
commitHostUpdate,
commitHostTextUpdate,
commitHostResetTextContent,
+ commitShowHideSuspenseBoundary,
commitShowHideHostInstance,
commitShowHideHostTextInstance,
commitHostPlacement,
@@ -1158,6 +1159,10 @@ function hideOrUnhideAllChildren(finishedWork: Fiber, isHidden: boolean) {
if (hostSubtreeRoot === null) {
commitShowHideHostTextInstance(node, isHidden);
}
+ } else if (node.tag === DehydratedFragment) {
+ commitShowHideSuspenseBoundary(node, isHidden);
} else if (
(node.tag === OffscreenComponent ||
node.tag === LegacyHiddenComponent) &&
diff --git a/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js b/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
index 0bb85246dfe24..fb190d410bba0 100644
--- a/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
+++ b/packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
@@ -44,6 +44,8 @@ export const commitHydratedContainer = shim;
export const commitHydratedSuspenseInstance = shim;
export const clearSuspenseBoundary = shim;
export const clearSuspenseBoundaryFromContainer = shim;
+export const hideSuspenseBoundary = shim;
+export const unhideSuspenseBoundary = shim;
export const shouldDeleteUnhydratedTailInstances = shim;
export const diffHydratedPropsForDevWarnings = shim;
export const diffHydratedTextForDevWarnings = shim;
diff --git a/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js b/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
index f890a78a80e71..983b20ab33dc7 100644
--- a/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
+++ b/packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
@@ -220,6 +220,8 @@ export const commitHydratedSuspenseInstance =
export const clearSuspenseBoundary = $$$config.clearSuspenseBoundary;
export const clearSuspenseBoundaryFromContainer =
$$$config.clearSuspenseBoundaryFromContainer;
+export const hideSuspenseBoundary = $$$config.hideSuspenseBoundary;
+export const unhideSuspenseBoundary = $$$config.unhideSuspenseBoundary;
export const shouldDeleteUnhydratedTailInstances =
$$$config.shouldDeleteUnhydratedTailInstances;
export const diffHydratedPropsForDevWarnings = | [
"+ const instance = ((node: any): HTMLElement & {_stashedDisplay?: string});",
"+ if (instance.getAttribute('style') === '') {",
"+ const textNode = ((node: any): Text & {_stashedText?: string});",
"+ if (depth === 0) {",
"+ depth--;",
"+ if (suspend) {",
"+ <Suspense>",
"+ const finalHTML = ReactDOMServer.renderToString(<App text=\"Hello\" />);",
"+ if (hostSubtreeRoot === null) {"
] | [
18,
24,
29,
40,
43,
95,
112,
132,
238
] | {
"additions": 183,
"author": "sebmarkbage",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32900",
"issue_id": 32900,
"merged_at": "2025-04-22T23:29:12Z",
"omission_probability": 0.1,
"pr_number": 32900,
"repo": "facebook/react",
"title": "Hide/unhide the content of dehydrated suspense boundaries if they resuspend",
"total_changes": 183
} |
210 | diff --git a/.github/workflows/compiler_prereleases.yml b/.github/workflows/compiler_prereleases.yml
index 2bb2c6ef16863..fbdeab220c753 100644
--- a/.github/workflows/compiler_prereleases.yml
+++ b/.github/workflows/compiler_prereleases.yml
@@ -16,6 +16,9 @@ on:
version_name:
required: true
type: string
+ tag_version:
+ required: false
+ type: number
secrets:
NPM_TOKEN:
required: true
@@ -55,4 +58,4 @@ jobs:
- name: Publish packages to npm
run: |
cp ./scripts/release/ci-npmrc ~/.npmrc
- scripts/release/publish.js --frfr --ci --versionName=${{ inputs.version_name }} --tag ${{ inputs.dist_tag }}
+ scripts/release/publish.js --frfr --ci --versionName=${{ inputs.version_name }} --tag=${{ inputs.dist_tag }} ${{ inputs.tag_version && format('--tagVersion={0}', inputs.tag_version) || '' }}
diff --git a/.github/workflows/compiler_prereleases_manual.yml b/.github/workflows/compiler_prereleases_manual.yml
index 4960489590a4f..a840065548744 100644
--- a/.github/workflows/compiler_prereleases_manual.yml
+++ b/.github/workflows/compiler_prereleases_manual.yml
@@ -14,6 +14,9 @@ on:
version_name:
required: true
type: string
+ tag_version:
+ required: false
+ type: number
permissions: {}
@@ -29,5 +32,6 @@ jobs:
release_channel: ${{ inputs.release_channel }}
dist_tag: ${{ inputs.dist_tag }}
version_name: ${{ inputs.version_name }}
+ tag_version: ${{ inputs.tag_version }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/ReactVersions.js b/ReactVersions.js
index a22eaf973630c..79e23e1d4b109 100644
--- a/ReactVersions.js
+++ b/ReactVersions.js
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
const rcNumber = 0;
const stablePackages = {
- 'eslint-plugin-react-hooks': '6.0.0',
+ 'eslint-plugin-react-hooks': '6.1.0',
'jest-react': '0.17.0',
react: ReactVersion,
'react-art': ReactVersion,
diff --git a/compiler/scripts/release/publish.js b/compiler/scripts/release/publish.js
index 40f70ec31394f..713e23dceffcb 100755
--- a/compiler/scripts/release/publish.js
+++ b/compiler/scripts/release/publish.js
@@ -65,6 +65,12 @@ async function main() {
choices: ['experimental', 'beta', 'rc'],
default: 'experimental',
})
+ .option('tag-version', {
+ description:
+ 'Optional tag version to append to tag name, eg `1` becomes 0.0.0-rc.1',
+ type: 'number',
+ default: null,
+ })
.option('version-name', {
description: 'Version name',
type: 'string',
@@ -133,7 +139,10 @@ async function main() {
files: {exclude: ['.DS_Store']},
});
const truncatedHash = hash.slice(0, 7);
- const newVersion = `${argv.versionName}-${argv.tag}-${truncatedHash}-${dateString}`;
+ const newVersion =
+ argv.tagVersion == null || argv.tagVersion === ''
+ ? `${argv.versionName}-${argv.tag}-${truncatedHash}-${dateString}`
+ : `${argv.versionName}-${argv.tag}.${argv.tagVersion}-${truncatedHash}-${dateString}`;
for (const pkgName of pkgNames) {
const pkgDir = path.resolve(__dirname, `../../packages/${pkgName}`);
| diff --git a/.github/workflows/compiler_prereleases.yml b/.github/workflows/compiler_prereleases.yml
index 2bb2c6ef16863..fbdeab220c753 100644
--- a/.github/workflows/compiler_prereleases.yml
+++ b/.github/workflows/compiler_prereleases.yml
@@ -16,6 +16,9 @@ on:
NPM_TOKEN:
@@ -55,4 +58,4 @@ jobs:
- name: Publish packages to npm
run: |
cp ./scripts/release/ci-npmrc ~/.npmrc
- scripts/release/publish.js --frfr --ci --versionName=${{ inputs.version_name }} --tag ${{ inputs.dist_tag }}
+ scripts/release/publish.js --frfr --ci --versionName=${{ inputs.version_name }} --tag=${{ inputs.dist_tag }} ${{ inputs.tag_version && format('--tagVersion={0}', inputs.tag_version) || '' }}
diff --git a/.github/workflows/compiler_prereleases_manual.yml b/.github/workflows/compiler_prereleases_manual.yml
index 4960489590a4f..a840065548744 100644
--- a/.github/workflows/compiler_prereleases_manual.yml
+++ b/.github/workflows/compiler_prereleases_manual.yml
@@ -14,6 +14,9 @@ on:
permissions: {}
@@ -29,5 +32,6 @@ jobs:
release_channel: ${{ inputs.release_channel }}
dist_tag: ${{ inputs.dist_tag }}
version_name: ${{ inputs.version_name }}
+ tag_version: ${{ inputs.tag_version }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/ReactVersions.js b/ReactVersions.js
index a22eaf973630c..79e23e1d4b109 100644
--- a/ReactVersions.js
+++ b/ReactVersions.js
@@ -33,7 +33,7 @@ const canaryChannelLabel = 'canary';
const rcNumber = 0;
const stablePackages = {
- 'eslint-plugin-react-hooks': '6.0.0',
+ 'eslint-plugin-react-hooks': '6.1.0',
'jest-react': '0.17.0',
react: ReactVersion,
'react-art': ReactVersion,
diff --git a/compiler/scripts/release/publish.js b/compiler/scripts/release/publish.js
index 40f70ec31394f..713e23dceffcb 100755
--- a/compiler/scripts/release/publish.js
+++ b/compiler/scripts/release/publish.js
@@ -65,6 +65,12 @@ async function main() {
choices: ['experimental', 'beta', 'rc'],
default: 'experimental',
})
+ .option('tag-version', {
+ description:
+ 'Optional tag version to append to tag name, eg `1` becomes 0.0.0-rc.1',
+ type: 'number',
+ default: null,
+ })
.option('version-name', {
description: 'Version name',
type: 'string',
@@ -133,7 +139,10 @@ async function main() {
files: {exclude: ['.DS_Store']},
});
const truncatedHash = hash.slice(0, 7);
- const newVersion = `${argv.versionName}-${argv.tag}-${truncatedHash}-${dateString}`;
+ const newVersion =
+ ? `${argv.versionName}-${argv.tag}-${truncatedHash}-${dateString}`
+ : `${argv.versionName}-${argv.tag}.${argv.tagVersion}-${truncatedHash}-${dateString}`;
for (const pkgName of pkgNames) {
const pkgDir = path.resolve(__dirname, `../../packages/${pkgName}`); | [
"+ argv.tagVersion == null || argv.tagVersion === ''"
] | [
77
] | {
"additions": 19,
"author": "poteto",
"deletions": 3,
"html_url": "https://github.com/facebook/react/pull/32979",
"issue_id": 32979,
"merged_at": "2025-04-21T18:43:20Z",
"omission_probability": 0.1,
"pr_number": 32979,
"repo": "facebook/react",
"title": "[compiler] Fix version name in publish script",
"total_changes": 22
} |
211 | diff --git a/.github/workflows/compiler_prereleases_weekly.yml b/.github/workflows/compiler_prereleases_weekly.yml
deleted file mode 100644
index 72af00d52117c..0000000000000
--- a/.github/workflows/compiler_prereleases_weekly.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: (Compiler) Publish Prereleases Weekly
-
-on:
- schedule:
- # At 10 minutes past 9:00 on Mon
- - cron: 10 9 * * 1
-
-permissions: {}
-
-env:
- TZ: /usr/share/zoneinfo/America/Los_Angeles
-
-jobs:
- publish_prerelease_beta:
- name: Publish to beta channel
- uses: facebook/react/.github/workflows/compiler_prereleases.yml@main
- with:
- commit_sha: ${{ github.sha }}
- release_channel: beta
- dist_tag: beta
- version_name: '19.0.0'
- secrets:
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
| diff --git a/.github/workflows/compiler_prereleases_weekly.yml b/.github/workflows/compiler_prereleases_weekly.yml
deleted file mode 100644
index 72af00d52117c..0000000000000
--- a/.github/workflows/compiler_prereleases_weekly.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: (Compiler) Publish Prereleases Weekly
-on:
- schedule:
- # At 10 minutes past 9:00 on Mon
- - cron: 10 9 * * 1
-permissions: {}
-env:
- TZ: /usr/share/zoneinfo/America/Los_Angeles
-jobs:
- publish_prerelease_beta:
- name: Publish to beta channel
- uses: facebook/react/.github/workflows/compiler_prereleases.yml@main
- commit_sha: ${{ github.sha }}
- release_channel: beta
- dist_tag: beta
- version_name: '19.0.0'
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | [
"- with:",
"- secrets:"
] | [
22,
27
] | {
"additions": 0,
"author": "poteto",
"deletions": 23,
"html_url": "https://github.com/facebook/react/pull/32977",
"issue_id": 32977,
"merged_at": "2025-04-21T17:47:50Z",
"omission_probability": 0.1,
"pr_number": 32977,
"repo": "facebook/react",
"title": "[ci] Remove compiler weekly release",
"total_changes": 23
} |
212 | diff --git a/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js b/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js
index 67725e27d8a7f..97bf1fe35bcbe 100644
--- a/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js
+++ b/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js
@@ -1,6 +1,6 @@
/* global chrome */
-import {normalizeUrl} from 'react-devtools-shared/src/utils';
+import {normalizeUrlIfValid} from 'react-devtools-shared/src/utils';
import {__DEBUG__} from 'react-devtools-shared/src/constants';
let debugIDCounter = 0;
@@ -117,7 +117,7 @@ async function fetchFileWithCaching(url: string): Promise<string> {
chrome.devtools.inspectedWindow.getResources(r => resolve(r)),
);
- const normalizedReferenceURL = normalizeUrl(url);
+ const normalizedReferenceURL = normalizeUrlIfValid(url);
const resource = resources.find(r => r.url === normalizedReferenceURL);
if (resource != null) {
diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js
index 7d94449fcc748..63d25819539f1 100644
--- a/packages/react-devtools-extensions/src/main/index.js
+++ b/packages/react-devtools-extensions/src/main/index.js
@@ -16,6 +16,7 @@ import {
LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY,
} from 'react-devtools-shared/src/constants';
import {logEvent} from 'react-devtools-shared/src/Logger';
+import {normalizeUrlIfValid} from 'react-devtools-shared/src/utils';
import {
setBrowserSelectionFromReact,
@@ -128,7 +129,11 @@ function createBridgeAndStore() {
: source;
// We use 1-based line and column, Chrome expects them 0-based.
- chrome.devtools.panels.openResource(sourceURL, line - 1, column - 1);
+ chrome.devtools.panels.openResource(
+ normalizeUrlIfValid(sourceURL),
+ line - 1,
+ column - 1,
+ );
};
// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
diff --git a/packages/react-devtools-shared/src/symbolicateSource.js b/packages/react-devtools-shared/src/symbolicateSource.js
index 9430e88b3fc15..6504ab2594091 100644
--- a/packages/react-devtools-shared/src/symbolicateSource.js
+++ b/packages/react-devtools-shared/src/symbolicateSource.js
@@ -7,7 +7,6 @@
* @flow
*/
-import {normalizeUrl} from 'react-devtools-shared/src/utils';
import SourceMapConsumer from 'react-devtools-shared/src/hooks/SourceMapConsumer';
import type {Source} from 'react-devtools-shared/src/shared/types';
@@ -91,9 +90,8 @@ export async function symbolicateSource(
try {
// sourceMapURL = https://react.dev/script.js.map
void new URL(possiblyURL); // test if it is a valid URL
- const normalizedURL = normalizeUrl(possiblyURL);
- return {sourceURL: normalizedURL, line, column};
+ return {sourceURL: possiblyURL, line, column};
} catch (e) {
// This is not valid URL
if (
diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js
index 12c9fb739ce95..b0a8f5c53e0cd 100644
--- a/packages/react-devtools-shared/src/utils.js
+++ b/packages/react-devtools-shared/src/utils.js
@@ -996,9 +996,17 @@ export function backendToFrontendSerializedElementMapper(
};
}
-// Chrome normalizes urls like webpack-internals:// but new URL don't, so cannot use new URL here.
-export function normalizeUrl(url: string): string {
- return url.replace('/./', '/');
+/**
+ * Should be used when treating url as a Chrome Resource URL.
+ */
+export function normalizeUrlIfValid(url: string): string {
+ try {
+ // TODO: Chrome will use the basepath to create a Resource URL.
+ return new URL(url).toString();
+ } catch {
+ // Giving up if it's not a valid URL without basepath
+ return url;
+ }
}
export function getIsReloadAndProfileSupported(): boolean {
| diff --git a/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js b/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js
index 67725e27d8a7f..97bf1fe35bcbe 100644
--- a/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js
+++ b/packages/react-devtools-extensions/src/main/fetchFileWithCaching.js
@@ -1,6 +1,6 @@
/* global chrome */
import {__DEBUG__} from 'react-devtools-shared/src/constants';
let debugIDCounter = 0;
@@ -117,7 +117,7 @@ async function fetchFileWithCaching(url: string): Promise<string> {
chrome.devtools.inspectedWindow.getResources(r => resolve(r)),
);
- const normalizedReferenceURL = normalizeUrl(url);
+ const normalizedReferenceURL = normalizeUrlIfValid(url);
const resource = resources.find(r => r.url === normalizedReferenceURL);
if (resource != null) {
diff --git a/packages/react-devtools-extensions/src/main/index.js b/packages/react-devtools-extensions/src/main/index.js
index 7d94449fcc748..63d25819539f1 100644
--- a/packages/react-devtools-extensions/src/main/index.js
+++ b/packages/react-devtools-extensions/src/main/index.js
@@ -16,6 +16,7 @@ import {
LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY,
} from 'react-devtools-shared/src/constants';
import {logEvent} from 'react-devtools-shared/src/Logger';
import {
setBrowserSelectionFromReact,
@@ -128,7 +129,11 @@ function createBridgeAndStore() {
: source;
// We use 1-based line and column, Chrome expects them 0-based.
- chrome.devtools.panels.openResource(sourceURL, line - 1, column - 1);
+ chrome.devtools.panels.openResource(
+ normalizeUrlIfValid(sourceURL),
+ line - 1,
+ column - 1,
+ );
// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
diff --git a/packages/react-devtools-shared/src/symbolicateSource.js b/packages/react-devtools-shared/src/symbolicateSource.js
index 9430e88b3fc15..6504ab2594091 100644
--- a/packages/react-devtools-shared/src/symbolicateSource.js
+++ b/packages/react-devtools-shared/src/symbolicateSource.js
@@ -7,7 +7,6 @@
* @flow
*/
import SourceMapConsumer from 'react-devtools-shared/src/hooks/SourceMapConsumer';
import type {Source} from 'react-devtools-shared/src/shared/types';
@@ -91,9 +90,8 @@ export async function symbolicateSource(
try {
// sourceMapURL = https://react.dev/script.js.map
void new URL(possiblyURL); // test if it is a valid URL
- const normalizedURL = normalizeUrl(possiblyURL);
- return {sourceURL: normalizedURL, line, column};
+ return {sourceURL: possiblyURL, line, column};
} catch (e) {
// This is not valid URL
if (
diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js
index 12c9fb739ce95..b0a8f5c53e0cd 100644
--- a/packages/react-devtools-shared/src/utils.js
+++ b/packages/react-devtools-shared/src/utils.js
@@ -996,9 +996,17 @@ export function backendToFrontendSerializedElementMapper(
-// Chrome normalizes urls like webpack-internals:// but new URL don't, so cannot use new URL here.
-export function normalizeUrl(url: string): string {
- return url.replace('/./', '/');
+/**
+ * Should be used when treating url as a Chrome Resource URL.
+ */
+export function normalizeUrlIfValid(url: string): string {
+ // TODO: Chrome will use the basepath to create a Resource URL.
+ return new URL(url).toString();
+ } catch {
+ // Giving up if it's not a valid URL without basepath
+ return url;
export function getIsReloadAndProfileSupported(): boolean { | [
"+ try {",
"+ }"
] | [
84,
90
] | {
"additions": 20,
"author": "eps1lon",
"deletions": 9,
"html_url": "https://github.com/facebook/react/pull/32951",
"issue_id": 32951,
"merged_at": "2025-04-17T19:56:05Z",
"omission_probability": 0.1,
"pr_number": 32951,
"repo": "facebook/react",
"title": "[devtools] Fix \"View source\" for sources with URLs that aren't normalized",
"total_changes": 29
} |
213 | diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 864b8242eba5d..6938c3ee64c99 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -158,7 +158,7 @@ server.tool(
}
}
};
- const errors: Array<{message: string; loc: SourceLocation}> = [];
+ const errors: Array<{message: string; loc: SourceLocation | null}> = [];
const compilerOptions: Partial<PluginOptions> = {
panicThreshold: 'none',
logger: {
@@ -170,12 +170,10 @@ server.tool(
detail.loc == null || typeof detail.loc == 'symbol'
? event.fnLoc
: detail.loc;
- if (loc != null) {
- errors.push({
- message: detail.reason,
- loc,
- });
- }
+ errors.push({
+ message: detail.reason,
+ loc,
+ });
}
},
},
@@ -279,17 +277,16 @@ server.tool(
}
}
if (errors.length > 0) {
- const errMessages = errors.map(err => {
- if (typeof err.loc !== 'symbol') {
+ return {
+ content: errors.map(err => {
return {
type: 'text' as const,
- text: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
+ text:
+ err.loc === null || typeof err.loc === 'symbol'
+ ? `React Compiler bailed out:\n\n${err.message}`
+ : `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
};
- }
- return null;
- });
- return {
- content: errMessages.filter(msg => msg !== null),
+ }),
};
}
return {
| diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 864b8242eba5d..6938c3ee64c99 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -158,7 +158,7 @@ server.tool(
};
- const errors: Array<{message: string; loc: SourceLocation}> = [];
const compilerOptions: Partial<PluginOptions> = {
panicThreshold: 'none',
logger: {
@@ -170,12 +170,10 @@ server.tool(
detail.loc == null || typeof detail.loc == 'symbol'
? event.fnLoc
: detail.loc;
- if (loc != null) {
- message: detail.reason,
- loc,
- });
- }
+ errors.push({
+ message: detail.reason,
+ loc,
+ });
}
},
},
@@ -279,17 +277,16 @@ server.tool(
if (errors.length > 0) {
- if (typeof err.loc !== 'symbol') {
+ return {
+ content: errors.map(err => {
return {
type: 'text' as const,
- text: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
+ text:
+ err.loc === null || typeof err.loc === 'symbol'
};
- }
- return null;
- return {
- content: errMessages.filter(msg => msg !== null),
+ }),
};
return { | [
"+ const errors: Array<{message: string; loc: SourceLocation | null}> = [];",
"- errors.push({",
"- const errMessages = errors.map(err => {",
"+ ? `React Compiler bailed out:\\n\\n${err.message}`",
"+ : `React Compiler bailed out:\\n\\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,",
"- });"
] | [
9,
18,
34,
43,
44,
48
] | {
"additions": 12,
"author": "poteto",
"deletions": 15,
"html_url": "https://github.com/facebook/react/pull/32937",
"issue_id": 32937,
"merged_at": "2025-04-17T17:11:56Z",
"omission_probability": 0.1,
"pr_number": 32937,
"repo": "facebook/react",
"title": "[mcp] Also emit bailout messages with no loc",
"total_changes": 27
} |
214 | diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
index 37a8816d0b336..7ed42cbce132a 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
@@ -9,6 +9,7 @@ import {Effect, ValueKind, ValueReason} from './HIR';
import {
BUILTIN_SHAPES,
BuiltInArrayId,
+ BuiltInFireFunctionId,
BuiltInFireId,
BuiltInMapId,
BuiltInMixedReadonlyId,
@@ -674,7 +675,12 @@ const REACT_APIS: Array<[string, BuiltInType]> = [
{
positionalParams: [],
restParam: null,
- returnType: {kind: 'Primitive'},
+ returnType: {
+ kind: 'Function',
+ return: {kind: 'Poly'},
+ shapeId: BuiltInFireFunctionId,
+ isConstructor: false,
+ },
calleeEffect: Effect.Read,
returnValueKind: ValueKind.Frozen,
},
diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
index 5c84cbb9fc4dd..0dfa937f37f03 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
@@ -1722,6 +1722,12 @@ export function isDispatcherType(id: Identifier): boolean {
return id.type.kind === 'Function' && id.type.shapeId === 'BuiltInDispatch';
}
+export function isFireFunctionType(id: Identifier): boolean {
+ return (
+ id.type.kind === 'Function' && id.type.shapeId === 'BuiltInFireFunction'
+ );
+}
+
export function isStableType(id: Identifier): boolean {
return (
isSetStateType(id) ||
diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
index 75aa38a71a452..a599fc2d74760 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
@@ -223,6 +223,7 @@ export const BuiltInUseContextHookId = 'BuiltInUseContextHook';
export const BuiltInUseTransitionId = 'BuiltInUseTransition';
export const BuiltInStartTransitionId = 'BuiltInStartTransition';
export const BuiltInFireId = 'BuiltInFire';
+export const BuiltInFireFunctionId = 'BuiltInFireFunction';
// ShapeRegistry with default definitions for built-ins.
export const BUILTIN_SHAPES: ShapeRegistry = new Map();
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 03bd9fd3827dc..0d27ac7ca0f69 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -17,6 +17,7 @@ import {
ReactiveScopeDependencies,
isUseRefType,
isSetStateType,
+ isFireFunctionType,
} from '../HIR';
import {DEFAULT_EXPORT} from '../HIR/Environment';
import {
@@ -189,9 +190,10 @@ export function inferEffectDependencies(fn: HIRFunction): void {
*/
for (const dep of scopeInfo.deps) {
if (
- (isUseRefType(dep.identifier) ||
+ ((isUseRefType(dep.identifier) ||
isSetStateType(dep.identifier)) &&
- !reactiveIds.has(dep.identifier.id)
+ !reactiveIds.has(dep.identifier.id)) ||
+ isFireFunctionType(dep.identifier)
) {
// exclude non-reactive hook results, which will never be in a memo block
continue;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts b/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts
index 943b6b8eca2b2..b033af6750c37 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts
@@ -34,7 +34,11 @@ import {
} from '../HIR';
import {createTemporaryPlace, markInstructionIds} from '../HIR/HIRBuilder';
import {getOrInsertWith} from '../Utils/utils';
-import {BuiltInFireId, DefaultNonmutatingHook} from '../HIR/ObjectShape';
+import {
+ BuiltInFireFunctionId,
+ BuiltInFireId,
+ DefaultNonmutatingHook,
+} from '../HIR/ObjectShape';
import {eachInstructionOperand} from '../HIR/visitors';
import {printSourceLocationLine} from '../HIR/PrintHIR';
import {USE_FIRE_FUNCTION_NAME} from '../HIR/Environment';
@@ -633,6 +637,13 @@ class Context {
() => createTemporaryPlace(this.#env, GeneratedSource),
);
+ fireFunctionBinding.identifier.type = {
+ kind: 'Function',
+ shapeId: BuiltInFireFunctionId,
+ return: {kind: 'Poly'},
+ isConstructor: false,
+ };
+
this.#capturedCalleeIdentifierIds.set(callee.identifier.id, {
fireFunctionBinding,
capturedCalleeIdentifier: callee.identifier,
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md
index 20260bd5e694d..46e813bf9d6cb 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md
@@ -49,7 +49,7 @@ function Component(props) {
} else {
t2 = $[4];
}
- useEffect(t2, [t1, props]);
+ useEffect(t2, [props]);
return null;
}
| diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
index 37a8816d0b336..7ed42cbce132a 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
@@ -9,6 +9,7 @@ import {Effect, ValueKind, ValueReason} from './HIR';
BUILTIN_SHAPES,
BuiltInArrayId,
BuiltInFireId,
BuiltInMapId,
BuiltInMixedReadonlyId,
@@ -674,7 +675,12 @@ const REACT_APIS: Array<[string, BuiltInType]> = [
{
positionalParams: [],
restParam: null,
- returnType: {kind: 'Primitive'},
+ kind: 'Function',
+ shapeId: BuiltInFireFunctionId,
+ isConstructor: false,
+ },
calleeEffect: Effect.Read,
returnValueKind: ValueKind.Frozen,
},
diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
index 5c84cbb9fc4dd..0dfa937f37f03 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
@@ -1722,6 +1722,12 @@ export function isDispatcherType(id: Identifier): boolean {
return id.type.kind === 'Function' && id.type.shapeId === 'BuiltInDispatch';
+export function isFireFunctionType(id: Identifier): boolean {
+ return (
+ id.type.kind === 'Function' && id.type.shapeId === 'BuiltInFireFunction'
+ );
export function isStableType(id: Identifier): boolean {
return (
isSetStateType(id) ||
diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
index 75aa38a71a452..a599fc2d74760 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
@@ -223,6 +223,7 @@ export const BuiltInUseContextHookId = 'BuiltInUseContextHook';
export const BuiltInUseTransitionId = 'BuiltInUseTransition';
export const BuiltInStartTransitionId = 'BuiltInStartTransition';
export const BuiltInFireId = 'BuiltInFire';
+export const BuiltInFireFunctionId = 'BuiltInFireFunction';
// ShapeRegistry with default definitions for built-ins.
export const BUILTIN_SHAPES: ShapeRegistry = new Map();
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
index 03bd9fd3827dc..0d27ac7ca0f69 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts
@@ -17,6 +17,7 @@ import {
ReactiveScopeDependencies,
isUseRefType,
isSetStateType,
+ isFireFunctionType,
import {DEFAULT_EXPORT} from '../HIR/Environment';
@@ -189,9 +190,10 @@ export function inferEffectDependencies(fn: HIRFunction): void {
*/
for (const dep of scopeInfo.deps) {
if (
- (isUseRefType(dep.identifier) ||
+ ((isUseRefType(dep.identifier) ||
isSetStateType(dep.identifier)) &&
- !reactiveIds.has(dep.identifier.id)
+ !reactiveIds.has(dep.identifier.id)) ||
+ isFireFunctionType(dep.identifier)
) {
// exclude non-reactive hook results, which will never be in a memo block
continue;
diff --git a/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts b/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts
index 943b6b8eca2b2..b033af6750c37 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts
+++ b/compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts
@@ -34,7 +34,11 @@ import {
import {createTemporaryPlace, markInstructionIds} from '../HIR/HIRBuilder';
import {getOrInsertWith} from '../Utils/utils';
-import {BuiltInFireId, DefaultNonmutatingHook} from '../HIR/ObjectShape';
+import {
+ BuiltInFireId,
+ DefaultNonmutatingHook,
import {eachInstructionOperand} from '../HIR/visitors';
import {printSourceLocationLine} from '../HIR/PrintHIR';
import {USE_FIRE_FUNCTION_NAME} from '../HIR/Environment';
@@ -633,6 +637,13 @@ class Context {
() => createTemporaryPlace(this.#env, GeneratedSource),
);
+ fireFunctionBinding.identifier.type = {
+ kind: 'Function',
+ shapeId: BuiltInFireFunctionId,
+ return: {kind: 'Poly'},
+ isConstructor: false,
+ };
this.#capturedCalleeIdentifierIds.set(callee.identifier.id, {
fireFunctionBinding,
capturedCalleeIdentifier: callee.identifier,
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md
index 20260bd5e694d..46e813bf9d6cb 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/transform-fire/fire-and-autodeps.expect.md
@@ -49,7 +49,7 @@ function Component(props) {
} else {
t2 = $[4];
}
- useEffect(t2, [t1, props]);
+ useEffect(t2, [props]);
return null; | [
"+ returnType: {",
"+ return: {kind: 'Poly'},",
"+}",
"+} from '../HIR/ObjectShape';"
] | [
17,
19,
38,
93
] | {
"additions": 31,
"author": "jbrown215",
"deletions": 5,
"html_url": "https://github.com/facebook/react/pull/32532",
"issue_id": 32532,
"merged_at": "2025-04-17T17:03:19Z",
"omission_probability": 0.1,
"pr_number": 32532,
"repo": "facebook/react",
"title": "[compiler][autodeps/fire] Do not include fire functions in autodep arrays",
"total_changes": 36
} |
215 | diff --git a/packages/react-devtools-shared/src/__tests__/utils-test.js b/packages/react-devtools-shared/src/__tests__/utils-test.js
index 9e781e072ba75..f35cacc73308f 100644
--- a/packages/react-devtools-shared/src/__tests__/utils-test.js
+++ b/packages/react-devtools-shared/src/__tests__/utils-test.js
@@ -26,6 +26,7 @@ import {
REACT_STRICT_MODE_TYPE as StrictMode,
} from 'shared/ReactSymbols';
import {createElement} from 'react';
+import {symbolicateSource} from '../symbolicateSource';
describe('utils', () => {
describe('getDisplayName', () => {
@@ -385,6 +386,35 @@ describe('utils', () => {
});
});
+ describe('symbolicateSource', () => {
+ const source = `"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = f;
+function f() { }
+//# sourceMappingURL=`;
+ const result = {
+ column: 16,
+ line: 1,
+ sourceURL: 'http://test/a.mts',
+ };
+ const fs = {
+ 'http://test/a.mts': `export function f() {}`,
+ 'http://test/a.mjs.map': `{"version":3,"file":"a.mjs","sourceRoot":"","sources":["a.mts"],"names":[],"mappings":";;AAAA,cAAsB;AAAtB,SAAgB,CAAC,KAAI,CAAC"}`,
+ 'http://test/a.mjs': `${source}a.mjs.map`,
+ 'http://test/b.mjs': `${source}./a.mjs.map`,
+ 'http://test/c.mjs': `${source}http://test/a.mjs.map`,
+ 'http://test/d.mjs': `${source}/a.mjs.map`,
+ };
+ const fetchFileWithCaching = async (url: string) => fs[url] || null;
+ it('should parse source map urls', async () => {
+ const run = url => symbolicateSource(fetchFileWithCaching, url, 4, 10);
+ await expect(run('http://test/a.mjs')).resolves.toStrictEqual(result);
+ await expect(run('http://test/b.mjs')).resolves.toStrictEqual(result);
+ await expect(run('http://test/c.mjs')).resolves.toStrictEqual(result);
+ await expect(run('http://test/d.mjs')).resolves.toStrictEqual(result);
+ });
+ });
+
describe('formatConsoleArguments', () => {
it('works with empty arguments list', () => {
expect(formatConsoleArguments(...[])).toEqual([]);
diff --git a/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js b/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
index 779cbb3b2f0d1..8e6503685bdb5 100644
--- a/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
+++ b/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
@@ -24,8 +24,8 @@ type SearchPosition = {
type ResultPosition = {
column: number,
line: number,
- sourceContent: string,
- sourceURL: string,
+ sourceContent: string | null,
+ sourceURL: string | null,
};
export type SourceMapConsumerType = {
@@ -118,18 +118,11 @@ function BasicSourceMapConsumer(sourceMapJSON: BasicSourceMap) {
const line = nearestEntry[2] + 1;
const column = nearestEntry[3];
- if (sourceContent === null || sourceURL === null) {
- // TODO maybe fall back to the runtime source instead of throwing?
- throw Error(
- `Could not find original source for line:${lineNumber} and column:${columnNumber}`,
- );
- }
-
return {
column,
line,
- sourceContent: ((sourceContent: any): string),
- sourceURL: ((sourceURL: any): string),
+ sourceContent: ((sourceContent: any): string | null),
+ sourceURL: ((sourceURL: any): string | null),
};
}
diff --git a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
index 40bfed48ba53f..15423c12416cc 100644
--- a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
+++ b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
@@ -276,6 +276,11 @@ function parseSourceAST(
columnNumber,
lineNumber,
});
+ if (sourceContent === null || sourceURL === null) {
+ throw Error(
+ `Could not find original source for line:${lineNumber} and column:${columnNumber}`,
+ );
+ }
originalSourceColumnNumber = column;
originalSourceLineNumber = line;
diff --git a/packages/react-devtools-shared/src/symbolicateSource.js b/packages/react-devtools-shared/src/symbolicateSource.js
index d28ed42e59db0..9430e88b3fc15 100644
--- a/packages/react-devtools-shared/src/symbolicateSource.js
+++ b/packages/react-devtools-shared/src/symbolicateSource.js
@@ -39,7 +39,7 @@ export async function symbolicateSourceWithCache(
}
const SOURCE_MAP_ANNOTATION_PREFIX = 'sourceMappingURL=';
-async function symbolicateSource(
+export async function symbolicateSource(
fetchFileWithCaching: FetchFileWithCaching,
sourceURL: string,
lineNumber: number, // 1-based
@@ -63,11 +63,12 @@ async function symbolicateSource(
const sourceMapAnnotationStartIndex = resourceLine.indexOf(
SOURCE_MAP_ANNOTATION_PREFIX,
);
- const sourceMapURL = resourceLine.slice(
+ const sourceMapAt = resourceLine.slice(
sourceMapAnnotationStartIndex + SOURCE_MAP_ANNOTATION_PREFIX.length,
resourceLine.length,
);
+ const sourceMapURL = new URL(sourceMapAt, sourceURL).toString();
const sourceMap = await fetchFileWithCaching(sourceMapURL).catch(
() => null,
);
@@ -84,29 +85,33 @@ async function symbolicateSource(
columnNumber, // 1-based
});
+ if (possiblyURL === null) {
+ return null;
+ }
try {
- void new URL(possiblyURL); // This is a valid URL
+ // sourceMapURL = https://react.dev/script.js.map
+ void new URL(possiblyURL); // test if it is a valid URL
const normalizedURL = normalizeUrl(possiblyURL);
return {sourceURL: normalizedURL, line, column};
} catch (e) {
// This is not valid URL
- if (possiblyURL.startsWith('/')) {
+ if (
+ // sourceMapURL = /file
+ possiblyURL.startsWith('/') ||
+ // sourceMapURL = C:\\...
+ possiblyURL.slice(1).startsWith(':\\\\')
+ ) {
// This is an absolute path
return {sourceURL: possiblyURL, line, column};
}
// This is a relative path
- const [sourceMapAbsolutePathWithoutQueryParameters] =
- sourceMapURL.split(/[?#&]/);
-
- const absoluteSourcePath =
- sourceMapAbsolutePathWithoutQueryParameters +
- (sourceMapAbsolutePathWithoutQueryParameters.endsWith('/')
- ? ''
- : '/') +
- possiblyURL;
-
+ // possiblyURL = x.js.map, sourceMapURL = https://react.dev/script.js.map
+ const absoluteSourcePath = new URL(
+ possiblyURL,
+ sourceMapURL,
+ ).toString();
return {sourceURL: absoluteSourcePath, line, column};
}
} catch (e) {
diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js
index 5b0903883c301..ffbc9e390d5a4 100644
--- a/packages/react-devtools-shared/src/utils.js
+++ b/packages/react-devtools-shared/src/utils.js
@@ -1017,7 +1017,7 @@ export function backendToFrontendSerializedElementMapper(
};
}
-// This is a hacky one to just support this exact case.
+// Chrome normalizes urls like webpack-internals:// but new URL don't, so cannot use new URL here.
export function normalizeUrl(url: string): string {
return url.replace('/./', '/');
}
| diff --git a/packages/react-devtools-shared/src/__tests__/utils-test.js b/packages/react-devtools-shared/src/__tests__/utils-test.js
index 9e781e072ba75..f35cacc73308f 100644
--- a/packages/react-devtools-shared/src/__tests__/utils-test.js
+++ b/packages/react-devtools-shared/src/__tests__/utils-test.js
@@ -26,6 +26,7 @@ import {
REACT_STRICT_MODE_TYPE as StrictMode,
} from 'shared/ReactSymbols';
import {createElement} from 'react';
+import {symbolicateSource} from '../symbolicateSource';
describe('utils', () => {
describe('getDisplayName', () => {
@@ -385,6 +386,35 @@ describe('utils', () => {
});
});
+ describe('symbolicateSource', () => {
+ const source = `"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.f = f;
+function f() { }
+//# sourceMappingURL=`;
+ const result = {
+ column: 16,
+ line: 1,
+ sourceURL: 'http://test/a.mts',
+ const fs = {
+ 'http://test/a.mts': `export function f() {}`,
+ 'http://test/a.mjs.map': `{"version":3,"file":"a.mjs","sourceRoot":"","sources":["a.mts"],"names":[],"mappings":";;AAAA,cAAsB;AAAtB,SAAgB,CAAC,KAAI,CAAC"}`,
+ 'http://test/a.mjs': `${source}a.mjs.map`,
+ 'http://test/b.mjs': `${source}./a.mjs.map`,
+ 'http://test/c.mjs': `${source}http://test/a.mjs.map`,
+ 'http://test/d.mjs': `${source}/a.mjs.map`,
+ const fetchFileWithCaching = async (url: string) => fs[url] || null;
+ it('should parse source map urls', async () => {
+ const run = url => symbolicateSource(fetchFileWithCaching, url, 4, 10);
+ await expect(run('http://test/a.mjs')).resolves.toStrictEqual(result);
+ await expect(run('http://test/b.mjs')).resolves.toStrictEqual(result);
+ await expect(run('http://test/c.mjs')).resolves.toStrictEqual(result);
+ await expect(run('http://test/d.mjs')).resolves.toStrictEqual(result);
+
describe('formatConsoleArguments', () => {
it('works with empty arguments list', () => {
expect(formatConsoleArguments(...[])).toEqual([]);
diff --git a/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js b/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
index 779cbb3b2f0d1..8e6503685bdb5 100644
--- a/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
+++ b/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
@@ -24,8 +24,8 @@ type SearchPosition = {
type ResultPosition = {
column: number,
line: number,
- sourceContent: string,
- sourceURL: string,
+ sourceContent: string | null,
+ sourceURL: string | null,
};
export type SourceMapConsumerType = {
@@ -118,18 +118,11 @@ function BasicSourceMapConsumer(sourceMapJSON: BasicSourceMap) {
const line = nearestEntry[2] + 1;
const column = nearestEntry[3];
- // TODO maybe fall back to the runtime source instead of throwing?
- throw Error(
- `Could not find original source for line:${lineNumber} and column:${columnNumber}`,
- );
- }
return {
column,
line,
- sourceContent: ((sourceContent: any): string),
- sourceURL: ((sourceURL: any): string),
+ sourceContent: ((sourceContent: any): string | null),
+ sourceURL: ((sourceURL: any): string | null),
};
}
diff --git a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
index 40bfed48ba53f..15423c12416cc 100644
--- a/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
+++ b/packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js
@@ -276,6 +276,11 @@ function parseSourceAST(
columnNumber,
lineNumber,
+ if (sourceContent === null || sourceURL === null) {
+ throw Error(
+ `Could not find original source for line:${lineNumber} and column:${columnNumber}`,
+ );
+ }
originalSourceColumnNumber = column;
originalSourceLineNumber = line;
diff --git a/packages/react-devtools-shared/src/symbolicateSource.js b/packages/react-devtools-shared/src/symbolicateSource.js
index d28ed42e59db0..9430e88b3fc15 100644
--- a/packages/react-devtools-shared/src/symbolicateSource.js
+++ b/packages/react-devtools-shared/src/symbolicateSource.js
@@ -39,7 +39,7 @@ export async function symbolicateSourceWithCache(
const SOURCE_MAP_ANNOTATION_PREFIX = 'sourceMappingURL=';
-async function symbolicateSource(
+export async function symbolicateSource(
fetchFileWithCaching: FetchFileWithCaching,
sourceURL: string,
lineNumber: number, // 1-based
@@ -63,11 +63,12 @@ async function symbolicateSource(
const sourceMapAnnotationStartIndex = resourceLine.indexOf(
SOURCE_MAP_ANNOTATION_PREFIX,
+ const sourceMapAt = resourceLine.slice(
sourceMapAnnotationStartIndex + SOURCE_MAP_ANNOTATION_PREFIX.length,
resourceLine.length,
+ const sourceMapURL = new URL(sourceMapAt, sourceURL).toString();
const sourceMap = await fetchFileWithCaching(sourceMapURL).catch(
() => null,
@@ -84,29 +85,33 @@ async function symbolicateSource(
columnNumber, // 1-based
+ if (possiblyURL === null) {
+ return null;
+ }
try {
- void new URL(possiblyURL); // This is a valid URL
+ // sourceMapURL = https://react.dev/script.js.map
const normalizedURL = normalizeUrl(possiblyURL);
return {sourceURL: normalizedURL, line, column};
} catch (e) {
// This is not valid URL
- if (possiblyURL.startsWith('/')) {
+ if (
+ possiblyURL.startsWith('/') ||
+ // sourceMapURL = C:\\...
+ ) {
// This is an absolute path
return {sourceURL: possiblyURL, line, column};
}
// This is a relative path
- const [sourceMapAbsolutePathWithoutQueryParameters] =
- sourceMapURL.split(/[?#&]/);
- const absoluteSourcePath =
- sourceMapAbsolutePathWithoutQueryParameters +
- (sourceMapAbsolutePathWithoutQueryParameters.endsWith('/')
- ? ''
- : '/') +
- possiblyURL;
+ // possiblyURL = x.js.map, sourceMapURL = https://react.dev/script.js.map
+ const absoluteSourcePath = new URL(
+ possiblyURL,
+ sourceMapURL,
+ ).toString();
return {sourceURL: absoluteSourcePath, line, column};
}
} catch (e) {
diff --git a/packages/react-devtools-shared/src/utils.js b/packages/react-devtools-shared/src/utils.js
index 5b0903883c301..ffbc9e390d5a4 100644
--- a/packages/react-devtools-shared/src/utils.js
+++ b/packages/react-devtools-shared/src/utils.js
@@ -1017,7 +1017,7 @@ export function backendToFrontendSerializedElementMapper(
};
-// This is a hacky one to just support this exact case.
+// Chrome normalizes urls like webpack-internals:// but new URL don't, so cannot use new URL here.
export function normalizeUrl(url: string): string {
return url.replace('/./', '/'); | [
"+ });",
"+ });",
"- if (sourceContent === null || sourceURL === null) {",
"- const sourceMapURL = resourceLine.slice(",
"+ void new URL(possiblyURL); // test if it is a valid URL",
"+ // sourceMapURL = /file",
"+ possiblyURL.slice(1).startsWith(':\\\\\\\\')"
] | [
42,
43,
67,
117,
137,
145,
148
] | {
"additions": 59,
"author": "Jack-Works",
"deletions": 26,
"html_url": "https://github.com/facebook/react/pull/29199",
"issue_id": 29199,
"merged_at": "2024-07-04T14:34:49Z",
"omission_probability": 0.1,
"pr_number": 29199,
"repo": "facebook/react",
"title": "fix: path handling in react devtools",
"total_changes": 85
} |
216 | diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml
index 21202a800459c..71aea56e8492f 100644
--- a/.github/workflows/compiler_discord_notify.yml
+++ b/.github/workflows/compiler_discord_notify.yml
@@ -13,15 +13,15 @@ jobs:
check_access:
runs-on: ubuntu-latest
outputs:
- is_member_or_collaborator: ${{ steps.check_access.outputs.is_member_or_collaborator }}
+ is_member_or_collaborator: ${{ steps.check_is_member_or_collaborator.outputs.is_member_or_collaborator }}
steps:
- - name: Check access
- id: check_access
+ - name: Check is member or collaborator
+ id: check_is_member_or_collaborator
if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
- run: echo "is_member_or_collaborator='true'" >> "$GITHUB_OUTPUT"
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
check_maintainer:
- if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' || needs.check_access.outputs.is_member_or_collaborator == true }}
needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml
index c3240ef88eb2a..44775fbe78880 100644
--- a/.github/workflows/runtime_discord_notify.yml
+++ b/.github/workflows/runtime_discord_notify.yml
@@ -13,15 +13,15 @@ jobs:
check_access:
runs-on: ubuntu-latest
outputs:
- is_member_or_collaborator: ${{ steps.check_access.outputs.is_member_or_collaborator }}
+ is_member_or_collaborator: ${{ steps.check_is_member_or_collaborator.outputs.is_member_or_collaborator }}
steps:
- - name: Check access
- id: check_access
+ - name: Check is member or collaborator
+ id: check_is_member_or_collaborator
if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
- run: echo "is_member_or_collaborator='true'" >> "$GITHUB_OUTPUT"
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
check_maintainer:
- if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' || needs.check_access.outputs.is_member_or_collaborator == true }}
needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml
index df75ff50429a1..fd4aa9399e386 100644
--- a/.github/workflows/shared_label_core_team_prs.yml
+++ b/.github/workflows/shared_label_core_team_prs.yml
@@ -2,6 +2,7 @@ name: (Shared) Label Core Team PRs
on:
pull_request_target:
+ types: [opened]
permissions: {}
@@ -14,15 +15,15 @@ jobs:
check_access:
runs-on: ubuntu-latest
outputs:
- is_member_or_collaborator: ${{ steps.check_access.outputs.is_member_or_collaborator }}
+ is_member_or_collaborator: ${{ steps.check_is_member_or_collaborator.outputs.is_member_or_collaborator }}
steps:
- - name: Check access
- id: check_access
+ - name: Check is member or collaborator
+ id: check_is_member_or_collaborator
if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
- run: echo "is_member_or_collaborator='true'" >> "$GITHUB_OUTPUT"
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
check_maintainer:
- if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' || needs.check_access.outputs.is_member_or_collaborator == true }}
needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
| diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml
index 21202a800459c..71aea56e8492f 100644
--- a/.github/workflows/compiler_discord_notify.yml
+++ b/.github/workflows/compiler_discord_notify.yml
diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml
index c3240ef88eb2a..44775fbe78880 100644
--- a/.github/workflows/runtime_discord_notify.yml
+++ b/.github/workflows/runtime_discord_notify.yml
diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml
index df75ff50429a1..fd4aa9399e386 100644
--- a/.github/workflows/shared_label_core_team_prs.yml
+++ b/.github/workflows/shared_label_core_team_prs.yml
@@ -2,6 +2,7 @@ name: (Shared) Label Core Team PRs
on:
pull_request_target:
+ types: [opened]
permissions: {}
@@ -14,15 +15,15 @@ jobs: | [] | [] | {
"additions": 16,
"author": "poteto",
"deletions": 15,
"html_url": "https://github.com/facebook/react/pull/32936",
"issue_id": 32936,
"merged_at": "2025-04-16T22:01:56Z",
"omission_probability": 0.1,
"pr_number": 32936,
"repo": "facebook/react",
"title": "[ci] Only label on PR open",
"total_changes": 31
} |
217 | diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml
index 21202a800459c..71aea56e8492f 100644
--- a/.github/workflows/compiler_discord_notify.yml
+++ b/.github/workflows/compiler_discord_notify.yml
@@ -13,15 +13,15 @@ jobs:
check_access:
runs-on: ubuntu-latest
outputs:
- is_member_or_collaborator: ${{ steps.check_access.outputs.is_member_or_collaborator }}
+ is_member_or_collaborator: ${{ steps.check_is_member_or_collaborator.outputs.is_member_or_collaborator }}
steps:
- - name: Check access
- id: check_access
+ - name: Check is member or collaborator
+ id: check_is_member_or_collaborator
if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
- run: echo "is_member_or_collaborator='true'" >> "$GITHUB_OUTPUT"
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
check_maintainer:
- if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' || needs.check_access.outputs.is_member_or_collaborator == true }}
needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml
index c3240ef88eb2a..44775fbe78880 100644
--- a/.github/workflows/runtime_discord_notify.yml
+++ b/.github/workflows/runtime_discord_notify.yml
@@ -13,15 +13,15 @@ jobs:
check_access:
runs-on: ubuntu-latest
outputs:
- is_member_or_collaborator: ${{ steps.check_access.outputs.is_member_or_collaborator }}
+ is_member_or_collaborator: ${{ steps.check_is_member_or_collaborator.outputs.is_member_or_collaborator }}
steps:
- - name: Check access
- id: check_access
+ - name: Check is member or collaborator
+ id: check_is_member_or_collaborator
if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
- run: echo "is_member_or_collaborator='true'" >> "$GITHUB_OUTPUT"
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
check_maintainer:
- if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' || needs.check_access.outputs.is_member_or_collaborator == true }}
needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml
index df75ff50429a1..73e7261f566cb 100644
--- a/.github/workflows/shared_label_core_team_prs.yml
+++ b/.github/workflows/shared_label_core_team_prs.yml
@@ -14,15 +14,15 @@ jobs:
check_access:
runs-on: ubuntu-latest
outputs:
- is_member_or_collaborator: ${{ steps.check_access.outputs.is_member_or_collaborator }}
+ is_member_or_collaborator: ${{ steps.check_is_member_or_collaborator.outputs.is_member_or_collaborator }}
steps:
- - name: Check access
- id: check_access
+ - name: Check is member or collaborator
+ id: check_is_member_or_collaborator
if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
- run: echo "is_member_or_collaborator='true'" >> "$GITHUB_OUTPUT"
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
check_maintainer:
- if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' || needs.check_access.outputs.is_member_or_collaborator == true }}
needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
| diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml
index 21202a800459c..71aea56e8492f 100644
--- a/.github/workflows/compiler_discord_notify.yml
+++ b/.github/workflows/compiler_discord_notify.yml
diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml
index c3240ef88eb2a..44775fbe78880 100644
--- a/.github/workflows/runtime_discord_notify.yml
+++ b/.github/workflows/runtime_discord_notify.yml
diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml
index df75ff50429a1..73e7261f566cb 100644
--- a/.github/workflows/shared_label_core_team_prs.yml
+++ b/.github/workflows/shared_label_core_team_prs.yml
@@ -14,15 +14,15 @@ jobs: | [] | [] | {
"additions": 15,
"author": "poteto",
"deletions": 15,
"html_url": "https://github.com/facebook/react/pull/32935",
"issue_id": 32935,
"merged_at": "2025-04-16T22:00:25Z",
"omission_probability": 0.1,
"pr_number": 32935,
"repo": "facebook/react",
"title": "[ci] Fix check_access again",
"total_changes": 30
} |
218 | diff --git a/compiler/packages/react-mcp-server/package.json b/compiler/packages/react-mcp-server/package.json
index 49e5a542d6a41..d4c270513aa7f 100644
--- a/compiler/packages/react-mcp-server/package.json
+++ b/compiler/packages/react-mcp-server/package.json
@@ -8,6 +8,8 @@
"scripts": {
"build": "rimraf dist && tsup",
"test": "echo 'no tests'",
+ "dev": "concurrently --kill-others -n build,inspect \"yarn run watch\" \"wait-on dist/index.js && yarn run inspect\"",
+ "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
"watch": "yarn build --watch"
},
"dependencies": {
diff --git a/compiler/packages/react-mcp-server/src/compiler/index.ts b/compiler/packages/react-mcp-server/src/compiler/index.ts
index 8b8e494ccc1cc..0da206bd02eaa 100644
--- a/compiler/packages/react-mcp-server/src/compiler/index.ts
+++ b/compiler/packages/react-mcp-server/src/compiler/index.ts
@@ -14,6 +14,16 @@ import * as prettier from 'prettier';
export let lastResult: BabelCore.BabelFileResult | null = null;
+export type PrintedCompilerPipelineValue =
+ | {
+ kind: 'hir';
+ name: string;
+ fnName: string | null;
+ value: string;
+ }
+ | {kind: 'reactive'; name: string; fnName: string | null; value: string}
+ | {kind: 'debug'; name: string; fnName: string | null; value: string};
+
type CompileOptions = {
text: string;
file: string;
diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 9f81de88ce9ab..e577128f86355 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -11,7 +11,7 @@ import {
} from '@modelcontextprotocol/sdk/server/mcp.js';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import {z} from 'zod';
-import {compile} from './compiler';
+import {compile, type PrintedCompilerPipelineValue} from './compiler';
import {
CompilerPipelineValue,
printReactiveFunctionWithOutlined,
@@ -22,32 +22,38 @@ import {
import * as cheerio from 'cheerio';
import TurndownService from 'turndown';
import {queryAlgolia} from './utils/algolia';
+import assertExhaustive from './utils/assertExhaustive';
const turndownService = new TurndownService();
-
-export type PrintedCompilerPipelineValue =
- | {
- kind: 'hir';
- name: string;
- fnName: string | null;
- value: string;
- }
- | {kind: 'reactive'; name: string; fnName: string | null; value: string}
- | {kind: 'debug'; name: string; fnName: string | null; value: string};
-
const server = new McpServer({
name: 'React',
version: '0.0.0',
});
+function slugify(heading: string): string {
+ return heading
+ .split(' ')
+ .map(w => w.toLowerCase())
+ .join('-');
+}
+
// TODO: how to verify this works?
server.resource(
'docs',
new ResourceTemplate('docs://{message}', {list: undefined}),
- async (uri, {message}) => {
+ async (_uri, {message}) => {
const hits = await queryAlgolia(message);
+ const deduped = new Map();
+ for (const hit of hits) {
+ // drop hashes to dedupe properly
+ const u = new URL(hit.url);
+ if (deduped.has(u.pathname)) {
+ continue;
+ }
+ deduped.set(u.pathname, hit);
+ }
const pages: Array<string | null> = await Promise.all(
- hits.map(hit => {
+ Array.from(deduped.values()).map(hit => {
return fetch(hit.url, {
headers: {
'User-Agent':
@@ -70,16 +76,17 @@ server.resource(
.filter(html => html !== null)
.map(html => {
const $ = cheerio.load(html);
+ const title = encodeURIComponent(slugify($('h1').text()));
// react.dev should always have at least one <article> with the main content
const article = $('article').html();
if (article != null) {
return {
- uri: uri.href,
+ uri: `docs://${title}`,
text: turndownService.turndown(article),
};
} else {
return {
- uri: uri.href,
+ uri: `docs://${title}`,
// Fallback to converting the whole page to markdown
text: turndownService.turndown($.html()),
};
@@ -97,7 +104,7 @@ server.tool(
'Compile code with React Compiler. Optionally, for debugging provide a pass name like "HIR" to see more information.',
{
text: z.string(),
- passName: z.string().optional(),
+ passName: z.enum(['HIR', 'ReactiveFunction', 'All', '@DEBUG']).optional(),
},
async ({text, passName}) => {
const pipelinePasses = new Map<
@@ -147,8 +154,7 @@ server.tool(
break;
}
default: {
- const _: never = result;
- throw new Error(`Unhandled result ${result}`);
+ assertExhaustive(result, `Unhandled result ${result}`);
}
}
};
@@ -188,6 +194,78 @@ server.tool(
}
const requestedPasses: Array<{type: 'text'; text: string}> = [];
if (passName != null) {
+ switch (passName) {
+ case 'All': {
+ const hir = pipelinePasses.get('PropagateScopeDependenciesHIR');
+ if (hir !== undefined) {
+ for (const pipelineValue of hir) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ }
+ const reactiveFunc = pipelinePasses.get('PruneHoistedContexts');
+ if (reactiveFunc !== undefined) {
+ for (const pipelineValue of reactiveFunc) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ }
+ break;
+ }
+ case 'HIR': {
+ // Last pass before HIR -> ReactiveFunction
+ const requestedPass = pipelinePasses.get(
+ 'PropagateScopeDependenciesHIR',
+ );
+ if (requestedPass !== undefined) {
+ for (const pipelineValue of requestedPass) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ } else {
+ console.error(`Could not find requested pass ${passName}`);
+ }
+ break;
+ }
+ case 'ReactiveFunction': {
+ // Last pass
+ const requestedPass = pipelinePasses.get('PruneHoistedContexts');
+ if (requestedPass !== undefined) {
+ for (const pipelineValue of requestedPass) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ } else {
+ console.error(`Could not find requested pass ${passName}`);
+ }
+ break;
+ }
+ case '@DEBUG': {
+ for (const [, pipelinePass] of pipelinePasses) {
+ for (const pass of pipelinePass) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: `${pass.name}\n\n${pass.value}`,
+ });
+ }
+ }
+ break;
+ }
+ default: {
+ assertExhaustive(
+ passName,
+ `Unhandled passName option: ${passName}`,
+ );
+ }
+ }
const requestedPass = pipelinePasses.get(passName);
if (requestedPass !== undefined) {
for (const pipelineValue of requestedPass) {
@@ -205,7 +283,7 @@ server.tool(
if (typeof err.loc !== 'symbol') {
return {
type: 'text' as const,
- text: `React Compiler bailed out: ${err.message}@${err.loc.start}:${err.loc.end}`,
+ text: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
};
}
return null;
diff --git a/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
new file mode 100644
index 0000000000000..2adfffa8d7ea4
--- /dev/null
+++ b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
@@ -0,0 +1,13 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/**
+ * Trigger an exhaustiveness check in TypeScript and throw at runtime.
+ */
+export default function assertExhaustive(_: never, errorMsg: string): never {
+ throw new Error(errorMsg);
+}
| diff --git a/compiler/packages/react-mcp-server/package.json b/compiler/packages/react-mcp-server/package.json
index 49e5a542d6a41..d4c270513aa7f 100644
--- a/compiler/packages/react-mcp-server/package.json
+++ b/compiler/packages/react-mcp-server/package.json
@@ -8,6 +8,8 @@
"scripts": {
"build": "rimraf dist && tsup",
"test": "echo 'no tests'",
+ "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
"watch": "yarn build --watch"
"dependencies": {
diff --git a/compiler/packages/react-mcp-server/src/compiler/index.ts b/compiler/packages/react-mcp-server/src/compiler/index.ts
index 8b8e494ccc1cc..0da206bd02eaa 100644
--- a/compiler/packages/react-mcp-server/src/compiler/index.ts
+++ b/compiler/packages/react-mcp-server/src/compiler/index.ts
@@ -14,6 +14,16 @@ import * as prettier from 'prettier';
export let lastResult: BabelCore.BabelFileResult | null = null;
+export type PrintedCompilerPipelineValue =
+ | {
+ kind: 'hir';
+ name: string;
+ fnName: string | null;
+ | {kind: 'reactive'; name: string; fnName: string | null; value: string}
+ | {kind: 'debug'; name: string; fnName: string | null; value: string};
type CompileOptions = {
text: string;
file: string;
diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 9f81de88ce9ab..e577128f86355 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -11,7 +11,7 @@ import {
} from '@modelcontextprotocol/sdk/server/mcp.js';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import {z} from 'zod';
-import {compile} from './compiler';
+import {compile, type PrintedCompilerPipelineValue} from './compiler';
import {
CompilerPipelineValue,
printReactiveFunctionWithOutlined,
@@ -22,32 +22,38 @@ import {
import * as cheerio from 'cheerio';
import TurndownService from 'turndown';
import {queryAlgolia} from './utils/algolia';
+import assertExhaustive from './utils/assertExhaustive';
const turndownService = new TurndownService();
-export type PrintedCompilerPipelineValue =
- | {
- kind: 'hir';
- name: string;
- fnName: string | null;
- value: string;
- }
- | {kind: 'reactive'; name: string; fnName: string | null; value: string}
- | {kind: 'debug'; name: string; fnName: string | null; value: string};
const server = new McpServer({
name: 'React',
version: '0.0.0',
});
+function slugify(heading: string): string {
+ return heading
+ .split(' ')
+ .map(w => w.toLowerCase())
+ .join('-');
// TODO: how to verify this works?
server.resource(
'docs',
new ResourceTemplate('docs://{message}', {list: undefined}),
- async (uri, {message}) => {
+ async (_uri, {message}) => {
const hits = await queryAlgolia(message);
+ for (const hit of hits) {
+ // drop hashes to dedupe properly
+ const u = new URL(hit.url);
+ if (deduped.has(u.pathname)) {
+ continue;
+ }
+ deduped.set(u.pathname, hit);
const pages: Array<string | null> = await Promise.all(
- hits.map(hit => {
return fetch(hit.url, {
headers: {
'User-Agent':
@@ -70,16 +76,17 @@ server.resource(
.filter(html => html !== null)
.map(html => {
const $ = cheerio.load(html);
+ const title = encodeURIComponent(slugify($('h1').text()));
// react.dev should always have at least one <article> with the main content
const article = $('article').html();
if (article != null) {
text: turndownService.turndown(article),
} else {
// Fallback to converting the whole page to markdown
text: turndownService.turndown($.html()),
@@ -97,7 +104,7 @@ server.tool(
'Compile code with React Compiler. Optionally, for debugging provide a pass name like "HIR" to see more information.',
{
text: z.string(),
- passName: z.string().optional(),
+ passName: z.enum(['HIR', 'ReactiveFunction', 'All', '@DEBUG']).optional(),
async ({text, passName}) => {
const pipelinePasses = new Map<
@@ -147,8 +154,7 @@ server.tool(
break;
default: {
- const _: never = result;
- throw new Error(`Unhandled result ${result}`);
+ assertExhaustive(result, `Unhandled result ${result}`);
};
@@ -188,6 +194,78 @@ server.tool(
const requestedPasses: Array<{type: 'text'; text: string}> = [];
if (passName != null) {
+ switch (passName) {
+ case 'All': {
+ const hir = pipelinePasses.get('PropagateScopeDependenciesHIR');
+ if (hir !== undefined) {
+ for (const pipelineValue of hir) {
+ const reactiveFunc = pipelinePasses.get('PruneHoistedContexts');
+ if (reactiveFunc !== undefined) {
+ for (const pipelineValue of reactiveFunc) {
+ case 'HIR': {
+ 'PropagateScopeDependenciesHIR',
+ // Last pass
+ const requestedPass = pipelinePasses.get('PruneHoistedContexts');
+ case '@DEBUG': {
+ for (const [, pipelinePass] of pipelinePasses) {
+ for (const pass of pipelinePass) {
+ text: `${pass.name}\n\n${pass.value}`,
+ default: {
+ assertExhaustive(
+ passName,
+ }
const requestedPass = pipelinePasses.get(passName);
if (requestedPass !== undefined) {
for (const pipelineValue of requestedPass) {
@@ -205,7 +283,7 @@ server.tool(
if (typeof err.loc !== 'symbol') {
return {
type: 'text' as const,
- text: `React Compiler bailed out: ${err.message}@${err.loc.start}:${err.loc.end}`,
+ text: `React Compiler bailed out:\n\n${err.message}@${err.loc.start.line}:${err.loc.end.line}`,
};
}
return null;
diff --git a/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
new file mode 100644
index 0000000000000..2adfffa8d7ea4
--- /dev/null
+++ b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
@@ -0,0 +1,13 @@
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ * Trigger an exhaustiveness check in TypeScript and throw at runtime.
+export default function assertExhaustive(_: never, errorMsg: string): never {
+ throw new Error(errorMsg); | [
"+ \"dev\": \"concurrently --kill-others -n build,inspect \\\"yarn run watch\\\" \\\"wait-on dist/index.js && yarn run inspect\\\"\",",
"+ value: string;",
"+ const deduped = new Map();",
"+ Array.from(deduped.values()).map(hit => {",
"+ // Last pass before HIR -> ReactiveFunction",
"+ const requestedPass = pipelinePasses.get(",
"+ case 'ReactiveFunction': {",
"+ `Unhandled passName option: ${passName}`,"
] | [
8,
26,
84,
95,
165,
166,
181,
210
] | {
"additions": 123,
"author": "poteto",
"deletions": 20,
"html_url": "https://github.com/facebook/react/pull/32931",
"issue_id": 32931,
"merged_at": "2025-04-16T21:49:15Z",
"omission_probability": 0.1,
"pr_number": 32931,
"repo": "facebook/react",
"title": "[mcp] Fix bailout loc",
"total_changes": 143
} |
219 | diff --git a/compiler/packages/react-mcp-server/package.json b/compiler/packages/react-mcp-server/package.json
index 49e5a542d6a41..d4c270513aa7f 100644
--- a/compiler/packages/react-mcp-server/package.json
+++ b/compiler/packages/react-mcp-server/package.json
@@ -8,6 +8,8 @@
"scripts": {
"build": "rimraf dist && tsup",
"test": "echo 'no tests'",
+ "dev": "concurrently --kill-others -n build,inspect \"yarn run watch\" \"wait-on dist/index.js && yarn run inspect\"",
+ "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
"watch": "yarn build --watch"
},
"dependencies": {
diff --git a/compiler/packages/react-mcp-server/src/compiler/index.ts b/compiler/packages/react-mcp-server/src/compiler/index.ts
index 8b8e494ccc1cc..0da206bd02eaa 100644
--- a/compiler/packages/react-mcp-server/src/compiler/index.ts
+++ b/compiler/packages/react-mcp-server/src/compiler/index.ts
@@ -14,6 +14,16 @@ import * as prettier from 'prettier';
export let lastResult: BabelCore.BabelFileResult | null = null;
+export type PrintedCompilerPipelineValue =
+ | {
+ kind: 'hir';
+ name: string;
+ fnName: string | null;
+ value: string;
+ }
+ | {kind: 'reactive'; name: string; fnName: string | null; value: string}
+ | {kind: 'debug'; name: string; fnName: string | null; value: string};
+
type CompileOptions = {
text: string;
file: string;
diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 9f81de88ce9ab..345e25881e0b8 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -11,7 +11,7 @@ import {
} from '@modelcontextprotocol/sdk/server/mcp.js';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import {z} from 'zod';
-import {compile} from './compiler';
+import {compile, type PrintedCompilerPipelineValue} from './compiler';
import {
CompilerPipelineValue,
printReactiveFunctionWithOutlined,
@@ -22,32 +22,38 @@ import {
import * as cheerio from 'cheerio';
import TurndownService from 'turndown';
import {queryAlgolia} from './utils/algolia';
+import assertExhaustive from './utils/assertExhaustive';
const turndownService = new TurndownService();
-
-export type PrintedCompilerPipelineValue =
- | {
- kind: 'hir';
- name: string;
- fnName: string | null;
- value: string;
- }
- | {kind: 'reactive'; name: string; fnName: string | null; value: string}
- | {kind: 'debug'; name: string; fnName: string | null; value: string};
-
const server = new McpServer({
name: 'React',
version: '0.0.0',
});
+function slugify(heading: string): string {
+ return heading
+ .split(' ')
+ .map(w => w.toLowerCase())
+ .join('-');
+}
+
// TODO: how to verify this works?
server.resource(
'docs',
new ResourceTemplate('docs://{message}', {list: undefined}),
- async (uri, {message}) => {
+ async (_uri, {message}) => {
const hits = await queryAlgolia(message);
+ const deduped = new Map();
+ for (const hit of hits) {
+ // drop hashes to dedupe properly
+ const u = new URL(hit.url);
+ if (deduped.has(u.pathname)) {
+ continue;
+ }
+ deduped.set(u.pathname, hit);
+ }
const pages: Array<string | null> = await Promise.all(
- hits.map(hit => {
+ Array.from(deduped.values()).map(hit => {
return fetch(hit.url, {
headers: {
'User-Agent':
@@ -70,16 +76,17 @@ server.resource(
.filter(html => html !== null)
.map(html => {
const $ = cheerio.load(html);
+ const title = encodeURIComponent(slugify($('h1').text()));
// react.dev should always have at least one <article> with the main content
const article = $('article').html();
if (article != null) {
return {
- uri: uri.href,
+ uri: `docs://${title}`,
text: turndownService.turndown(article),
};
} else {
return {
- uri: uri.href,
+ uri: `docs://${title}`,
// Fallback to converting the whole page to markdown
text: turndownService.turndown($.html()),
};
@@ -97,7 +104,7 @@ server.tool(
'Compile code with React Compiler. Optionally, for debugging provide a pass name like "HIR" to see more information.',
{
text: z.string(),
- passName: z.string().optional(),
+ passName: z.enum(['HIR', 'ReactiveFunction', 'All', '@DEBUG']).optional(),
},
async ({text, passName}) => {
const pipelinePasses = new Map<
@@ -147,8 +154,7 @@ server.tool(
break;
}
default: {
- const _: never = result;
- throw new Error(`Unhandled result ${result}`);
+ assertExhaustive(result, `Unhandled result ${result}`);
}
}
};
@@ -188,6 +194,78 @@ server.tool(
}
const requestedPasses: Array<{type: 'text'; text: string}> = [];
if (passName != null) {
+ switch (passName) {
+ case 'All': {
+ const hir = pipelinePasses.get('PropagateScopeDependenciesHIR');
+ if (hir !== undefined) {
+ for (const pipelineValue of hir) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ }
+ const reactiveFunc = pipelinePasses.get('PruneHoistedContexts');
+ if (reactiveFunc !== undefined) {
+ for (const pipelineValue of reactiveFunc) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ }
+ break;
+ }
+ case 'HIR': {
+ // Last pass before HIR -> ReactiveFunction
+ const requestedPass = pipelinePasses.get(
+ 'PropagateScopeDependenciesHIR',
+ );
+ if (requestedPass !== undefined) {
+ for (const pipelineValue of requestedPass) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ } else {
+ console.error(`Could not find requested pass ${passName}`);
+ }
+ break;
+ }
+ case 'ReactiveFunction': {
+ // Last pass
+ const requestedPass = pipelinePasses.get('PruneHoistedContexts');
+ if (requestedPass !== undefined) {
+ for (const pipelineValue of requestedPass) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: pipelineValue.value,
+ });
+ }
+ } else {
+ console.error(`Could not find requested pass ${passName}`);
+ }
+ break;
+ }
+ case '@DEBUG': {
+ for (const [, pipelinePass] of pipelinePasses) {
+ for (const pass of pipelinePass) {
+ requestedPasses.push({
+ type: 'text' as const,
+ text: `${pass.name}\n\n${pass.value}`,
+ });
+ }
+ }
+ break;
+ }
+ default: {
+ assertExhaustive(
+ passName,
+ `Unhandled passName option: ${passName}`,
+ );
+ }
+ }
const requestedPass = pipelinePasses.get(passName);
if (requestedPass !== undefined) {
for (const pipelineValue of requestedPass) {
diff --git a/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
new file mode 100644
index 0000000000000..2adfffa8d7ea4
--- /dev/null
+++ b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
@@ -0,0 +1,13 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/**
+ * Trigger an exhaustiveness check in TypeScript and throw at runtime.
+ */
+export default function assertExhaustive(_: never, errorMsg: string): never {
+ throw new Error(errorMsg);
+}
| diff --git a/compiler/packages/react-mcp-server/package.json b/compiler/packages/react-mcp-server/package.json
index 49e5a542d6a41..d4c270513aa7f 100644
--- a/compiler/packages/react-mcp-server/package.json
+++ b/compiler/packages/react-mcp-server/package.json
@@ -8,6 +8,8 @@
"scripts": {
"build": "rimraf dist && tsup",
"test": "echo 'no tests'",
+ "dev": "concurrently --kill-others -n build,inspect \"yarn run watch\" \"wait-on dist/index.js && yarn run inspect\"",
"watch": "yarn build --watch"
"dependencies": {
diff --git a/compiler/packages/react-mcp-server/src/compiler/index.ts b/compiler/packages/react-mcp-server/src/compiler/index.ts
index 8b8e494ccc1cc..0da206bd02eaa 100644
--- a/compiler/packages/react-mcp-server/src/compiler/index.ts
+++ b/compiler/packages/react-mcp-server/src/compiler/index.ts
@@ -14,6 +14,16 @@ import * as prettier from 'prettier';
export let lastResult: BabelCore.BabelFileResult | null = null;
+export type PrintedCompilerPipelineValue =
+ | {
+ kind: 'hir';
+ name: string;
+ fnName: string | null;
+ value: string;
+ | {kind: 'reactive'; name: string; fnName: string | null; value: string}
+ | {kind: 'debug'; name: string; fnName: string | null; value: string};
type CompileOptions = {
text: string;
file: string;
diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 9f81de88ce9ab..345e25881e0b8 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -11,7 +11,7 @@ import {
} from '@modelcontextprotocol/sdk/server/mcp.js';
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
import {z} from 'zod';
-import {compile} from './compiler';
+import {compile, type PrintedCompilerPipelineValue} from './compiler';
import {
CompilerPipelineValue,
printReactiveFunctionWithOutlined,
@@ -22,32 +22,38 @@ import {
import * as cheerio from 'cheerio';
import TurndownService from 'turndown';
import {queryAlgolia} from './utils/algolia';
+import assertExhaustive from './utils/assertExhaustive';
const turndownService = new TurndownService();
-export type PrintedCompilerPipelineValue =
- | {
- kind: 'hir';
- name: string;
- fnName: string | null;
- value: string;
- }
- | {kind: 'reactive'; name: string; fnName: string | null; value: string}
- | {kind: 'debug'; name: string; fnName: string | null; value: string};
const server = new McpServer({
name: 'React',
version: '0.0.0',
});
+function slugify(heading: string): string {
+ return heading
+ .split(' ')
+ .map(w => w.toLowerCase())
+ .join('-');
// TODO: how to verify this works?
server.resource(
'docs',
new ResourceTemplate('docs://{message}', {list: undefined}),
+ async (_uri, {message}) => {
const hits = await queryAlgolia(message);
+ const deduped = new Map();
+ for (const hit of hits) {
+ // drop hashes to dedupe properly
+ const u = new URL(hit.url);
+ if (deduped.has(u.pathname)) {
+ continue;
+ }
+ deduped.set(u.pathname, hit);
const pages: Array<string | null> = await Promise.all(
- hits.map(hit => {
+ Array.from(deduped.values()).map(hit => {
return fetch(hit.url, {
headers: {
'User-Agent':
@@ -70,16 +76,17 @@ server.resource(
.filter(html => html !== null)
.map(html => {
const $ = cheerio.load(html);
+ const title = encodeURIComponent(slugify($('h1').text()));
// react.dev should always have at least one <article> with the main content
const article = $('article').html();
if (article != null) {
text: turndownService.turndown(article),
} else {
// Fallback to converting the whole page to markdown
text: turndownService.turndown($.html()),
@@ -97,7 +104,7 @@ server.tool(
'Compile code with React Compiler. Optionally, for debugging provide a pass name like "HIR" to see more information.',
{
text: z.string(),
async ({text, passName}) => {
const pipelinePasses = new Map<
@@ -147,8 +154,7 @@ server.tool(
break;
default: {
- const _: never = result;
- throw new Error(`Unhandled result ${result}`);
+ assertExhaustive(result, `Unhandled result ${result}`);
};
@@ -188,6 +194,78 @@ server.tool(
const requestedPasses: Array<{type: 'text'; text: string}> = [];
if (passName != null) {
+ switch (passName) {
+ case 'All': {
+ const hir = pipelinePasses.get('PropagateScopeDependenciesHIR');
+ for (const pipelineValue of hir) {
+ const reactiveFunc = pipelinePasses.get('PruneHoistedContexts');
+ if (reactiveFunc !== undefined) {
+ for (const pipelineValue of reactiveFunc) {
+ case 'HIR': {
+ // Last pass before HIR -> ReactiveFunction
+ const requestedPass = pipelinePasses.get(
+ 'PropagateScopeDependenciesHIR',
+ case 'ReactiveFunction': {
+ // Last pass
+ const requestedPass = pipelinePasses.get('PruneHoistedContexts');
+ for (const [, pipelinePass] of pipelinePasses) {
+ text: `${pass.name}\n\n${pass.value}`,
+ default: {
+ assertExhaustive(
+ passName,
+ `Unhandled passName option: ${passName}`,
const requestedPass = pipelinePasses.get(passName);
if (requestedPass !== undefined) {
for (const pipelineValue of requestedPass) {
diff --git a/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
new file mode 100644
index 0000000000000..2adfffa8d7ea4
--- /dev/null
+++ b/compiler/packages/react-mcp-server/src/utils/assertExhaustive.ts
@@ -0,0 +1,13 @@
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ * Trigger an exhaustiveness check in TypeScript and throw at runtime.
+export default function assertExhaustive(_: never, errorMsg: string): never {
+ throw new Error(errorMsg); | [
"+ \"inspect\": \"npx @modelcontextprotocol/inspector node dist/index.js\",",
"- async (uri, {message}) => {",
"- passName: z.string().optional(),",
"+ passName: z.enum(['HIR', 'ReactiveFunction', 'All', '@DEBUG']).optional(),",
"+ if (hir !== undefined) {",
"+ case '@DEBUG': {",
"+ for (const pass of pipelinePass) {",
"+ }",
"+ *"
] | [
9,
81,
123,
124,
145,
196,
198,
213,
225
] | {
"additions": 122,
"author": "poteto",
"deletions": 19,
"html_url": "https://github.com/facebook/react/pull/32930",
"issue_id": 32930,
"merged_at": "2025-04-16T21:49:04Z",
"omission_probability": 0.1,
"pr_number": 32930,
"repo": "facebook/react",
"title": "[mcp] Refine passes returned",
"total_changes": 141
} |
220 | diff --git a/compiler/packages/react-mcp-server/package.json b/compiler/packages/react-mcp-server/package.json
index 49e5a542d6a41..d4c270513aa7f 100644
--- a/compiler/packages/react-mcp-server/package.json
+++ b/compiler/packages/react-mcp-server/package.json
@@ -8,6 +8,8 @@
"scripts": {
"build": "rimraf dist && tsup",
"test": "echo 'no tests'",
+ "dev": "concurrently --kill-others -n build,inspect \"yarn run watch\" \"wait-on dist/index.js && yarn run inspect\"",
+ "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
"watch": "yarn build --watch"
},
"dependencies": {
diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 9f81de88ce9ab..fbe5f58f66143 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -40,14 +40,30 @@ const server = new McpServer({
version: '0.0.0',
});
+function slugify(heading: string): string {
+ return heading
+ .split(' ')
+ .map(w => w.toLowerCase())
+ .join('-');
+}
+
// TODO: how to verify this works?
server.resource(
'docs',
new ResourceTemplate('docs://{message}', {list: undefined}),
- async (uri, {message}) => {
+ async (_uri, {message}) => {
const hits = await queryAlgolia(message);
+ const deduped = new Map();
+ for (const hit of hits) {
+ // drop hashes to dedupe properly
+ const u = new URL(hit.url);
+ if (deduped.has(u.pathname)) {
+ continue;
+ }
+ deduped.set(u.pathname, hit);
+ }
const pages: Array<string | null> = await Promise.all(
- hits.map(hit => {
+ Array.from(deduped.values()).map(hit => {
return fetch(hit.url, {
headers: {
'User-Agent':
@@ -70,16 +86,17 @@ server.resource(
.filter(html => html !== null)
.map(html => {
const $ = cheerio.load(html);
+ const title = encodeURIComponent(slugify($('h1').text()));
// react.dev should always have at least one <article> with the main content
const article = $('article').html();
if (article != null) {
return {
- uri: uri.href,
+ uri: `docs://${title}`,
text: turndownService.turndown(article),
};
} else {
return {
- uri: uri.href,
+ uri: `docs://${title}`,
// Fallback to converting the whole page to markdown
text: turndownService.turndown($.html()),
};
| diff --git a/compiler/packages/react-mcp-server/package.json b/compiler/packages/react-mcp-server/package.json
index 49e5a542d6a41..d4c270513aa7f 100644
--- a/compiler/packages/react-mcp-server/package.json
+++ b/compiler/packages/react-mcp-server/package.json
@@ -8,6 +8,8 @@
"scripts": {
"build": "rimraf dist && tsup",
"test": "echo 'no tests'",
+ "dev": "concurrently --kill-others -n build,inspect \"yarn run watch\" \"wait-on dist/index.js && yarn run inspect\"",
+ "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
"watch": "yarn build --watch"
},
"dependencies": {
diff --git a/compiler/packages/react-mcp-server/src/index.ts b/compiler/packages/react-mcp-server/src/index.ts
index 9f81de88ce9ab..fbe5f58f66143 100644
--- a/compiler/packages/react-mcp-server/src/index.ts
+++ b/compiler/packages/react-mcp-server/src/index.ts
@@ -40,14 +40,30 @@ const server = new McpServer({
version: '0.0.0',
});
+function slugify(heading: string): string {
+ return heading
+ .map(w => w.toLowerCase())
+ .join('-');
+}
+
// TODO: how to verify this works?
server.resource(
'docs',
new ResourceTemplate('docs://{message}', {list: undefined}),
- async (uri, {message}) => {
+ async (_uri, {message}) => {
const hits = await queryAlgolia(message);
+ const deduped = new Map();
+ for (const hit of hits) {
+ // drop hashes to dedupe properly
+ const u = new URL(hit.url);
+ }
+ deduped.set(u.pathname, hit);
+ }
const pages: Array<string | null> = await Promise.all(
- hits.map(hit => {
+ Array.from(deduped.values()).map(hit => {
return fetch(hit.url, {
headers: {
'User-Agent':
@@ -70,16 +86,17 @@ server.resource(
.filter(html => html !== null)
.map(html => {
const $ = cheerio.load(html);
+ const title = encodeURIComponent(slugify($('h1').text()));
// react.dev should always have at least one <article> with the main content
const article = $('article').html();
if (article != null) {
text: turndownService.turndown(article),
} else {
// Fallback to converting the whole page to markdown
text: turndownService.turndown($.html()), | [
"+ .split(' ')",
"+ if (deduped.has(u.pathname)) {",
"+ continue;"
] | [
23,
39,
40
] | {
"additions": 23,
"author": "poteto",
"deletions": 4,
"html_url": "https://github.com/facebook/react/pull/32929",
"issue_id": 32929,
"merged_at": "2025-04-16T21:48:53Z",
"omission_probability": 0.1,
"pr_number": 32929,
"repo": "facebook/react",
"title": "[mcp] Dedupe docs",
"total_changes": 27
} |
221 | diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 86a0ceb42e84a..deef07d6ef663 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -3723,6 +3723,11 @@ describe('ReactDOMServerPartialHydration', () => {
<Activity mode="hidden">
<HiddenChild />
</Activity>
+ <Suspense fallback={null}>
+ <Activity mode="hidden">
+ <HiddenChild />
+ </Activity>
+ </Suspense>
</>
);
}
@@ -3743,6 +3748,10 @@ describe('ReactDOMServerPartialHydration', () => {
</span>
<!--&-->
<!--/&-->
+ <!--$-->
+ <!--&-->
+ <!--/&-->
+ <!--/$-->
</div>
`);
@@ -3758,6 +3767,7 @@ describe('ReactDOMServerPartialHydration', () => {
await waitForPaint([]);
}
// Subsequently, the hidden child is prerendered on the client
+ // along with hydrating the Suspense boundary outside the Activity.
await waitForPaint(['HiddenChild']);
expect(container).toMatchInlineSnapshot(`
<div>
@@ -3766,6 +3776,37 @@ describe('ReactDOMServerPartialHydration', () => {
</span>
<!--&-->
<!--/&-->
+ <!--$-->
+ <!--&-->
+ <!--/&-->
+ <!--/$-->
+ <span
+ style="display: none;"
+ >
+ Hidden
+ </span>
+ </div>
+ `);
+
+ // Next the child inside the Activity is hydrated.
+ await waitForPaint(['HiddenChild']);
+
+ expect(container).toMatchInlineSnapshot(`
+ <div>
+ <span>
+ Visible
+ </span>
+ <!--&-->
+ <!--/&-->
+ <!--$-->
+ <!--&-->
+ <!--/&-->
+ <!--/$-->
+ <span
+ style="display: none;"
+ >
+ Hidden
+ </span>
<span
style="display: none;"
>
diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index b8e753dc03514..41e01b74601e2 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -724,7 +724,14 @@ function updateOffscreenComponent(
}
reuseHiddenContextOnStack(workInProgress);
pushOffscreenSuspenseHandler(workInProgress);
- } else if (!includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
+ } else if (
+ !includesSomeLane(renderLanes, (OffscreenLane: Lane)) ||
+ // SSR doesn't render hidden content (except legacy hidden) so it shouldn't hydrate,
+ // even at offscreen lane. Defer to a client rendered offscreen lane.
+ (getIsHydrating() &&
+ (!enableLegacyHidden ||
+ nextProps.mode !== 'unstable-defer-without-hiding'))
+ ) {
// We're hidden, and we're not rendering at Offscreen. We will bail out
// and resume this tree later.
| diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 86a0ceb42e84a..deef07d6ef663 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -3723,6 +3723,11 @@ describe('ReactDOMServerPartialHydration', () => {
<Activity mode="hidden">
<HiddenChild />
</Activity>
+ <Activity mode="hidden">
+ </Activity>
+ </Suspense>
</>
);
@@ -3743,6 +3748,10 @@ describe('ReactDOMServerPartialHydration', () => {
</div>
`);
@@ -3758,6 +3767,7 @@ describe('ReactDOMServerPartialHydration', () => {
await waitForPaint([]);
// Subsequently, the hidden child is prerendered on the client
+ // along with hydrating the Suspense boundary outside the Activity.
await waitForPaint(['HiddenChild']);
expect(container).toMatchInlineSnapshot(`
<div>
@@ -3766,6 +3776,37 @@ describe('ReactDOMServerPartialHydration', () => {
+ </div>
+ `);
+ // Next the child inside the Activity is hydrated.
+ await waitForPaint(['HiddenChild']);
+ expect(container).toMatchInlineSnapshot(`
+ <div>
+ <span>
+ Visible
<span
style="display: none;"
>
diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index b8e753dc03514..41e01b74601e2 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -724,7 +724,14 @@ function updateOffscreenComponent(
}
reuseHiddenContextOnStack(workInProgress);
pushOffscreenSuspenseHandler(workInProgress);
- } else if (!includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
+ } else if (
+ !includesSomeLane(renderLanes, (OffscreenLane: Lane)) ||
+ // SSR doesn't render hidden content (except legacy hidden) so it shouldn't hydrate,
+ // even at offscreen lane. Defer to a client rendered offscreen lane.
+ (getIsHydrating() &&
+ nextProps.mode !== 'unstable-defer-without-hiding'))
+ ) {
// We're hidden, and we're not rendering at Offscreen. We will bail out
// and resume this tree later. | [
"+ <Suspense fallback={null}>",
"+ <HiddenChild />",
"+ (!enableLegacyHidden ||"
] | [
8,
10,
87
] | {
"additions": 49,
"author": "sebmarkbage",
"deletions": 1,
"html_url": "https://github.com/facebook/react/pull/32862",
"issue_id": 32862,
"merged_at": "2025-04-15T21:43:42Z",
"omission_probability": 0.1,
"pr_number": 32862,
"repo": "facebook/react",
"title": "Don't try to hydrate a hidden Offscreen tree",
"total_changes": 50
} |
222 | diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index fc5019b2ff850..fd8451a3ef1be 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -873,6 +873,22 @@ function updateActivityComponent(
renderLanes: Lanes,
) {
const nextProps: ActivityProps = workInProgress.pendingProps;
+ if (__DEV__) {
+ const hiddenProp = (nextProps: any).hidden;
+ if (hiddenProp !== undefined) {
+ console.error(
+ '<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
+ '- <Activity %s>\n' +
+ '+ <Activity %s>',
+ hiddenProp === true
+ ? 'hidden'
+ : hiddenProp === false
+ ? 'hidden={false}'
+ : 'hidden={...}',
+ hiddenProp ? 'mode="hidden"' : 'mode="visible"',
+ );
+ }
+ }
const nextChildren = nextProps.children;
const nextMode = nextProps.mode;
const mode = workInProgress.mode;
diff --git a/packages/react-reconciler/src/__tests__/Activity-test.js b/packages/react-reconciler/src/__tests__/Activity-test.js
index 4655d4917d6a3..d514bb4e0b0f0 100644
--- a/packages/react-reconciler/src/__tests__/Activity-test.js
+++ b/packages/react-reconciler/src/__tests__/Activity-test.js
@@ -732,7 +732,7 @@ describe('Activity', () => {
const root = ReactNoop.createRoot();
await act(() => {
- root.render(<Activity hidden={false} />);
+ root.render(<Activity />);
});
assertLog([]);
expect(root).toMatchRenderedOutput(null);
@@ -741,7 +741,7 @@ describe('Activity', () => {
// Partially render a component
startTransition(() => {
root.render(
- <Activity hidden={false}>
+ <Activity>
<Child />
<Text text="Sibling" />
</Activity>,
@@ -1480,4 +1480,28 @@ describe('Activity', () => {
assertLog([]);
expect(root).toMatchRenderedOutput(<span prop={2} />);
});
+
+ // @gate enableActivity
+ it('warns if you pass a hidden prop', async () => {
+ function App() {
+ return (
+ // eslint-disable-next-line react/jsx-boolean-value
+ <Activity hidden>
+ <div />
+ </Activity>
+ );
+ }
+
+ const root = ReactNoop.createRoot();
+ await act(() => {
+ root.render(<App show={true} step={1} />);
+ });
+ assertConsoleErrorDev([
+ '<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
+ '- <Activity hidden>\n' +
+ '+ <Activity mode="hidden">\n' +
+ ' in Activity (at **)\n' +
+ ' in App (at **)',
+ ]);
+ });
});
| diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index fc5019b2ff850..fd8451a3ef1be 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -873,6 +873,22 @@ function updateActivityComponent(
renderLanes: Lanes,
) {
const nextProps: ActivityProps = workInProgress.pendingProps;
+ if (__DEV__) {
+ const hiddenProp = (nextProps: any).hidden;
+ if (hiddenProp !== undefined) {
+ console.error(
+ '<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
+ '- <Activity %s>\n' +
+ '+ <Activity %s>',
+ ? 'hidden'
+ : hiddenProp === false
+ ? 'hidden={false}'
+ : 'hidden={...}',
+ hiddenProp ? 'mode="hidden"' : 'mode="visible"',
+ }
const nextChildren = nextProps.children;
const nextMode = nextProps.mode;
const mode = workInProgress.mode;
diff --git a/packages/react-reconciler/src/__tests__/Activity-test.js b/packages/react-reconciler/src/__tests__/Activity-test.js
index 4655d4917d6a3..d514bb4e0b0f0 100644
--- a/packages/react-reconciler/src/__tests__/Activity-test.js
+++ b/packages/react-reconciler/src/__tests__/Activity-test.js
@@ -732,7 +732,7 @@ describe('Activity', () => {
const root = ReactNoop.createRoot();
await act(() => {
});
expect(root).toMatchRenderedOutput(null);
@@ -741,7 +741,7 @@ describe('Activity', () => {
// Partially render a component
startTransition(() => {
root.render(
- <Activity hidden={false}>
+ <Activity>
<Child />
<Text text="Sibling" />
</Activity>,
@@ -1480,4 +1480,28 @@ describe('Activity', () => {
expect(root).toMatchRenderedOutput(<span prop={2} />);
});
+ it('warns if you pass a hidden prop', async () => {
+ function App() {
+ return (
+ // eslint-disable-next-line react/jsx-boolean-value
+ <div />
+ </Activity>
+ const root = ReactNoop.createRoot();
+ await act(() => {
+ root.render(<App show={true} step={1} />);
+ });
+ assertConsoleErrorDev([
+ '<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
+ '- <Activity hidden>\n' +
+ '+ <Activity mode="hidden">\n' +
+ ' in App (at **)',
+ ]);
+ });
}); | [
"+ hiddenProp === true",
"- root.render(<Activity hidden={false} />);",
"+ root.render(<Activity />);",
"+ // @gate enableActivity",
"+ <Activity hidden>",
"+ ' in Activity (at **)\\n' +"
] | [
15,
35,
36,
54,
59,
73
] | {
"additions": 42,
"author": "sebmarkbage",
"deletions": 2,
"html_url": "https://github.com/facebook/react/pull/32916",
"issue_id": 32916,
"merged_at": "2025-04-15T21:17:23Z",
"omission_probability": 0.1,
"pr_number": 32916,
"repo": "facebook/react",
"title": "Warn if you pass a hidden prop to Activity",
"total_changes": 44
} |
223 | diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml
index 3840e3787bc00..0c7574bd16590 100644
--- a/.github/workflows/compiler_discord_notify.yml
+++ b/.github/workflows/compiler_discord_notify.yml
@@ -10,7 +10,19 @@ on:
permissions: {}
jobs:
+ check_access:
+ runs-on: ubuntu-latest
+ outputs:
+ is_member_or_collaborator: ${{ steps.check_access.outputs.result }}
+ steps:
+ - name: Check access
+ id: check_access
+ if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
+
check_maintainer:
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
# Used by check_maintainer
diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml
index ad94e28054d24..9b7ee8f25b35d 100644
--- a/.github/workflows/runtime_discord_notify.yml
+++ b/.github/workflows/runtime_discord_notify.yml
@@ -10,7 +10,19 @@ on:
permissions: {}
jobs:
+ check_access:
+ runs-on: ubuntu-latest
+ outputs:
+ is_member_or_collaborator: ${{ steps.check_access.outputs.result }}
+ steps:
+ - name: Check access
+ id: check_access
+ if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
+
check_maintainer:
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
# Used by check_maintainer
diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml
index 2cd9f290e0af0..ec0b63c177de3 100644
--- a/.github/workflows/shared_label_core_team_prs.yml
+++ b/.github/workflows/shared_label_core_team_prs.yml
@@ -11,7 +11,19 @@ env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
jobs:
+ check_access:
+ runs-on: ubuntu-latest
+ outputs:
+ is_member_or_collaborator: ${{ steps.check_access.outputs.result }}
+ steps:
+ - name: Check access
+ id: check_access
+ if: ${{ github.event.pull_request.author_association == 'MEMBER' || github.event.pull_request.author_association == 'COLLABORATOR' }}
+ run: echo "is_member_or_collaborator=true" >> "$GITHUB_OUTPUT"
+
check_maintainer:
+ if: ${{ needs.check_access.outputs.is_member_or_collaborator == 'true' }}
+ needs: [check_access]
uses: facebook/react/.github/workflows/shared_check_maintainer.yml@main
permissions:
# Used by check_maintainer
| diff --git a/.github/workflows/compiler_discord_notify.yml b/.github/workflows/compiler_discord_notify.yml
index 3840e3787bc00..0c7574bd16590 100644
--- a/.github/workflows/compiler_discord_notify.yml
+++ b/.github/workflows/compiler_discord_notify.yml
diff --git a/.github/workflows/runtime_discord_notify.yml b/.github/workflows/runtime_discord_notify.yml
index ad94e28054d24..9b7ee8f25b35d 100644
--- a/.github/workflows/runtime_discord_notify.yml
+++ b/.github/workflows/runtime_discord_notify.yml
diff --git a/.github/workflows/shared_label_core_team_prs.yml b/.github/workflows/shared_label_core_team_prs.yml
index 2cd9f290e0af0..ec0b63c177de3 100644
--- a/.github/workflows/shared_label_core_team_prs.yml
+++ b/.github/workflows/shared_label_core_team_prs.yml
@@ -11,7 +11,19 @@ env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 | [] | [] | {
"additions": 36,
"author": "poteto",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32918",
"issue_id": 32918,
"merged_at": "2025-04-15T17:02:17Z",
"omission_probability": 0.1,
"pr_number": 32918,
"repo": "facebook/react",
"title": "[ci] Don't run some checks for non-members/collaborators",
"total_changes": 36
} |
224 | diff --git a/compiler/package.json b/compiler/package.json
index 282f707d4e1eb..e3c3ee8c7f341 100644
--- a/compiler/package.json
+++ b/compiler/package.json
@@ -37,7 +37,7 @@
"prettier": "^3.3.3",
"prettier-plugin-hermes-parser": "^0.26.0",
"prompt-promise": "^1.0.3",
- "rimraf": "^5.0.10",
+ "rimraf": "^6.0.1",
"to-fast-properties": "^2.0.0",
"tsup": "^8.4.0",
"typescript": "^5.4.3",
@@ -45,7 +45,6 @@
"yargs": "^17.7.2"
},
"resolutions": {
- "rimraf": "5.0.10",
"@babel/types": "7.26.3"
},
"packageManager": "[email protected]"
diff --git a/compiler/yarn.lock b/compiler/yarn.lock
index e93f5fa78b9d1..be814741267b8 100644
--- a/compiler/yarn.lock
+++ b/compiler/yarn.lock
@@ -5274,7 +5274,7 @@ glob@^10.3.10:
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
path-scurry "^1.10.1"
-glob@^10.3.7, glob@^10.4.5:
+glob@^10.4.5:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
@@ -5286,6 +5286,18 @@ glob@^10.3.7, glob@^10.4.5:
package-json-from-dist "^1.0.0"
path-scurry "^1.11.1"
+glob@^11.0.0:
+ version "11.0.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.1.tgz#1c3aef9a59d680e611b53dcd24bb8639cef064d9"
+ integrity sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==
+ dependencies:
+ foreground-child "^3.1.0"
+ jackspeak "^4.0.1"
+ minimatch "^10.0.0"
+ minipass "^7.1.2"
+ package-json-from-dist "^1.0.0"
+ path-scurry "^2.0.0"
+
glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
@@ -5782,6 +5794,13 @@ jackspeak@^3.1.2:
optionalDependencies:
"@pkgjs/parseargs" "^0.11.0"
+jackspeak@^4.0.1:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-4.1.0.tgz#c489c079f2b636dc4cbe9b0312a13ff1282e561b"
+ integrity sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw==
+ dependencies:
+ "@isaacs/cliui" "^8.0.2"
+
jest-changed-files@^28.1.3:
version "28.1.3"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-28.1.3.tgz#d9aeee6792be3686c47cb988a8eaf82ff4238831"
@@ -7197,6 +7216,11 @@ lru-cache@^10.2.0:
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
+lru-cache@^11.0.0:
+ version "11.1.0"
+ resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.1.0.tgz#afafb060607108132dbc1cf8ae661afb69486117"
+ integrity sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==
+
lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -7302,6 +7326,13 @@ [email protected], minimatch@^9.0.1:
dependencies:
brace-expansion "^2.0.1"
+minimatch@^10.0.0:
+ version "10.0.1"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.1.tgz#ce0521856b453c86e25f2c4c0d03e6ff7ddc440b"
+ integrity sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==
+ dependencies:
+ brace-expansion "^2.0.1"
+
minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
@@ -7749,6 +7780,14 @@ path-scurry@^1.11.1:
lru-cache "^10.2.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
+path-scurry@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.0.tgz#9f052289f23ad8bf9397a2a0425e7b8615c58580"
+ integrity sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==
+ dependencies:
+ lru-cache "^11.0.0"
+ minipass "^7.1.2"
+
path-type@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
@@ -8157,12 +8196,20 @@ reusify@^1.0.4:
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
[email protected], [email protected], rimraf@^3.0.0, rimraf@^3.0.2, rimraf@^5.0.10:
- version "5.0.10"
- resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.10.tgz#23b9843d3dc92db71f96e1a2ce92e39fd2a8221c"
- integrity sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==
[email protected], rimraf@^6.0.1:
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-6.0.1.tgz#ffb8ad8844dd60332ab15f52bc104bc3ed71ea4e"
+ integrity sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==
+ dependencies:
+ glob "^11.0.0"
+ package-json-from-dist "^1.0.0"
+
+rimraf@^3.0.0, rimraf@^3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
+ integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
dependencies:
- glob "^10.3.7"
+ glob "^7.1.3"
rollup@^4.34.8:
version "4.34.9"
| diff --git a/compiler/package.json b/compiler/package.json
index 282f707d4e1eb..e3c3ee8c7f341 100644
--- a/compiler/package.json
+++ b/compiler/package.json
@@ -37,7 +37,7 @@
"prettier": "^3.3.3",
"prettier-plugin-hermes-parser": "^0.26.0",
"prompt-promise": "^1.0.3",
+ "rimraf": "^6.0.1",
"to-fast-properties": "^2.0.0",
"tsup": "^8.4.0",
"typescript": "^5.4.3",
@@ -45,7 +45,6 @@
"yargs": "^17.7.2"
"resolutions": {
"@babel/types": "7.26.3"
"packageManager": "[email protected]"
diff --git a/compiler/yarn.lock b/compiler/yarn.lock
index e93f5fa78b9d1..be814741267b8 100644
--- a/compiler/yarn.lock
+++ b/compiler/yarn.lock
@@ -5274,7 +5274,7 @@ glob@^10.3.10:
path-scurry "^1.10.1"
+glob@^10.4.5:
version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
@@ -5286,6 +5286,18 @@ glob@^10.3.7, glob@^10.4.5:
package-json-from-dist "^1.0.0"
path-scurry "^1.11.1"
+glob@^11.0.0:
+ version "11.0.1"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.1.tgz#1c3aef9a59d680e611b53dcd24bb8639cef064d9"
+ foreground-child "^3.1.0"
+ minimatch "^10.0.0"
+ path-scurry "^2.0.0"
glob@^7.1.3, glob@^7.1.4, glob@^7.1.6:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
@@ -5782,6 +5794,13 @@ jackspeak@^3.1.2:
optionalDependencies:
"@pkgjs/parseargs" "^0.11.0"
+jackspeak@^4.0.1:
+ resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-4.1.0.tgz#c489c079f2b636dc4cbe9b0312a13ff1282e561b"
+ integrity sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw==
+ "@isaacs/cliui" "^8.0.2"
jest-changed-files@^28.1.3:
version "28.1.3"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-28.1.3.tgz#d9aeee6792be3686c47cb988a8eaf82ff4238831"
@@ -7197,6 +7216,11 @@ lru-cache@^10.2.0:
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
+lru-cache@^11.0.0:
+ version "11.1.0"
+ resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.1.0.tgz#afafb060607108132dbc1cf8ae661afb69486117"
+ integrity sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==
lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
@@ -7302,6 +7326,13 @@ [email protected], minimatch@^9.0.1:
brace-expansion "^2.0.1"
+minimatch@^10.0.0:
+ version "10.0.1"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.1.tgz#ce0521856b453c86e25f2c4c0d03e6ff7ddc440b"
+ integrity sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==
+ brace-expansion "^2.0.1"
minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
@@ -7749,6 +7780,14 @@ path-scurry@^1.11.1:
lru-cache "^10.2.0"
+path-scurry@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.0.tgz#9f052289f23ad8bf9397a2a0425e7b8615c58580"
+ integrity sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==
+ lru-cache "^11.0.0"
path-type@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
@@ -8157,12 +8196,20 @@ reusify@^1.0.4:
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
[email protected], [email protected], rimraf@^3.0.0, rimraf@^3.0.2, rimraf@^5.0.10:
- version "5.0.10"
- integrity sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==
[email protected], rimraf@^6.0.1:
+ integrity sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==
+ glob "^11.0.0"
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
+ integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
+ glob "^7.1.3"
rollup@^4.34.8:
version "4.34.9" | [
"- \"rimraf\": \"^5.0.10\",",
"- \"rimraf\": \"5.0.10\",",
"-glob@^10.3.7, glob@^10.4.5:",
"+ integrity sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==",
"+ jackspeak \"^4.0.1\"",
"+ version \"4.1.0\"",
"- resolved \"https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.10.tgz#23b9843d3dc92db71f96e1a2ce92e39fd2a8221c\"",
"+ version \"6.0.1\"",
"+ resolved \"https://registry.yarnpkg.com/rimraf/-/rimraf-6.0.1.tgz#ffb8ad8844dd60332ab15f52bc104bc3ed71ea4e\"",
"+rimraf@^3.0.0, rimraf@^3.0.2:",
"- glob \"^10.3.7\""
] | [
8,
17,
29,
41,
44,
58,
114,
117,
118,
124,
129
] | {
"additions": 54,
"author": "poteto",
"deletions": 8,
"html_url": "https://github.com/facebook/react/pull/32868",
"issue_id": 32868,
"merged_at": "2025-04-14T19:15:14Z",
"omission_probability": 0.1,
"pr_number": 32868,
"repo": "facebook/react",
"title": "[compiler] Update rimraf",
"total_changes": 62
} |
225 | diff --git a/.nvmrc b/.nvmrc
index ef33d6510196d..5f53e875de687 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-v18.20.1
+v20.19.0
diff --git a/fixtures/flight-esm/.nvmrc b/fixtures/flight-esm/.nvmrc
index 3f430af82b3df..5f53e875de687 100644
--- a/fixtures/flight-esm/.nvmrc
+++ b/fixtures/flight-esm/.nvmrc
@@ -1 +1 @@
-v18
+v20.19.0
diff --git a/fixtures/flight/.nvmrc b/fixtures/flight/.nvmrc
index 3f430af82b3df..5f53e875de687 100644
--- a/fixtures/flight/.nvmrc
+++ b/fixtures/flight/.nvmrc
@@ -1 +1 @@
-v18
+v20.19.0
diff --git a/fixtures/flight/yarn.lock b/fixtures/flight/yarn.lock
index 000e591333de7..9c257161271b5 100644
--- a/fixtures/flight/yarn.lock
+++ b/fixtures/flight/yarn.lock
@@ -3952,20 +3952,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
-caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000888, caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001373:
- version "1.0.30001457"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001457.tgz"
- integrity sha512-SDIV6bgE1aVbK6XyxdURbUE89zY7+k1BBBaOwYwkNCglXlel/E7mELiHC64HQ+W0xSKlqWhV9Wh7iHxUjMs4fA==
-
-caniuse-lite@^1.0.30001503:
- version "1.0.30001505"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001505.tgz#10a343e49d31cbbfdae298ef73cb0a9f46670dc5"
- integrity sha512-jaAOR5zVtxHfL0NjZyflVTtXm3D3J9P15zSJ7HmQF8dSKGA6tqzQq+0ZI3xkjyQj46I4/M0K2GbMpcAFOcbr3A==
-
-caniuse-lite@^1.0.30001646:
- version "1.0.30001651"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz#52de59529e8b02b1aedcaaf5c05d9e23c0c28138"
- integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==
+caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000888, caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001373, caniuse-lite@^1.0.30001503, caniuse-lite@^1.0.30001646:
+ version "1.0.30001713"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001713.tgz"
+ integrity sha512-wCIWIg+A4Xr7NfhTuHdX+/FKh3+Op3LBbSp2N5Pfx6T/LhdQy3GTyoTg48BReaW/MyMNZAkTadsBtai3ldWK0Q==
canvas@^3.1.0:
version "3.1.0"
@@ -8660,7 +8650,16 @@ string-length@^5.0.1:
char-regex "^2.0.0"
strip-ansi "^7.0.1"
-"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
+"string-width-cjs@npm:string-width@^4.2.0":
+ version "4.2.3"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
+ integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
+ dependencies:
+ emoji-regex "^8.0.0"
+ is-fullwidth-code-point "^3.0.0"
+ strip-ansi "^6.0.1"
+
+string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -8731,7 +8730,14 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"
-"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
+"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
+ integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
+ dependencies:
+ ansi-regex "^5.0.1"
+
+strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -9446,7 +9452,16 @@ wordwrap@~1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
-"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
+"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
+ integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
+ dependencies:
+ ansi-styles "^4.0.0"
+ string-width "^4.1.0"
+ strip-ansi "^6.0.0"
+
+wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
| diff --git a/.nvmrc b/.nvmrc
index ef33d6510196d..5f53e875de687 100644
--- a/.nvmrc
+++ b/.nvmrc
diff --git a/fixtures/flight-esm/.nvmrc b/fixtures/flight-esm/.nvmrc
--- a/fixtures/flight-esm/.nvmrc
+++ b/fixtures/flight-esm/.nvmrc
diff --git a/fixtures/flight/.nvmrc b/fixtures/flight/.nvmrc
--- a/fixtures/flight/.nvmrc
+++ b/fixtures/flight/.nvmrc
diff --git a/fixtures/flight/yarn.lock b/fixtures/flight/yarn.lock
index 000e591333de7..9c257161271b5 100644
--- a/fixtures/flight/yarn.lock
+++ b/fixtures/flight/yarn.lock
@@ -3952,20 +3952,10 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
-caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000888, caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001373:
- version "1.0.30001457"
- resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001457.tgz"
-caniuse-lite@^1.0.30001503:
- version "1.0.30001505"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001505.tgz#10a343e49d31cbbfdae298ef73cb0a9f46670dc5"
- integrity sha512-jaAOR5zVtxHfL0NjZyflVTtXm3D3J9P15zSJ7HmQF8dSKGA6tqzQq+0ZI3xkjyQj46I4/M0K2GbMpcAFOcbr3A==
-caniuse-lite@^1.0.30001646:
- version "1.0.30001651"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz#52de59529e8b02b1aedcaaf5c05d9e23c0c28138"
- integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==
+caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000888, caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001373, caniuse-lite@^1.0.30001503, caniuse-lite@^1.0.30001646:
+ version "1.0.30001713"
+ resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001713.tgz"
+ integrity sha512-wCIWIg+A4Xr7NfhTuHdX+/FKh3+Op3LBbSp2N5Pfx6T/LhdQy3GTyoTg48BReaW/MyMNZAkTadsBtai3ldWK0Q==
canvas@^3.1.0:
version "3.1.0"
@@ -8660,7 +8650,16 @@ string-length@^5.0.1:
char-regex "^2.0.0"
strip-ansi "^7.0.1"
+"string-width-cjs@npm:string-width@^4.2.0":
+ version "4.2.3"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
+ integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
+ is-fullwidth-code-point "^3.0.0"
+ strip-ansi "^6.0.1"
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -8731,7 +8730,14 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"
-"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
+"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
+ integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
+ ansi-regex "^5.0.1"
+strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -9446,7 +9452,16 @@ wordwrap@~1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
-"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
+"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
+ version "7.0.0"
+ integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
+ ansi-styles "^4.0.0"
+ string-width "^4.1.0"
+ strip-ansi "^6.0.0"
+wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | [
"-v18.20.1",
"- integrity sha512-SDIV6bgE1aVbK6XyxdURbUE89zY7+k1BBBaOwYwkNCglXlel/E7mELiHC64HQ+W0xSKlqWhV9Wh7iHxUjMs4fA==",
"-\"string-width-cjs@npm:string-width@^4.2.0\", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:",
"+ emoji-regex \"^8.0.0\"",
"+string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:",
"+ resolved \"https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43\""
] | [
5,
32,
54,
60,
64,
91
] | {
"additions": 35,
"author": "poteto",
"deletions": 20,
"html_url": "https://github.com/facebook/react/pull/32855",
"issue_id": 32855,
"merged_at": "2025-04-14T16:52:02Z",
"omission_probability": 0.1,
"pr_number": 32855,
"repo": "facebook/react",
"title": "Upgrade node.js to 20 LTS",
"total_changes": 55
} |
226 | diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index aa53e06ee68c4..c3cbb8256fcb3 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -433,33 +433,21 @@ function updateForwardRef(
}
// The rest is a fork of updateFunctionComponent
- let nextChildren;
- let hasId;
prepareToReadContext(workInProgress, renderLanes);
if (enableSchedulingProfiler) {
markComponentRenderStarted(workInProgress);
}
- if (__DEV__) {
- nextChildren = renderWithHooks(
- current,
- workInProgress,
- render,
- propsWithoutRef,
- ref,
- renderLanes,
- );
- hasId = checkDidRenderIdHook();
- } else {
- nextChildren = renderWithHooks(
- current,
- workInProgress,
- render,
- propsWithoutRef,
- ref,
- renderLanes,
- );
- hasId = checkDidRenderIdHook();
- }
+
+ const nextChildren = renderWithHooks(
+ current,
+ workInProgress,
+ render,
+ propsWithoutRef,
+ ref,
+ renderLanes,
+ );
+ const hasId = checkDidRenderIdHook();
+
if (enableSchedulingProfiler) {
markComponentRenderStopped();
}
| diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index aa53e06ee68c4..c3cbb8256fcb3 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -433,33 +433,21 @@ function updateForwardRef(
// The rest is a fork of updateFunctionComponent
- let nextChildren;
- let hasId;
prepareToReadContext(workInProgress, renderLanes);
markComponentRenderStarted(workInProgress);
- if (__DEV__) {
- } else {
- }
+ const nextChildren = renderWithHooks(
+ current,
+ workInProgress,
+ render,
+ propsWithoutRef,
+ ref,
+ renderLanes,
markComponentRenderStopped(); | [
"+ );",
"+ const hasId = checkDidRenderIdHook();"
] | [
43,
44
] | {
"additions": 11,
"author": "captbaritone",
"deletions": 23,
"html_url": "https://github.com/facebook/react/pull/32810",
"issue_id": 32810,
"merged_at": "2025-04-11T21:39:36Z",
"omission_probability": 0.1,
"pr_number": 32810,
"repo": "facebook/react",
"title": "Remove redundant __DEV__ condition",
"total_changes": 34
} |
227 | diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index dd71c0146952d..b8e753dc03514 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -203,7 +203,6 @@ import {
pushFallbackTreeSuspenseHandler,
pushOffscreenSuspenseHandler,
reuseSuspenseHandlerOnStack,
- popSuspenseHandler,
} from './ReactFiberSuspenseContext';
import {
pushHiddenContext,
@@ -245,7 +244,7 @@ import {
claimHydratableSingleton,
tryToClaimNextHydratableInstance,
tryToClaimNextHydratableTextInstance,
- tryToClaimNextHydratableSuspenseInstance,
+ claimNextHydratableSuspenseInstance,
warnIfHydrating,
queueHydrationError,
} from './ReactFiberHydrationContext';
@@ -2151,24 +2150,14 @@ function updateSuspenseComponent(
} else {
pushFallbackTreeSuspenseHandler(workInProgress);
}
- tryToClaimNextHydratableSuspenseInstance(workInProgress);
- // This could've been a dehydrated suspense component.
- const suspenseState: null | SuspenseState = workInProgress.memoizedState;
- if (suspenseState !== null) {
- const dehydrated = suspenseState.dehydrated;
- if (dehydrated !== null) {
- return mountDehydratedSuspenseComponent(
- workInProgress,
- dehydrated,
- renderLanes,
- );
- }
- }
- // If hydration didn't succeed, fall through to the normal Suspense path.
- // To avoid a stack mismatch we need to pop the Suspense handler that we
- // pushed above. This will become less awkward when move the hydration
- // logic to its own fiber.
- popSuspenseHandler(workInProgress);
+ // This throws if we fail to hydrate.
+ const dehydrated: SuspenseInstance =
+ claimNextHydratableSuspenseInstance(workInProgress);
+ return mountDehydratedSuspenseComponent(
+ workInProgress,
+ dehydrated,
+ renderLanes,
+ );
}
const nextPrimaryChildren = nextProps.children;
diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.js b/packages/react-reconciler/src/ReactFiberHydrationContext.js
index c2507f32019e1..daa9c8ca7a52a 100644
--- a/packages/react-reconciler/src/ReactFiberHydrationContext.js
+++ b/packages/react-reconciler/src/ReactFiberHydrationContext.js
@@ -272,7 +272,10 @@ function tryHydrateText(fiber: Fiber, nextInstance: any) {
return false;
}
-function tryHydrateSuspense(fiber: Fiber, nextInstance: any) {
+function tryHydrateSuspense(
+ fiber: Fiber,
+ nextInstance: any,
+): null | SuspenseInstance {
// fiber is a SuspenseComponent Fiber
const suspenseInstance = canHydrateSuspenseInstance(
nextInstance,
@@ -298,9 +301,8 @@ function tryHydrateSuspense(fiber: Fiber, nextInstance: any) {
// While a Suspense Instance does have children, we won't step into
// it during the first pass. Instead, we'll reenter it later.
nextHydratableInstance = null;
- return true;
}
- return false;
+ return suspenseInstance;
}
export const HydrationMismatchException: mixed = new Error(
@@ -423,15 +425,16 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
}
}
-function tryToClaimNextHydratableSuspenseInstance(fiber: Fiber): void {
- if (!isHydrating) {
- return;
- }
+function claimNextHydratableSuspenseInstance(fiber: Fiber): SuspenseInstance {
const nextInstance = nextHydratableInstance;
- if (!nextInstance || !tryHydrateSuspense(fiber, nextInstance)) {
+ const suspenseInstance = nextInstance
+ ? tryHydrateSuspense(fiber, nextInstance)
+ : null;
+ if (suspenseInstance === null) {
warnNonHydratedInstance(fiber, nextInstance);
- throwOnHydrationMismatch(fiber);
+ throw throwOnHydrationMismatch(fiber);
}
+ return suspenseInstance;
}
export function tryToClaimNextHydratableFormMarkerInstance(
@@ -790,7 +793,7 @@ export {
claimHydratableSingleton,
tryToClaimNextHydratableInstance,
tryToClaimNextHydratableTextInstance,
- tryToClaimNextHydratableSuspenseInstance,
+ claimNextHydratableSuspenseInstance,
prepareToHydrateHostInstance,
prepareToHydrateHostTextInstance,
prepareToHydrateHostSuspenseInstance,
| diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index dd71c0146952d..b8e753dc03514 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -203,7 +203,6 @@ import {
pushFallbackTreeSuspenseHandler,
pushOffscreenSuspenseHandler,
reuseSuspenseHandlerOnStack,
- popSuspenseHandler,
} from './ReactFiberSuspenseContext';
import {
pushHiddenContext,
@@ -245,7 +244,7 @@ import {
warnIfHydrating,
queueHydrationError,
} from './ReactFiberHydrationContext';
@@ -2151,24 +2150,14 @@ function updateSuspenseComponent(
} else {
pushFallbackTreeSuspenseHandler(workInProgress);
}
- tryToClaimNextHydratableSuspenseInstance(workInProgress);
- // This could've been a dehydrated suspense component.
- const suspenseState: null | SuspenseState = workInProgress.memoizedState;
- if (suspenseState !== null) {
- const dehydrated = suspenseState.dehydrated;
- if (dehydrated !== null) {
- return mountDehydratedSuspenseComponent(
- workInProgress,
- dehydrated,
- renderLanes,
- );
- }
- // If hydration didn't succeed, fall through to the normal Suspense path.
- // To avoid a stack mismatch we need to pop the Suspense handler that we
- // pushed above. This will become less awkward when move the hydration
- // logic to its own fiber.
- popSuspenseHandler(workInProgress);
+ // This throws if we fail to hydrate.
+ const dehydrated: SuspenseInstance =
+ workInProgress,
+ dehydrated,
+ renderLanes,
+ );
}
const nextPrimaryChildren = nextProps.children;
diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.js b/packages/react-reconciler/src/ReactFiberHydrationContext.js
index c2507f32019e1..daa9c8ca7a52a 100644
--- a/packages/react-reconciler/src/ReactFiberHydrationContext.js
+++ b/packages/react-reconciler/src/ReactFiberHydrationContext.js
@@ -272,7 +272,10 @@ function tryHydrateText(fiber: Fiber, nextInstance: any) {
return false;
-function tryHydrateSuspense(fiber: Fiber, nextInstance: any) {
+function tryHydrateSuspense(
+ nextInstance: any,
// fiber is a SuspenseComponent Fiber
const suspenseInstance = canHydrateSuspenseInstance(
nextInstance,
@@ -298,9 +301,8 @@ function tryHydrateSuspense(fiber: Fiber, nextInstance: any) {
// While a Suspense Instance does have children, we won't step into
// it during the first pass. Instead, we'll reenter it later.
nextHydratableInstance = null;
- return true;
- return false;
export const HydrationMismatchException: mixed = new Error(
@@ -423,15 +425,16 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
-function tryToClaimNextHydratableSuspenseInstance(fiber: Fiber): void {
- if (!isHydrating) {
- return;
- }
+function claimNextHydratableSuspenseInstance(fiber: Fiber): SuspenseInstance {
const nextInstance = nextHydratableInstance;
- if (!nextInstance || !tryHydrateSuspense(fiber, nextInstance)) {
+ const suspenseInstance = nextInstance
+ ? tryHydrateSuspense(fiber, nextInstance)
+ : null;
+ if (suspenseInstance === null) {
warnNonHydratedInstance(fiber, nextInstance);
- throwOnHydrationMismatch(fiber);
+ throw throwOnHydrationMismatch(fiber);
export function tryToClaimNextHydratableFormMarkerInstance(
@@ -790,7 +793,7 @@ export {
prepareToHydrateHostInstance,
prepareToHydrateHostTextInstance,
prepareToHydrateHostSuspenseInstance, | [
"- }",
"+ claimNextHydratableSuspenseInstance(workInProgress);",
"+ return mountDehydratedSuspenseComponent(",
"+ fiber: Fiber,",
"+): null | SuspenseInstance {"
] | [
37,
45,
46,
64,
66
] | {
"additions": 22,
"author": "sebmarkbage",
"deletions": 30,
"html_url": "https://github.com/facebook/react/pull/32851",
"issue_id": 32851,
"merged_at": "2025-04-11T14:52:23Z",
"omission_probability": 0.1,
"pr_number": 32851,
"repo": "facebook/react",
"title": "Try not. Do... or do not. Hydrate Suspense Boundaries.",
"total_changes": 52
} |
228 | diff --git a/packages/react-reconciler/src/ReactFiberApplyGesture.js b/packages/react-reconciler/src/ReactFiberApplyGesture.js
index c4d4800195a77..1fa34e4957f84 100644
--- a/packages/react-reconciler/src/ReactFiberApplyGesture.js
+++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js
@@ -631,6 +631,12 @@ function recursivelyInsertClonesFromExistingTree(
const viewTransitionState: ViewTransitionState = child.stateNode;
// TODO: If this was already cloned by a previous pass we can reuse those clones.
viewTransitionState.clones = null;
+ // "Existing" view transitions are in subtrees that didn't update so
+ // this is a "current". We normally clear this upon rerendering
+ // but we use this flag to track changes from layout in the commit.
+ // So we need it to be cleared before we do that.
+ // TODO: Use some other temporary state to track this.
+ child.flags &= ~Update;
let nextPhase;
if (visitPhase === CLONE_EXIT) {
// This was an Enter of a ViewTransition. We now move onto unhiding the inner
diff --git a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
index 9e7e7e2ebae31..9a75195915d53 100644
--- a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
+++ b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
@@ -510,6 +510,12 @@ export function commitNestedViewTransitions(changedParent: Fiber): void {
props.default,
props.update,
);
+ // "Nested" view transitions are in subtrees that didn't update so
+ // this is a "current". We normally clear this upon rerendering
+ // but we use this flag to track changes from layout in the commit.
+ // So we need it to be cleared before we do that.
+ // TODO: Use some other temporary state to track this.
+ child.flags &= ~Update;
if (className !== 'none') {
applyViewTransitionToHostInstances(
child.child,
| diff --git a/packages/react-reconciler/src/ReactFiberApplyGesture.js b/packages/react-reconciler/src/ReactFiberApplyGesture.js
index c4d4800195a77..1fa34e4957f84 100644
--- a/packages/react-reconciler/src/ReactFiberApplyGesture.js
+++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js
@@ -631,6 +631,12 @@ function recursivelyInsertClonesFromExistingTree(
const viewTransitionState: ViewTransitionState = child.stateNode;
// TODO: If this was already cloned by a previous pass we can reuse those clones.
viewTransitionState.clones = null;
+ // "Existing" view transitions are in subtrees that didn't update so
+ // this is a "current". We normally clear this upon rerendering
+ // but we use this flag to track changes from layout in the commit.
+ // So we need it to be cleared before we do that.
+ // TODO: Use some other temporary state to track this.
+ child.flags &= ~Update;
let nextPhase;
if (visitPhase === CLONE_EXIT) {
// This was an Enter of a ViewTransition. We now move onto unhiding the inner
diff --git a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
index 9e7e7e2ebae31..9a75195915d53 100644
--- a/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
+++ b/packages/react-reconciler/src/ReactFiberCommitViewTransitions.js
@@ -510,6 +510,12 @@ export function commitNestedViewTransitions(changedParent: Fiber): void {
props.default,
props.update,
);
+ // "Nested" view transitions are in subtrees that didn't update so
+ // this is a "current". We normally clear this upon rerendering
+ // but we use this flag to track changes from layout in the commit.
+ // So we need it to be cleared before we do that.
+ // TODO: Use some other temporary state to track this.
if (className !== 'none') {
applyViewTransitionToHostInstances(
child.child, | [
"+ child.flags &= ~Update;"
] | [
30
] | {
"additions": 12,
"author": "sebmarkbage",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32849",
"issue_id": 32849,
"merged_at": "2025-04-11T14:54:06Z",
"omission_probability": 0.1,
"pr_number": 32849,
"repo": "facebook/react",
"title": "Clear Update flag for unchanged trees in the beginning of the commit phase",
"total_changes": 12
} |
229 | diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
index 40acf5b3c6111..0022820465a4b 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
@@ -4087,6 +4087,28 @@ export function writePlaceholder(
return writeChunkAndReturn(destination, placeholder2);
}
+// Activity boundaries are encoded as comments.
+const startActivityBoundary = stringToPrecomputedChunk('<!--&-->');
+const endActivityBoundary = stringToPrecomputedChunk('<!--/&-->');
+
+export function pushStartActivityBoundary(
+ target: Array<Chunk | PrecomputedChunk>,
+ renderState: RenderState,
+): void {
+ target.push(startActivityBoundary);
+}
+
+export function pushEndActivityBoundary(
+ target: Array<Chunk | PrecomputedChunk>,
+ renderState: RenderState,
+ preambleState: null | PreambleState,
+): void {
+ if (preambleState) {
+ pushPreambleContribution(target, preambleState);
+ }
+ target.push(endActivityBoundary);
+}
+
// Suspense boundaries are encoded as comments.
const startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
const startPendingSuspenseBoundary1 = stringToPrecomputedChunk(
@@ -4225,6 +4247,23 @@ export function writeEndClientRenderedSuspenseBoundary(
const boundaryPreambleContributionChunkStart = stringToPrecomputedChunk('<!--');
const boundaryPreambleContributionChunkEnd = stringToPrecomputedChunk('-->');
+function pushPreambleContribution(
+ target: Array<Chunk | PrecomputedChunk>,
+ preambleState: PreambleState,
+) {
+ // Same as writePreambleContribution but for the render phase.
+ const contribution = preambleState.contribution;
+ if (contribution !== NoContribution) {
+ target.push(
+ boundaryPreambleContributionChunkStart,
+ // This is a number type so we can do the fast path without coercion checking
+ // eslint-disable-next-line react-internal/safe-string-coercion
+ stringToChunk('' + contribution),
+ boundaryPreambleContributionChunkEnd,
+ );
+ }
+}
+
function writePreambleContribution(
destination: Destination,
preambleState: PreambleState,
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
index ecd12d2ac5fd1..78615d8063248 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
@@ -20,6 +20,8 @@ import {
createRenderState as createRenderStateImpl,
pushTextInstance as pushTextInstanceImpl,
pushSegmentFinale as pushSegmentFinaleImpl,
+ pushStartActivityBoundary as pushStartActivityBoundaryImpl,
+ pushEndActivityBoundary as pushEndActivityBoundaryImpl,
writeStartCompletedSuspenseBoundary as writeStartCompletedSuspenseBoundaryImpl,
writeStartClientRenderedSuspenseBoundary as writeStartClientRenderedSuspenseBoundaryImpl,
writeEndCompletedSuspenseBoundary as writeEndCompletedSuspenseBoundaryImpl,
@@ -207,6 +209,29 @@ export function pushSegmentFinale(
}
}
+export function pushStartActivityBoundary(
+ target: Array<Chunk | PrecomputedChunk>,
+ renderState: RenderState,
+): void {
+ if (renderState.generateStaticMarkup) {
+ // A completed boundary is done and doesn't need a representation in the HTML
+ // if we're not going to be hydrating it.
+ return;
+ }
+ pushStartActivityBoundaryImpl(target, renderState);
+}
+
+export function pushEndActivityBoundary(
+ target: Array<Chunk | PrecomputedChunk>,
+ renderState: RenderState,
+ preambleState: null | PreambleState,
+): void {
+ if (renderState.generateStaticMarkup) {
+ return;
+ }
+ pushEndActivityBoundaryImpl(target, renderState, preambleState);
+}
+
export function writeStartCompletedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 94d672cef42a6..86a0ceb42e84a 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -3669,7 +3669,7 @@ describe('ReactDOMServerPartialHydration', () => {
});
// @gate enableActivity
- it('a visible Activity component acts like a fragment', async () => {
+ it('a visible Activity component is surrounded by comment markers', async () => {
const ref = React.createRef();
function App() {
@@ -3690,9 +3690,11 @@ describe('ReactDOMServerPartialHydration', () => {
// pure indirection.
expect(container).toMatchInlineSnapshot(`
<div>
+ <!--&-->
<span>
Child
</span>
+ <!--/&-->
</div>
`);
@@ -3739,6 +3741,8 @@ describe('ReactDOMServerPartialHydration', () => {
<span>
Visible
</span>
+ <!--&-->
+ <!--/&-->
</div>
`);
@@ -3760,6 +3764,8 @@ describe('ReactDOMServerPartialHydration', () => {
<span>
Visible
</span>
+ <!--&-->
+ <!--/&-->
<span
style="display: none;"
>
diff --git a/packages/react-markup/src/ReactFizzConfigMarkup.js b/packages/react-markup/src/ReactFizzConfigMarkup.js
index 358a08e7c54b8..7e95c0ce39042 100644
--- a/packages/react-markup/src/ReactFizzConfigMarkup.js
+++ b/packages/react-markup/src/ReactFizzConfigMarkup.js
@@ -151,6 +151,23 @@ export function pushSegmentFinale(
return;
}
+export function pushStartActivityBoundary(
+ target: Array<Chunk | PrecomputedChunk>,
+ renderState: RenderState,
+): void {
+ // Markup doesn't have any instructions.
+ return;
+}
+
+export function pushEndActivityBoundary(
+ target: Array<Chunk | PrecomputedChunk>,
+ renderState: RenderState,
+ preambleState: null | PreambleState,
+): void {
+ // Markup doesn't have any instructions.
+ return;
+}
+
export function writeStartCompletedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
@@ -158,6 +175,7 @@ export function writeStartCompletedSuspenseBoundary(
// Markup doesn't have any instructions.
return true;
}
+
export function writeStartClientRenderedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
diff --git a/packages/react-noop-renderer/src/ReactNoopServer.js b/packages/react-noop-renderer/src/ReactNoopServer.js
index 964cf4509df6d..5af393f3317eb 100644
--- a/packages/react-noop-renderer/src/ReactNoopServer.js
+++ b/packages/react-noop-renderer/src/ReactNoopServer.js
@@ -30,6 +30,10 @@ type TextInstance = {
hidden: boolean,
};
+type ActivityInstance = {
+ children: Array<Instance | TextInstance | SuspenseInstance>,
+};
+
type SuspenseInstance = {
state: 'pending' | 'complete' | 'client-render',
children: Array<Instance | TextInstance | SuspenseInstance>,
@@ -164,44 +168,74 @@ const ReactNoopServer = ReactFizzServer({
});
},
+ pushStartActivityBoundary(
+ target: Array<Uint8Array>,
+ renderState: RenderState,
+ ): void {
+ const activityInstance: ActivityInstance = {
+ children: [],
+ };
+ target.push(Buffer.from(JSON.stringify(activityInstance), 'utf8'));
+ },
+
+ pushEndActivityBoundary(
+ target: Array<Uint8Array>,
+ renderState: RenderState,
+ preambleState: null | PreambleState,
+ ): void {
+ target.push(POP);
+ },
+
writeStartCompletedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- suspenseInstance: SuspenseInstance,
): boolean {
- suspenseInstance.state = 'complete';
+ const suspenseInstance: SuspenseInstance = {
+ state: 'complete',
+ children: [],
+ };
const parent = destination.stack[destination.stack.length - 1];
parent.children.push(suspenseInstance);
destination.stack.push(suspenseInstance);
+ return true;
},
writeStartPendingSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- suspenseInstance: SuspenseInstance,
): boolean {
- suspenseInstance.state = 'pending';
+ const suspenseInstance: SuspenseInstance = {
+ state: 'pending',
+ children: [],
+ };
const parent = destination.stack[destination.stack.length - 1];
parent.children.push(suspenseInstance);
destination.stack.push(suspenseInstance);
+ return true;
},
writeStartClientRenderedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- suspenseInstance: SuspenseInstance,
): boolean {
- suspenseInstance.state = 'client-render';
+ const suspenseInstance: SuspenseInstance = {
+ state: 'client-render',
+ children: [],
+ };
const parent = destination.stack[destination.stack.length - 1];
parent.children.push(suspenseInstance);
destination.stack.push(suspenseInstance);
+ return true;
},
writeEndCompletedSuspenseBoundary(destination: Destination): boolean {
destination.stack.pop();
+ return true;
},
writeEndPendingSuspenseBoundary(destination: Destination): boolean {
destination.stack.pop();
+ return true;
},
writeEndClientRenderedSuspenseBoundary(destination: Destination): boolean {
destination.stack.pop();
+ return true;
},
writeStartSegment(
@@ -218,9 +252,11 @@ const ReactNoopServer = ReactFizzServer({
throw new Error('Segments are only expected at the root of the stack.');
}
destination.stack.push(segment);
+ return true;
},
writeEndSegment(destination: Destination, formatContext: null): boolean {
destination.stack.pop();
+ return true;
},
writeCompletedSegmentInstruction(
@@ -241,6 +277,7 @@ const ReactNoopServer = ReactFizzServer({
0,
...segment.children,
);
+ return true;
},
writeCompletedBoundaryInstruction(
@@ -255,6 +292,7 @@ const ReactNoopServer = ReactFizzServer({
}
boundary.children = segment.children;
boundary.state = 'complete';
+ return true;
},
writeClientRenderBoundaryInstruction(
@@ -263,6 +301,7 @@ const ReactNoopServer = ReactFizzServer({
boundary: SuspenseInstance,
): boolean {
boundary.status = 'client-render';
+ return true;
},
writePreambleStart() {},
diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js
index daa77239bad41..b0580aa1a1744 100644
--- a/packages/react-server/src/ReactFizzServer.js
+++ b/packages/react-server/src/ReactFizzServer.js
@@ -51,6 +51,8 @@ import {
import {
writeCompletedRoot,
writePlaceholder,
+ pushStartActivityBoundary,
+ pushEndActivityBoundary,
writeStartCompletedSuspenseBoundary,
writeStartPendingSuspenseBoundary,
writeStartClientRenderedSuspenseBoundary,
@@ -2200,23 +2202,50 @@ function renderLazyComponent(
renderElement(request, task, keyPath, Component, resolvedProps, ref);
}
-function renderOffscreen(
+function renderActivity(
request: Request,
task: Task,
keyPath: KeyNode,
props: Object,
): void {
- const mode: ?OffscreenMode = (props.mode: any);
- if (mode === 'hidden') {
- // A hidden Offscreen boundary is not server rendered. Prerendering happens
- // on the client.
+ const segment = task.blockedSegment;
+ if (segment === null) {
+ // Replay
+ const mode: ?OffscreenMode = (props.mode: any);
+ if (mode === 'hidden') {
+ // A hidden Activity boundary is not server rendered. Prerendering happens
+ // on the client.
+ } else {
+ // A visible Activity boundary has its children rendered inside the boundary.
+ const prevKeyPath = task.keyPath;
+ task.keyPath = keyPath;
+ renderNode(request, task, props.children, -1);
+ task.keyPath = prevKeyPath;
+ }
} else {
- // A visible Offscreen boundary is treated exactly like a fragment: a
- // pure indirection.
- const prevKeyPath = task.keyPath;
- task.keyPath = keyPath;
- renderNodeDestructive(request, task, props.children, -1);
- task.keyPath = prevKeyPath;
+ // Render
+ // An Activity boundary is delimited so that we can hydrate it separately.
+ pushStartActivityBoundary(segment.chunks, request.renderState);
+ segment.lastPushedText = false;
+ const mode: ?OffscreenMode = (props.mode: any);
+ if (mode === 'hidden') {
+ // A hidden Activity boundary is not server rendered. Prerendering happens
+ // on the client.
+ } else {
+ // A visible Activity boundary has its children rendered inside the boundary.
+ const prevKeyPath = task.keyPath;
+ task.keyPath = keyPath;
+ // We use the non-destructive form because if something suspends, we still
+ // need to pop back up and finish the end comment.
+ renderNode(request, task, props.children, -1);
+ task.keyPath = prevKeyPath;
+ }
+ pushEndActivityBoundary(
+ segment.chunks,
+ request.renderState,
+ task.blockedPreamble,
+ );
+ segment.lastPushedText = false;
}
}
@@ -2291,7 +2320,7 @@ function renderElement(
return;
}
case REACT_ACTIVITY_TYPE: {
- renderOffscreen(request, task, keyPath, props);
+ renderActivity(request, task, keyPath, props);
return;
}
case REACT_SUSPENSE_LIST_TYPE: {
diff --git a/packages/react-server/src/forks/ReactFizzConfig.custom.js b/packages/react-server/src/forks/ReactFizzConfig.custom.js
index d386d04e39819..ad33d1fc72bab 100644
--- a/packages/react-server/src/forks/ReactFizzConfig.custom.js
+++ b/packages/react-server/src/forks/ReactFizzConfig.custom.js
@@ -59,6 +59,8 @@ export const pushFormStateMarkerIsNotMatching =
$$$config.pushFormStateMarkerIsNotMatching;
export const writeCompletedRoot = $$$config.writeCompletedRoot;
export const writePlaceholder = $$$config.writePlaceholder;
+export const pushStartActivityBoundary = $$$config.pushStartActivityBoundary;
+export const pushEndActivityBoundary = $$$config.pushEndActivityBoundary;
export const writeStartCompletedSuspenseBoundary =
$$$config.writeStartCompletedSuspenseBoundary;
export const writeStartPendingSuspenseBoundary =
| diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
index 40acf5b3c6111..0022820465a4b 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
@@ -4087,6 +4087,28 @@ export function writePlaceholder(
return writeChunkAndReturn(destination, placeholder2);
+// Activity boundaries are encoded as comments.
+const startActivityBoundary = stringToPrecomputedChunk('<!--&-->');
+const endActivityBoundary = stringToPrecomputedChunk('<!--/&-->');
+ target.push(startActivityBoundary);
+ if (preambleState) {
+ pushPreambleContribution(target, preambleState);
+ target.push(endActivityBoundary);
// Suspense boundaries are encoded as comments.
const startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
const startPendingSuspenseBoundary1 = stringToPrecomputedChunk(
@@ -4225,6 +4247,23 @@ export function writeEndClientRenderedSuspenseBoundary(
const boundaryPreambleContributionChunkStart = stringToPrecomputedChunk('<!--');
const boundaryPreambleContributionChunkEnd = stringToPrecomputedChunk('-->');
+function pushPreambleContribution(
+ preambleState: PreambleState,
+) {
+ // Same as writePreambleContribution but for the render phase.
+ const contribution = preambleState.contribution;
+ if (contribution !== NoContribution) {
+ target.push(
+ boundaryPreambleContributionChunkStart,
+ // eslint-disable-next-line react-internal/safe-string-coercion
+ stringToChunk('' + contribution),
+ boundaryPreambleContributionChunkEnd,
function writePreambleContribution(
preambleState: PreambleState,
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
index ecd12d2ac5fd1..78615d8063248 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
@@ -20,6 +20,8 @@ import {
createRenderState as createRenderStateImpl,
pushTextInstance as pushTextInstanceImpl,
pushSegmentFinale as pushSegmentFinaleImpl,
+ pushStartActivityBoundary as pushStartActivityBoundaryImpl,
writeStartCompletedSuspenseBoundary as writeStartCompletedSuspenseBoundaryImpl,
writeStartClientRenderedSuspenseBoundary as writeStartClientRenderedSuspenseBoundaryImpl,
writeEndCompletedSuspenseBoundary as writeEndCompletedSuspenseBoundaryImpl,
@@ -207,6 +209,29 @@ export function pushSegmentFinale(
+ // A completed boundary is done and doesn't need a representation in the HTML
+ // if we're not going to be hydrating it.
+ pushStartActivityBoundaryImpl(target, renderState);
+ pushEndActivityBoundaryImpl(target, renderState, preambleState);
diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
index 94d672cef42a6..86a0ceb42e84a 100644
--- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
@@ -3669,7 +3669,7 @@ describe('ReactDOMServerPartialHydration', () => {
});
// @gate enableActivity
- it('a visible Activity component acts like a fragment', async () => {
+ it('a visible Activity component is surrounded by comment markers', async () => {
const ref = React.createRef();
function App() {
@@ -3690,9 +3690,11 @@ describe('ReactDOMServerPartialHydration', () => {
// pure indirection.
expect(container).toMatchInlineSnapshot(`
<div>
Child
@@ -3739,6 +3741,8 @@ describe('ReactDOMServerPartialHydration', () => {
@@ -3760,6 +3764,8 @@ describe('ReactDOMServerPartialHydration', () => {
<span
style="display: none;"
>
diff --git a/packages/react-markup/src/ReactFizzConfigMarkup.js b/packages/react-markup/src/ReactFizzConfigMarkup.js
index 358a08e7c54b8..7e95c0ce39042 100644
--- a/packages/react-markup/src/ReactFizzConfigMarkup.js
+++ b/packages/react-markup/src/ReactFizzConfigMarkup.js
@@ -151,6 +151,23 @@ export function pushSegmentFinale(
return;
@@ -158,6 +175,7 @@ export function writeStartCompletedSuspenseBoundary(
// Markup doesn't have any instructions.
return true;
export function writeStartClientRenderedSuspenseBoundary(
diff --git a/packages/react-noop-renderer/src/ReactNoopServer.js b/packages/react-noop-renderer/src/ReactNoopServer.js
index 964cf4509df6d..5af393f3317eb 100644
--- a/packages/react-noop-renderer/src/ReactNoopServer.js
+++ b/packages/react-noop-renderer/src/ReactNoopServer.js
@@ -30,6 +30,10 @@ type TextInstance = {
hidden: boolean,
};
+ children: Array<Instance | TextInstance | SuspenseInstance>,
+};
type SuspenseInstance = {
state: 'pending' | 'complete' | 'client-render',
children: Array<Instance | TextInstance | SuspenseInstance>,
@@ -164,44 +168,74 @@ const ReactNoopServer = ReactFizzServer({
});
+ pushStartActivityBoundary(
+ const activityInstance: ActivityInstance = {
+ pushEndActivityBoundary(
+ target.push(POP);
writeStartCompletedSuspenseBoundary(
- suspenseInstance.state = 'complete';
+ state: 'complete',
writeStartPendingSuspenseBoundary(
- suspenseInstance.state = 'pending';
+ state: 'pending',
writeStartClientRenderedSuspenseBoundary(
- suspenseInstance.state = 'client-render';
+ state: 'client-render',
writeEndCompletedSuspenseBoundary(destination: Destination): boolean {
writeEndPendingSuspenseBoundary(destination: Destination): boolean {
writeEndClientRenderedSuspenseBoundary(destination: Destination): boolean {
writeStartSegment(
@@ -218,9 +252,11 @@ const ReactNoopServer = ReactFizzServer({
throw new Error('Segments are only expected at the root of the stack.');
destination.stack.push(segment);
writeEndSegment(destination: Destination, formatContext: null): boolean {
writeCompletedSegmentInstruction(
@@ -241,6 +277,7 @@ const ReactNoopServer = ReactFizzServer({
0,
...segment.children,
);
writeCompletedBoundaryInstruction(
@@ -255,6 +292,7 @@ const ReactNoopServer = ReactFizzServer({
boundary.children = segment.children;
boundary.state = 'complete';
writeClientRenderBoundaryInstruction(
@@ -263,6 +301,7 @@ const ReactNoopServer = ReactFizzServer({
boundary: SuspenseInstance,
boundary.status = 'client-render';
writePreambleStart() {},
diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js
index daa77239bad41..b0580aa1a1744 100644
--- a/packages/react-server/src/ReactFizzServer.js
+++ b/packages/react-server/src/ReactFizzServer.js
@@ -51,6 +51,8 @@ import {
import {
writeCompletedRoot,
writePlaceholder,
+ pushStartActivityBoundary,
writeStartCompletedSuspenseBoundary,
writeStartPendingSuspenseBoundary,
writeStartClientRenderedSuspenseBoundary,
@@ -2200,23 +2202,50 @@ function renderLazyComponent(
renderElement(request, task, keyPath, Component, resolvedProps, ref);
+function renderActivity(
request: Request,
task: Task,
keyPath: KeyNode,
props: Object,
): void {
- const mode: ?OffscreenMode = (props.mode: any);
- if (mode === 'hidden') {
- // A hidden Offscreen boundary is not server rendered. Prerendering happens
- // on the client.
+ const segment = task.blockedSegment;
+ if (segment === null) {
+ // Replay
} else {
- // A visible Offscreen boundary is treated exactly like a fragment: a
- // pure indirection.
- const prevKeyPath = task.keyPath;
- task.keyPath = keyPath;
- renderNodeDestructive(request, task, props.children, -1);
- task.keyPath = prevKeyPath;
+ // Render
+ // An Activity boundary is delimited so that we can hydrate it separately.
+ pushStartActivityBoundary(segment.chunks, request.renderState);
+ // We use the non-destructive form because if something suspends, we still
+ // need to pop back up and finish the end comment.
+ pushEndActivityBoundary(
+ segment.chunks,
+ request.renderState,
+ task.blockedPreamble,
@@ -2291,7 +2320,7 @@ function renderElement(
case REACT_ACTIVITY_TYPE: {
- renderOffscreen(request, task, keyPath, props);
+ renderActivity(request, task, keyPath, props);
case REACT_SUSPENSE_LIST_TYPE: {
diff --git a/packages/react-server/src/forks/ReactFizzConfig.custom.js b/packages/react-server/src/forks/ReactFizzConfig.custom.js
index d386d04e39819..ad33d1fc72bab 100644
--- a/packages/react-server/src/forks/ReactFizzConfig.custom.js
+++ b/packages/react-server/src/forks/ReactFizzConfig.custom.js
@@ -59,6 +59,8 @@ export const pushFormStateMarkerIsNotMatching =
$$$config.pushFormStateMarkerIsNotMatching;
export const writeCompletedRoot = $$$config.writeCompletedRoot;
export const writePlaceholder = $$$config.writePlaceholder;
+export const pushStartActivityBoundary = $$$config.pushStartActivityBoundary;
+export const pushEndActivityBoundary = $$$config.pushEndActivityBoundary;
export const writeStartCompletedSuspenseBoundary =
$$$config.writeStartCompletedSuspenseBoundary;
export const writeStartPendingSuspenseBoundary = | [
"+ // This is a number type so we can do the fast path without coercion checking",
"+ pushEndActivityBoundary as pushEndActivityBoundaryImpl,",
"+type ActivityInstance = {",
"+ target.push(Buffer.from(JSON.stringify(activityInstance), 'utf8'));",
"+ preambleState: null | PreambleState,",
"+ pushEndActivityBoundary,",
"-function renderOffscreen("
] | [
46,
66,
187,
205,
211,
320,
328
] | {
"additions": 177,
"author": "sebmarkbage",
"deletions": 19,
"html_url": "https://github.com/facebook/react/pull/32834",
"issue_id": 32834,
"merged_at": "2025-04-09T14:59:53Z",
"omission_probability": 0.1,
"pr_number": 32834,
"repo": "facebook/react",
"title": "Emit Activity boundaries as comments in Fizz",
"total_changes": 196
} |
230 | diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 77771b5b19a69..2d29781dfee97 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -230,9 +230,9 @@ const SUSPENSE_START_DATA = '$';
const SUSPENSE_END_DATA = '/$';
const SUSPENSE_PENDING_START_DATA = '$?';
const SUSPENSE_FALLBACK_START_DATA = '$!';
-const PREAMBLE_CONTRIBUTION_HTML = 0b001;
-const PREAMBLE_CONTRIBUTION_BODY = 0b010;
-const PREAMBLE_CONTRIBUTION_HEAD = 0b100;
+const PREAMBLE_CONTRIBUTION_HTML = 'html';
+const PREAMBLE_CONTRIBUTION_BODY = 'body';
+const PREAMBLE_CONTRIBUTION_HEAD = 'head';
const FORM_STATE_IS_MATCHING = 'F!';
const FORM_STATE_IS_NOT_MATCHING = 'F';
@@ -1054,7 +1054,6 @@ export function clearSuspenseBoundary(
suspenseInstance: SuspenseInstance,
): void {
let node: Node = suspenseInstance;
- let possiblePreambleContribution: number = 0;
// Delete all nodes within this suspense boundary.
// There might be nested nodes so we need to keep track of how
// deep we are and only break out when we're back on top.
@@ -1065,36 +1064,6 @@ export function clearSuspenseBoundary(
if (nextNode && nextNode.nodeType === COMMENT_NODE) {
const data = ((nextNode: any).data: string);
if (data === SUSPENSE_END_DATA) {
- if (
- // represents 3 bits where at least one bit is set (1-7)
- possiblePreambleContribution > 0 &&
- possiblePreambleContribution < 8
- ) {
- const code = possiblePreambleContribution;
- // It's not normally possible to insert a comment immediately preceding Suspense boundary
- // closing comment marker so we can infer that if the comment preceding starts with "1" through "7"
- // then it is in fact a preamble contribution marker comment. We do this value test to avoid the case
- // where the Suspense boundary is empty and the preceding comment marker is the Suspense boundary
- // opening marker or the closing marker of an inner boundary. In those cases the first character won't
- // have the requisite value to be interpreted as a Preamble contribution
- const ownerDocument = parentInstance.ownerDocument;
- if (code & PREAMBLE_CONTRIBUTION_HTML) {
- const documentElement: Element =
- (ownerDocument.documentElement: any);
- releaseSingletonInstance(documentElement);
- }
- if (code & PREAMBLE_CONTRIBUTION_BODY) {
- const body: Element = (ownerDocument.body: any);
- releaseSingletonInstance(body);
- }
- if (code & PREAMBLE_CONTRIBUTION_HEAD) {
- const head: Element = (ownerDocument.head: any);
- releaseSingletonInstance(head);
- // We need to clear the head because this is the only singleton that can have children that
- // were part of this boundary but are not inside this boundary.
- clearHead(head);
- }
- }
if (depth === 0) {
parentInstance.removeChild(nextNode);
// Retry if any event replaying was blocked on this.
@@ -1109,11 +1078,24 @@ export function clearSuspenseBoundary(
data === SUSPENSE_FALLBACK_START_DATA
) {
depth++;
- } else {
- possiblePreambleContribution = data.charCodeAt(0) - 48;
+ } else if (data === PREAMBLE_CONTRIBUTION_HTML) {
+ // If a preamble contribution marker is found within the bounds of this boundary,
+ // then it contributed to the html tag and we need to reset it.
+ const ownerDocument = parentInstance.ownerDocument;
+ const documentElement: Element = (ownerDocument.documentElement: any);
+ releaseSingletonInstance(documentElement);
+ } else if (data === PREAMBLE_CONTRIBUTION_HEAD) {
+ const ownerDocument = parentInstance.ownerDocument;
+ const head: Element = (ownerDocument.head: any);
+ releaseSingletonInstance(head);
+ // We need to clear the head because this is the only singleton that can have children that
+ // were part of this boundary but are not inside this boundary.
+ clearHead(head);
+ } else if (data === PREAMBLE_CONTRIBUTION_BODY) {
+ const ownerDocument = parentInstance.ownerDocument;
+ const body: Element = (ownerDocument.body: any);
+ releaseSingletonInstance(body);
}
- } else {
- possiblePreambleContribution = 0;
}
// $FlowFixMe[incompatible-type] we bail out when we get a null
node = nextNode;
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
index 0022820465a4b..abdbf1a4f1c24 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
@@ -692,23 +692,16 @@ export function completeResumableState(resumableState: ResumableState): void {
resumableState.bootstrapModules = undefined;
}
-const NoContribution /* */ = 0b000;
-const HTMLContribution /* */ = 0b001;
-const BodyContribution /* */ = 0b010;
-const HeadContribution /* */ = 0b100;
-
export type PreambleState = {
htmlChunks: null | Array<Chunk | PrecomputedChunk>,
headChunks: null | Array<Chunk | PrecomputedChunk>,
bodyChunks: null | Array<Chunk | PrecomputedChunk>,
- contribution: number,
};
export function createPreambleState(): PreambleState {
return {
htmlChunks: null,
headChunks: null,
bodyChunks: null,
- contribution: NoContribution,
};
}
@@ -3279,6 +3272,12 @@ function pushTitleImpl(
return null;
}
+// These are used by the client if we clear a boundary and we find these, then we
+// also clear the singleton as well.
+const headPreambleContributionChunk = stringToPrecomputedChunk('<!--head-->');
+const bodyPreambleContributionChunk = stringToPrecomputedChunk('<!--body-->');
+const htmlPreambleContributionChunk = stringToPrecomputedChunk('<!--html-->');
+
function pushStartHead(
target: Array<Chunk | PrecomputedChunk>,
props: Object,
@@ -3293,6 +3292,12 @@ function pushStartHead(
if (preamble.headChunks) {
throw new Error(`The ${'`<head>`'} tag may only be rendered once.`);
}
+
+ // Insert a marker in the body where the contribution to the head was in case we need to clear it.
+ if (preambleState !== null) {
+ target.push(headPreambleContributionChunk);
+ }
+
preamble.headChunks = [];
return pushStartSingletonElement(preamble.headChunks, props, 'head');
} else {
@@ -3317,6 +3322,11 @@ function pushStartBody(
throw new Error(`The ${'`<body>`'} tag may only be rendered once.`);
}
+ // Insert a marker in the body where the contribution to the body tag was in case we need to clear it.
+ if (preambleState !== null) {
+ target.push(bodyPreambleContributionChunk);
+ }
+
preamble.bodyChunks = [];
return pushStartSingletonElement(preamble.bodyChunks, props, 'body');
} else {
@@ -3341,6 +3351,11 @@ function pushStartHtml(
throw new Error(`The ${'`<html>`'} tag may only be rendered once.`);
}
+ // Insert a marker in the body where the contribution to the head was in case we need to clear it.
+ if (preambleState !== null) {
+ target.push(htmlPreambleContributionChunk);
+ }
+
preamble.htmlChunks = [DOCTYPE];
return pushStartSingletonElement(preamble.htmlChunks, props, 'html');
} else {
@@ -4013,15 +4028,12 @@ export function hoistPreambleState(
const rootPreamble = renderState.preamble;
if (rootPreamble.htmlChunks === null && preambleState.htmlChunks) {
rootPreamble.htmlChunks = preambleState.htmlChunks;
- preambleState.contribution |= HTMLContribution;
}
if (rootPreamble.headChunks === null && preambleState.headChunks) {
rootPreamble.headChunks = preambleState.headChunks;
- preambleState.contribution |= HeadContribution;
}
if (rootPreamble.bodyChunks === null && preambleState.bodyChunks) {
rootPreamble.bodyChunks = preambleState.bodyChunks;
- preambleState.contribution |= BodyContribution;
}
}
@@ -4101,11 +4113,7 @@ export function pushStartActivityBoundary(
export function pushEndActivityBoundary(
target: Array<Chunk | PrecomputedChunk>,
renderState: RenderState,
- preambleState: null | PreambleState,
): void {
- if (preambleState) {
- pushPreambleContribution(target, preambleState);
- }
target.push(endActivityBoundary);
}
@@ -4220,11 +4228,7 @@ export function writeStartClientRenderedSuspenseBoundary(
export function writeEndCompletedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- preambleState: null | PreambleState,
): boolean {
- if (preambleState) {
- writePreambleContribution(destination, preambleState);
- }
return writeChunkAndReturn(destination, endSuspenseBoundary);
}
export function writeEndPendingSuspenseBoundary(
@@ -4236,48 +4240,10 @@ export function writeEndPendingSuspenseBoundary(
export function writeEndClientRenderedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- preambleState: null | PreambleState,
): boolean {
- if (preambleState) {
- writePreambleContribution(destination, preambleState);
- }
return writeChunkAndReturn(destination, endSuspenseBoundary);
}
-const boundaryPreambleContributionChunkStart = stringToPrecomputedChunk('<!--');
-const boundaryPreambleContributionChunkEnd = stringToPrecomputedChunk('-->');
-
-function pushPreambleContribution(
- target: Array<Chunk | PrecomputedChunk>,
- preambleState: PreambleState,
-) {
- // Same as writePreambleContribution but for the render phase.
- const contribution = preambleState.contribution;
- if (contribution !== NoContribution) {
- target.push(
- boundaryPreambleContributionChunkStart,
- // This is a number type so we can do the fast path without coercion checking
- // eslint-disable-next-line react-internal/safe-string-coercion
- stringToChunk('' + contribution),
- boundaryPreambleContributionChunkEnd,
- );
- }
-}
-
-function writePreambleContribution(
- destination: Destination,
- preambleState: PreambleState,
-) {
- const contribution = preambleState.contribution;
- if (contribution !== NoContribution) {
- writeChunk(destination, boundaryPreambleContributionChunkStart);
- // This is a number type so we can do the fast path without coercion checking
- // eslint-disable-next-line react-internal/safe-string-coercion
- writeChunk(destination, stringToChunk('' + contribution));
- writeChunk(destination, boundaryPreambleContributionChunkEnd);
- }
-}
-
const startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
const startSegmentHTML2 = stringToPrecomputedChunk('">');
const endSegmentHTML = stringToPrecomputedChunk('</div>');
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
index 78615d8063248..43a0545ba10f1 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
@@ -224,12 +224,11 @@ export function pushStartActivityBoundary(
export function pushEndActivityBoundary(
target: Array<Chunk | PrecomputedChunk>,
renderState: RenderState,
- preambleState: null | PreambleState,
): void {
if (renderState.generateStaticMarkup) {
return;
}
- pushEndActivityBoundaryImpl(target, renderState, preambleState);
+ pushEndActivityBoundaryImpl(target, renderState);
}
export function writeStartCompletedSuspenseBoundary(
@@ -269,30 +268,20 @@ export function writeStartClientRenderedSuspenseBoundary(
export function writeEndCompletedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- preambleState: null | PreambleState,
): boolean {
if (renderState.generateStaticMarkup) {
return true;
}
- return writeEndCompletedSuspenseBoundaryImpl(
- destination,
- renderState,
- preambleState,
- );
+ return writeEndCompletedSuspenseBoundaryImpl(destination, renderState);
}
export function writeEndClientRenderedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- preambleState: null | PreambleState,
): boolean {
if (renderState.generateStaticMarkup) {
return true;
}
- return writeEndClientRenderedSuspenseBoundaryImpl(
- destination,
- renderState,
- preambleState,
- );
+ return writeEndClientRenderedSuspenseBoundaryImpl(destination, renderState);
}
export type TransitionStatus = FormStatus;
diff --git a/packages/react-markup/src/ReactFizzConfigMarkup.js b/packages/react-markup/src/ReactFizzConfigMarkup.js
index 7e95c0ce39042..3d08ed1ee64a2 100644
--- a/packages/react-markup/src/ReactFizzConfigMarkup.js
+++ b/packages/react-markup/src/ReactFizzConfigMarkup.js
@@ -162,7 +162,6 @@ export function pushStartActivityBoundary(
export function pushEndActivityBoundary(
target: Array<Chunk | PrecomputedChunk>,
renderState: RenderState,
- preambleState: null | PreambleState,
): void {
// Markup doesn't have any instructions.
return;
@@ -192,7 +191,6 @@ export function writeStartClientRenderedSuspenseBoundary(
export function writeEndCompletedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- preambleState: null | PreambleState,
): boolean {
// Markup doesn't have any instructions.
return true;
@@ -200,7 +198,6 @@ export function writeEndCompletedSuspenseBoundary(
export function writeEndClientRenderedSuspenseBoundary(
destination: Destination,
renderState: RenderState,
- preambleState: null | PreambleState,
): boolean {
// Markup doesn't have any instructions.
return true;
diff --git a/packages/react-noop-renderer/src/ReactNoopServer.js b/packages/react-noop-renderer/src/ReactNoopServer.js
index 5af393f3317eb..7d9597d95610b 100644
--- a/packages/react-noop-renderer/src/ReactNoopServer.js
+++ b/packages/react-noop-renderer/src/ReactNoopServer.js
@@ -181,7 +181,6 @@ const ReactNoopServer = ReactFizzServer({
pushEndActivityBoundary(
target: Array<Uint8Array>,
renderState: RenderState,
- preambleState: null | PreambleState,
): void {
target.push(POP);
},
diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js
index b89c4adc349d2..0eda8bcb02e96 100644
--- a/packages/react-server/src/ReactFizzServer.js
+++ b/packages/react-server/src/ReactFizzServer.js
@@ -2243,11 +2243,7 @@ function renderActivity(
renderNode(request, task, props.children, -1);
task.keyPath = prevKeyPath;
}
- pushEndActivityBoundary(
- segment.chunks,
- request.renderState,
- task.blockedPreamble,
- );
+ pushEndActivityBoundary(segment.chunks, request.renderState);
segment.lastPushedText = false;
}
}
@@ -4908,7 +4904,6 @@ function flushSegment(
return writeEndClientRenderedSuspenseBoundary(
destination,
request.renderState,
- boundary.fallbackPreamble,
);
} else if (boundary.status !== COMPLETED) {
if (boundary.status === PENDING) {
@@ -4979,11 +4974,7 @@ function flushSegment(
const contentSegment = completedSegments[0];
flushSegment(request, destination, contentSegment, hoistableState);
- return writeEndCompletedSuspenseBoundary(
- destination,
- request.renderState,
- boundary.contentPreamble,
- );
+ return writeEndCompletedSuspenseBoundary(destination, request.renderState);
}
}
| diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 77771b5b19a69..2d29781dfee97 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -230,9 +230,9 @@ const SUSPENSE_START_DATA = '$';
const SUSPENSE_END_DATA = '/$';
const SUSPENSE_PENDING_START_DATA = '$?';
const SUSPENSE_FALLBACK_START_DATA = '$!';
-const PREAMBLE_CONTRIBUTION_HTML = 0b001;
+const PREAMBLE_CONTRIBUTION_HTML = 'html';
+const PREAMBLE_CONTRIBUTION_BODY = 'body';
+const PREAMBLE_CONTRIBUTION_HEAD = 'head';
const FORM_STATE_IS_MATCHING = 'F!';
const FORM_STATE_IS_NOT_MATCHING = 'F';
@@ -1054,7 +1054,6 @@ export function clearSuspenseBoundary(
suspenseInstance: SuspenseInstance,
let node: Node = suspenseInstance;
- let possiblePreambleContribution: number = 0;
// Delete all nodes within this suspense boundary.
// There might be nested nodes so we need to keep track of how
// deep we are and only break out when we're back on top.
@@ -1065,36 +1064,6 @@ export function clearSuspenseBoundary(
if (nextNode && nextNode.nodeType === COMMENT_NODE) {
const data = ((nextNode: any).data: string);
if (data === SUSPENSE_END_DATA) {
- if (
- possiblePreambleContribution > 0 &&
- possiblePreambleContribution < 8
- ) {
- const code = possiblePreambleContribution;
- // It's not normally possible to insert a comment immediately preceding Suspense boundary
- // then it is in fact a preamble contribution marker comment. We do this value test to avoid the case
- // where the Suspense boundary is empty and the preceding comment marker is the Suspense boundary
- // opening marker or the closing marker of an inner boundary. In those cases the first character won't
- const ownerDocument = parentInstance.ownerDocument;
- if (code & PREAMBLE_CONTRIBUTION_HTML) {
- const documentElement: Element =
- (ownerDocument.documentElement: any);
- releaseSingletonInstance(documentElement);
- if (code & PREAMBLE_CONTRIBUTION_BODY) {
- const body: Element = (ownerDocument.body: any);
- releaseSingletonInstance(body);
- const head: Element = (ownerDocument.head: any);
- // We need to clear the head because this is the only singleton that can have children that
- // were part of this boundary but are not inside this boundary.
- clearHead(head);
- }
if (depth === 0) {
parentInstance.removeChild(nextNode);
// Retry if any event replaying was blocked on this.
@@ -1109,11 +1078,24 @@ export function clearSuspenseBoundary(
data === SUSPENSE_FALLBACK_START_DATA
) {
depth++;
- } else {
- possiblePreambleContribution = data.charCodeAt(0) - 48;
+ } else if (data === PREAMBLE_CONTRIBUTION_HTML) {
+ // If a preamble contribution marker is found within the bounds of this boundary,
+ // then it contributed to the html tag and we need to reset it.
+ const documentElement: Element = (ownerDocument.documentElement: any);
+ releaseSingletonInstance(documentElement);
+ const head: Element = (ownerDocument.head: any);
+ releaseSingletonInstance(head);
+ // We need to clear the head because this is the only singleton that can have children that
+ // were part of this boundary but are not inside this boundary.
+ clearHead(head);
+ } else if (data === PREAMBLE_CONTRIBUTION_BODY) {
+ const body: Element = (ownerDocument.body: any);
}
- } else {
- possiblePreambleContribution = 0;
// $FlowFixMe[incompatible-type] we bail out when we get a null
node = nextNode;
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
index 0022820465a4b..abdbf1a4f1c24 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
@@ -692,23 +692,16 @@ export function completeResumableState(resumableState: ResumableState): void {
resumableState.bootstrapModules = undefined;
-const NoContribution /* */ = 0b000;
-const HTMLContribution /* */ = 0b001;
-const BodyContribution /* */ = 0b010;
-const HeadContribution /* */ = 0b100;
export type PreambleState = {
htmlChunks: null | Array<Chunk | PrecomputedChunk>,
headChunks: null | Array<Chunk | PrecomputedChunk>,
bodyChunks: null | Array<Chunk | PrecomputedChunk>,
- contribution: number,
};
export function createPreambleState(): PreambleState {
return {
htmlChunks: null,
headChunks: null,
bodyChunks: null,
- contribution: NoContribution,
};
@@ -3279,6 +3272,12 @@ function pushTitleImpl(
return null;
+// These are used by the client if we clear a boundary and we find these, then we
+// also clear the singleton as well.
+const headPreambleContributionChunk = stringToPrecomputedChunk('<!--head-->');
+const bodyPreambleContributionChunk = stringToPrecomputedChunk('<!--body-->');
+const htmlPreambleContributionChunk = stringToPrecomputedChunk('<!--html-->');
function pushStartHead(
props: Object,
@@ -3293,6 +3292,12 @@ function pushStartHead(
if (preamble.headChunks) {
throw new Error(`The ${'`<head>`'} tag may only be rendered once.`);
+ target.push(headPreambleContributionChunk);
preamble.headChunks = [];
return pushStartSingletonElement(preamble.headChunks, props, 'head');
@@ -3317,6 +3322,11 @@ function pushStartBody(
throw new Error(`The ${'`<body>`'} tag may only be rendered once.`);
+ target.push(bodyPreambleContributionChunk);
preamble.bodyChunks = [];
return pushStartSingletonElement(preamble.bodyChunks, props, 'body');
@@ -3341,6 +3351,11 @@ function pushStartHtml(
throw new Error(`The ${'`<html>`'} tag may only be rendered once.`);
+ target.push(htmlPreambleContributionChunk);
preamble.htmlChunks = [DOCTYPE];
return pushStartSingletonElement(preamble.htmlChunks, props, 'html');
@@ -4013,15 +4028,12 @@ export function hoistPreambleState(
const rootPreamble = renderState.preamble;
if (rootPreamble.htmlChunks === null && preambleState.htmlChunks) {
rootPreamble.htmlChunks = preambleState.htmlChunks;
- preambleState.contribution |= HTMLContribution;
if (rootPreamble.headChunks === null && preambleState.headChunks) {
rootPreamble.headChunks = preambleState.headChunks;
- preambleState.contribution |= HeadContribution;
if (rootPreamble.bodyChunks === null && preambleState.bodyChunks) {
rootPreamble.bodyChunks = preambleState.bodyChunks;
- preambleState.contribution |= BodyContribution;
@@ -4101,11 +4113,7 @@ export function pushStartActivityBoundary(
- pushPreambleContribution(target, preambleState);
target.push(endActivityBoundary);
@@ -4220,11 +4228,7 @@ export function writeStartClientRenderedSuspenseBoundary(
export function writeEndPendingSuspenseBoundary(
@@ -4236,48 +4240,10 @@ export function writeEndPendingSuspenseBoundary(
-const boundaryPreambleContributionChunkStart = stringToPrecomputedChunk('<!--');
-const boundaryPreambleContributionChunkEnd = stringToPrecomputedChunk('-->');
- // Same as writePreambleContribution but for the render phase.
- target.push(
- boundaryPreambleContributionChunkStart,
- // This is a number type so we can do the fast path without coercion checking
- // eslint-disable-next-line react-internal/safe-string-coercion
- stringToChunk('' + contribution),
- boundaryPreambleContributionChunkEnd,
-function writePreambleContribution(
- destination: Destination,
- writeChunk(destination, boundaryPreambleContributionChunkStart);
- // This is a number type so we can do the fast path without coercion checking
- // eslint-disable-next-line react-internal/safe-string-coercion
- writeChunk(destination, stringToChunk('' + contribution));
- writeChunk(destination, boundaryPreambleContributionChunkEnd);
const startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
const startSegmentHTML2 = stringToPrecomputedChunk('">');
const endSegmentHTML = stringToPrecomputedChunk('</div>');
diff --git a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
index 78615d8063248..43a0545ba10f1 100644
--- a/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
+++ b/packages/react-dom-bindings/src/server/ReactFizzConfigDOMLegacy.js
@@ -224,12 +224,11 @@ export function pushStartActivityBoundary(
return;
+ pushEndActivityBoundaryImpl(target, renderState);
export function writeStartCompletedSuspenseBoundary(
@@ -269,30 +268,20 @@ export function writeStartClientRenderedSuspenseBoundary(
- return writeEndCompletedSuspenseBoundaryImpl(
+ return writeEndCompletedSuspenseBoundaryImpl(destination, renderState);
+ return writeEndClientRenderedSuspenseBoundaryImpl(destination, renderState);
export type TransitionStatus = FormStatus;
diff --git a/packages/react-markup/src/ReactFizzConfigMarkup.js b/packages/react-markup/src/ReactFizzConfigMarkup.js
index 7e95c0ce39042..3d08ed1ee64a2 100644
--- a/packages/react-markup/src/ReactFizzConfigMarkup.js
+++ b/packages/react-markup/src/ReactFizzConfigMarkup.js
@@ -162,7 +162,6 @@ export function pushStartActivityBoundary(
return;
@@ -192,7 +191,6 @@ export function writeStartClientRenderedSuspenseBoundary(
@@ -200,7 +198,6 @@ export function writeEndCompletedSuspenseBoundary(
diff --git a/packages/react-noop-renderer/src/ReactNoopServer.js b/packages/react-noop-renderer/src/ReactNoopServer.js
index 5af393f3317eb..7d9597d95610b 100644
--- a/packages/react-noop-renderer/src/ReactNoopServer.js
+++ b/packages/react-noop-renderer/src/ReactNoopServer.js
@@ -181,7 +181,6 @@ const ReactNoopServer = ReactFizzServer({
pushEndActivityBoundary(
target: Array<Uint8Array>,
renderState: RenderState,
- preambleState: null | PreambleState,
): void {
target.push(POP);
},
diff --git a/packages/react-server/src/ReactFizzServer.js b/packages/react-server/src/ReactFizzServer.js
index b89c4adc349d2..0eda8bcb02e96 100644
--- a/packages/react-server/src/ReactFizzServer.js
+++ b/packages/react-server/src/ReactFizzServer.js
@@ -2243,11 +2243,7 @@ function renderActivity(
renderNode(request, task, props.children, -1);
task.keyPath = prevKeyPath;
- pushEndActivityBoundary(
- segment.chunks,
- task.blockedPreamble,
+ pushEndActivityBoundary(segment.chunks, request.renderState);
segment.lastPushedText = false;
@@ -4908,7 +4904,6 @@ function flushSegment(
return writeEndClientRenderedSuspenseBoundary(
destination,
request.renderState,
- boundary.fallbackPreamble,
);
} else if (boundary.status !== COMPLETED) {
if (boundary.status === PENDING) {
@@ -4979,11 +4974,7 @@ function flushSegment(
const contentSegment = completedSegments[0];
flushSegment(request, destination, contentSegment, hoistableState);
- return writeEndCompletedSuspenseBoundary(
- destination,
- boundary.contentPreamble, | [
"-const PREAMBLE_CONTRIBUTION_BODY = 0b010;",
"-const PREAMBLE_CONTRIBUTION_HEAD = 0b100;",
"- // represents 3 bits where at least one bit is set (1-7)",
"- // closing comment marker so we can infer that if the comment preceding starts with \"1\" through \"7\"",
"- // have the requisite value to be interpreted as a Preamble contribution",
"- if (code & PREAMBLE_CONTRIBUTION_HEAD) {",
"- releaseSingletonInstance(head);",
"+ } else if (data === PREAMBLE_CONTRIBUTION_HEAD) {",
"+ releaseSingletonInstance(body);",
"+ // Insert a marker in the body where the contribution to the body tag was in case we need to clear it.",
"-function pushPreambleContribution(",
"- target: Array<Chunk | PrecomputedChunk>,",
"- pushEndActivityBoundaryImpl(target, renderState, preambleState);",
"- return writeEndClientRenderedSuspenseBoundaryImpl(",
"+ return writeEndCompletedSuspenseBoundary(destination, request.renderState);"
] | [
9,
10,
30,
36,
40,
51,
53,
74,
84,
149,
224,
225,
271,
300,
383
] | {
"additions": 47,
"author": "sebmarkbage",
"deletions": 123,
"html_url": "https://github.com/facebook/react/pull/32850",
"issue_id": 32850,
"merged_at": "2025-04-10T23:42:03Z",
"omission_probability": 0.1,
"pr_number": 32850,
"repo": "facebook/react",
"title": "Emit Preamble Contribution inline instead of the end of a boundary",
"total_changes": 170
} |
231 | diff --git a/packages/react-native-renderer/src/ReactFiberConfigFabric.js b/packages/react-native-renderer/src/ReactFiberConfigFabric.js
index d0ddc5f7f0dc0..151cd3c8cc2ae 100644
--- a/packages/react-native-renderer/src/ReactFiberConfigFabric.js
+++ b/packages/react-native-renderer/src/ReactFiberConfigFabric.js
@@ -18,6 +18,8 @@ import {
NoEventPriority,
DefaultEventPriority,
DiscreteEventPriority,
+ ContinuousEventPriority,
+ IdleEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
@@ -46,6 +48,8 @@ const {
registerEventHandler,
unstable_DefaultEventPriority: FabricDefaultPriority,
unstable_DiscreteEventPriority: FabricDiscretePriority,
+ unstable_ContinuousEventPriority: FabricContinuousPriority,
+ unstable_IdleEventPriority: FabricIdlePriority,
unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
} = nativeFabricUIManager;
@@ -397,6 +401,10 @@ export function resolveUpdatePriority(): EventPriority {
switch (currentEventPriority) {
case FabricDiscretePriority:
return DiscreteEventPriority;
+ case FabricContinuousPriority:
+ return ContinuousEventPriority;
+ case FabricIdlePriority:
+ return IdleEventPriority;
case FabricDefaultPriority:
default:
return DefaultEventPriority;
diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js
index 78fa4891c1bfb..840450b79cdb1 100644
--- a/scripts/flow/react-native-host-hooks.js
+++ b/scripts/flow/react-native-host-hooks.js
@@ -277,6 +277,8 @@ declare const nativeFabricUIManager: {
) => void,
unstable_DefaultEventPriority: number,
unstable_DiscreteEventPriority: number,
+ unstable_ContinuousEventPriority: number,
+ unstable_IdleEventPriority: number,
unstable_getCurrentEventPriority: () => number,
...
};
| diff --git a/packages/react-native-renderer/src/ReactFiberConfigFabric.js b/packages/react-native-renderer/src/ReactFiberConfigFabric.js
index d0ddc5f7f0dc0..151cd3c8cc2ae 100644
--- a/packages/react-native-renderer/src/ReactFiberConfigFabric.js
+++ b/packages/react-native-renderer/src/ReactFiberConfigFabric.js
@@ -18,6 +18,8 @@ import {
NoEventPriority,
DefaultEventPriority,
DiscreteEventPriority,
+ ContinuousEventPriority,
+ IdleEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
@@ -46,6 +48,8 @@ const {
registerEventHandler,
unstable_DefaultEventPriority: FabricDefaultPriority,
unstable_DiscreteEventPriority: FabricDiscretePriority,
+ unstable_ContinuousEventPriority: FabricContinuousPriority,
+ unstable_IdleEventPriority: FabricIdlePriority,
unstable_getCurrentEventPriority: fabricGetCurrentEventPriority,
} = nativeFabricUIManager;
@@ -397,6 +401,10 @@ export function resolveUpdatePriority(): EventPriority {
switch (currentEventPriority) {
case FabricDiscretePriority:
return DiscreteEventPriority;
+ case FabricContinuousPriority:
+ return ContinuousEventPriority;
+ case FabricIdlePriority:
+ return IdleEventPriority;
case FabricDefaultPriority:
default:
return DefaultEventPriority;
diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js
index 78fa4891c1bfb..840450b79cdb1 100644
--- a/scripts/flow/react-native-host-hooks.js
+++ b/scripts/flow/react-native-host-hooks.js
@@ -277,6 +277,8 @@ declare const nativeFabricUIManager: {
) => void,
unstable_DefaultEventPriority: number,
unstable_DiscreteEventPriority: number,
+ unstable_ContinuousEventPriority: number,
+ unstable_IdleEventPriority: number,
unstable_getCurrentEventPriority: () => number,
...
}; | [] | [] | {
"additions": 10,
"author": "rubennorte",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32847",
"issue_id": 32847,
"merged_at": "2025-04-10T16:35:15Z",
"omission_probability": 0.1,
"pr_number": 32847,
"repo": "facebook/react",
"title": "[RN] Map Fabric priorities to reconciler priorities correctly",
"total_changes": 10
} |
232 | diff --git a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
index ea5c30d5b27f0..8f1612f20ea7a 100644
--- a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
+++ b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
@@ -92,36 +92,8 @@ const tests: CompilerTestCases = {
}
`,
},
- {
- // Don't report the issue if Flow already has
- name: '[InvalidInput] Ref access during render',
- code: normalizeIndent`
- function Component(props) {
- const ref = useRef(null);
- // $FlowFixMe[react-rule-unsafe-ref]
- const value = ref.current;
- return value;
- }
- `,
- },
],
invalid: [
- {
- name: '[InvalidInput] Ref access during render',
- code: normalizeIndent`
- function Component(props) {
- const ref = useRef(null);
- const value = ref.current;
- return value;
- }
- `,
- errors: [
- {
- message:
- 'Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)',
- },
- ],
- },
{
name: 'Reportable levels can be configured',
options: [{reportableLevels: new Set([ErrorSeverity.Todo])}],
diff --git a/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts b/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
index 3f778deee47b2..e9eee26bdabc6 100644
--- a/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
+++ b/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
@@ -105,6 +105,9 @@ const COMPILER_OPTIONS: Partial<PluginOptions> = {
panicThreshold: 'none',
// Don't emit errors on Flow suppressions--Flow already gave a signal
flowSuppressions: false,
+ environment: validateEnvironmentConfig({
+ validateRefAccessDuringRender: false,
+ }),
};
const rule: Rule.RuleModule = {
@@ -149,10 +152,14 @@ const rule: Rule.RuleModule = {
}
let shouldReportUnusedOptOutDirective = true;
- const options: PluginOptions = {
- ...parsePluginOptions(userOpts),
+ const options: PluginOptions = parsePluginOptions({
...COMPILER_OPTIONS,
- };
+ ...userOpts,
+ environment: {
+ ...COMPILER_OPTIONS.environment,
+ ...userOpts.environment,
+ },
+ });
const userLogger: Logger | null = options.logger;
options.logger = {
logEvent: (filename, event): void => {
diff --git a/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts b/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts
index f0d14494b9671..30762e5819535 100644
--- a/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts
+++ b/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts
@@ -94,36 +94,8 @@ const tests: CompilerTestCases = {
}
`,
},
- {
- // Don't report the issue if Flow already has
- name: '[InvalidInput] Ref access during render',
- code: normalizeIndent`
- function Component(props) {
- const ref = useRef(null);
- // $FlowFixMe[react-rule-unsafe-ref]
- const value = ref.current;
- return value;
- }
- `,
- },
],
invalid: [
- {
- name: '[InvalidInput] Ref access during render',
- code: normalizeIndent`
- function Component(props) {
- const ref = useRef(null);
- const value = ref.current;
- return value;
- }
- `,
- errors: [
- {
- message:
- 'Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)',
- },
- ],
- },
{
name: 'Reportable levels can be configured',
options: [{reportableLevels: new Set([ErrorSeverity.Todo])}],
diff --git a/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts b/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts
index c2f9d3a103438..67d5745a1c7ea 100644
--- a/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts
+++ b/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts
@@ -107,6 +107,9 @@ const COMPILER_OPTIONS: Partial<PluginOptions> = {
panicThreshold: 'none',
// Don't emit errors on Flow suppressions--Flow already gave a signal
flowSuppressions: false,
+ environment: validateEnvironmentConfig({
+ validateRefAccessDuringRender: false,
+ }),
};
const rule: Rule.RuleModule = {
@@ -151,10 +154,14 @@ const rule: Rule.RuleModule = {
}
let shouldReportUnusedOptOutDirective = true;
- const options: PluginOptions = {
- ...parsePluginOptions(userOpts),
+ const options: PluginOptions = parsePluginOptions({
...COMPILER_OPTIONS,
- };
+ ...userOpts,
+ environment: {
+ ...COMPILER_OPTIONS.environment,
+ ...userOpts.environment,
+ },
+ });
const userLogger: Logger | null = options.logger;
options.logger = {
logEvent: (eventFilename, event): void => {
| diff --git a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
index ea5c30d5b27f0..8f1612f20ea7a 100644
--- a/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
+++ b/compiler/packages/eslint-plugin-react-compiler/__tests__/ReactCompilerRule-test.ts
@@ -92,36 +92,8 @@ const tests: CompilerTestCases = {
diff --git a/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts b/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
index 3f778deee47b2..e9eee26bdabc6 100644
--- a/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
+++ b/compiler/packages/eslint-plugin-react-compiler/src/rules/ReactCompilerRule.ts
@@ -105,6 +105,9 @@ const COMPILER_OPTIONS: Partial<PluginOptions> = {
@@ -149,10 +152,14 @@ const rule: Rule.RuleModule = {
logEvent: (filename, event): void => {
diff --git a/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts b/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts
index f0d14494b9671..30762e5819535 100644
--- a/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts
+++ b/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRule-test.ts
@@ -94,36 +94,8 @@ const tests: CompilerTestCases = {
diff --git a/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts b/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts
index c2f9d3a103438..67d5745a1c7ea 100644
--- a/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts
+++ b/packages/eslint-plugin-react-hooks/src/rules/ReactCompiler.ts
@@ -107,6 +107,9 @@ const COMPILER_OPTIONS: Partial<PluginOptions> = {
@@ -151,10 +154,14 @@ const rule: Rule.RuleModule = {
logEvent: (eventFilename, event): void => { | [] | [] | {
"additions": 20,
"author": "poteto",
"deletions": 62,
"html_url": "https://github.com/facebook/react/pull/32839",
"issue_id": 32839,
"merged_at": "2025-04-09T18:49:31Z",
"omission_probability": 0.1,
"pr_number": 32839,
"repo": "facebook/react",
"title": "[eprh] Temporarily disable ref access in render validation",
"total_changes": 82
} |
233 | diff --git a/.github/workflows/runtime_prereleases.yml b/.github/workflows/runtime_prereleases.yml
index e3cd5bd1a22ba..ee8dd72ce9665 100644
--- a/.github/workflows/runtime_prereleases.yml
+++ b/.github/workflows/runtime_prereleases.yml
@@ -13,7 +13,14 @@ on:
dist_tag:
required: true
type: string
+ enableFailureNotification:
+ description: 'Whether to notify the team on Discord when the release fails. Useful if this workflow is called from an automation.'
+ required: false
+ type: boolean
secrets:
+ DISCORD_WEBHOOK_URL:
+ description: 'Discord webhook URL to notify on failure. Only required if enableFailureNotification is true.'
+ required: false
GH_TOKEN:
required: true
NPM_TOKEN:
@@ -58,3 +65,11 @@ jobs:
GH_TOKEN=${{ secrets.GH_TOKEN }} scripts/release/prepare-release-from-ci.js --skipTests -r ${{ inputs.release_channel }} --commit=${{ inputs.commit_sha }}
cp ./scripts/release/ci-npmrc ~/.npmrc
scripts/release/publish.js --ci --tags ${{ inputs.dist_tag }}
+ - name: Notify Discord on failure
+ if: failure() && inputs.enableFailureNotification == true
+ uses: tsickert/discord-webhook@86dc739f3f165f16dadc5666051c367efa1692f4
+ with:
+ webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
+ embed-author-name: "GitHub Actions"
+ embed-title: 'Publish of $${{ inputs.release_channel }} release failed'
+ embed-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
diff --git a/.github/workflows/runtime_prereleases_nightly.yml b/.github/workflows/runtime_prereleases_nightly.yml
index f89a0d2c91bc4..a38e241d53996 100644
--- a/.github/workflows/runtime_prereleases_nightly.yml
+++ b/.github/workflows/runtime_prereleases_nightly.yml
@@ -21,7 +21,9 @@ jobs:
commit_sha: ${{ github.sha }}
release_channel: stable
dist_tag: canary,next
+ enableFailureNotification: true
secrets:
+ DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -40,6 +42,8 @@ jobs:
commit_sha: ${{ github.sha }}
release_channel: experimental
dist_tag: experimental
+ enableFailureNotification: true
secrets:
+ DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
| diff --git a/.github/workflows/runtime_prereleases.yml b/.github/workflows/runtime_prereleases.yml
index e3cd5bd1a22ba..ee8dd72ce9665 100644
--- a/.github/workflows/runtime_prereleases.yml
+++ b/.github/workflows/runtime_prereleases.yml
@@ -13,7 +13,14 @@ on:
dist_tag:
type: string
+ enableFailureNotification:
+ type: boolean
+ DISCORD_WEBHOOK_URL:
+ description: 'Discord webhook URL to notify on failure. Only required if enableFailureNotification is true.'
GH_TOKEN:
NPM_TOKEN:
@@ -58,3 +65,11 @@ jobs:
GH_TOKEN=${{ secrets.GH_TOKEN }} scripts/release/prepare-release-from-ci.js --skipTests -r ${{ inputs.release_channel }} --commit=${{ inputs.commit_sha }}
cp ./scripts/release/ci-npmrc ~/.npmrc
scripts/release/publish.js --ci --tags ${{ inputs.dist_tag }}
+ - name: Notify Discord on failure
+ uses: tsickert/discord-webhook@86dc739f3f165f16dadc5666051c367efa1692f4
+ with:
+ webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
+ embed-author-name: "GitHub Actions"
+ embed-title: 'Publish of $${{ inputs.release_channel }} release failed'
+ embed-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
diff --git a/.github/workflows/runtime_prereleases_nightly.yml b/.github/workflows/runtime_prereleases_nightly.yml
index f89a0d2c91bc4..a38e241d53996 100644
--- a/.github/workflows/runtime_prereleases_nightly.yml
+++ b/.github/workflows/runtime_prereleases_nightly.yml
@@ -21,7 +21,9 @@ jobs:
release_channel: stable
dist_tag: canary,next
@@ -40,6 +42,8 @@ jobs:
release_channel: experimental
dist_tag: experimental | [
"+ description: 'Whether to notify the team on Discord when the release fails. Useful if this workflow is called from an automation.'",
"+ if: failure() && inputs.enableFailureNotification == true"
] | [
9,
24
] | {
"additions": 19,
"author": "eps1lon",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32840",
"issue_id": 32840,
"merged_at": "2025-04-09T17:14:28Z",
"omission_probability": 0.1,
"pr_number": 32840,
"repo": "facebook/react",
"title": "Send notification to Discord if automated publish fails",
"total_changes": 19
} |
234 | diff --git a/packages/eslint-plugin-react-hooks/README.md b/packages/eslint-plugin-react-hooks/README.md
index 138cff733be6b..10020afd61038 100644
--- a/packages/eslint-plugin-react-hooks/README.md
+++ b/packages/eslint-plugin-react-hooks/README.md
@@ -20,6 +20,19 @@ yarn add eslint-plugin-react-hooks --dev
### Flat Config (eslint.config.js|ts)
+#### >= 6.0.0
+
+For users of 6.0 and beyond, simply add the `recommended` config.
+
+```js
+import * as reactHooks from 'eslint-plugin-react-hooks';
+
+export default [
+ // ...
+ reactHooks.configs.recommended,
+];
+```
+
#### 5.2.0
For users of 5.2.0 (the first version with flat config support), add the `recommended-latest` config.
| diff --git a/packages/eslint-plugin-react-hooks/README.md b/packages/eslint-plugin-react-hooks/README.md
index 138cff733be6b..10020afd61038 100644
--- a/packages/eslint-plugin-react-hooks/README.md
+++ b/packages/eslint-plugin-react-hooks/README.md
@@ -20,6 +20,19 @@ yarn add eslint-plugin-react-hooks --dev
### Flat Config (eslint.config.js|ts)
+For users of 6.0 and beyond, simply add the `recommended` config.
+```js
+import * as reactHooks from 'eslint-plugin-react-hooks';
+export default [
+ // ...
+ reactHooks.configs.recommended,
+];
+```
#### 5.2.0
For users of 5.2.0 (the first version with flat config support), add the `recommended-latest` config. | [
"+#### >= 6.0.0"
] | [
8
] | {
"additions": 13,
"author": "michaelfaith",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32513",
"issue_id": 32513,
"merged_at": "2025-04-09T16:42:23Z",
"omission_probability": 0.1,
"pr_number": 32513,
"repo": "facebook/react",
"title": "docs(eslint-plugin-react-hooks): add 6.0 documentation",
"total_changes": 13
} |
235 | diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 7a930f8fe6e07..77771b5b19a69 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -107,6 +107,7 @@ import {
disableCommentsAsDOMContainers,
enableSuspenseyImages,
enableSrcObject,
+ enableViewTransition,
} from 'shared/ReactFeatureFlags';
import {
HostComponent,
@@ -5112,7 +5113,7 @@ export function isHostHoistableType(
}
export function maySuspendCommit(type: Type, props: Props): boolean {
- if (!enableSuspenseyImages) {
+ if (!enableSuspenseyImages && !enableViewTransition) {
return false;
}
// Suspensey images are the default, unless you opt-out of with either
@@ -5206,7 +5207,7 @@ export function suspendInstance(
type: Type,
props: Props,
): void {
- if (!enableSuspenseyImages) {
+ if (!enableSuspenseyImages && !enableViewTransition) {
return;
}
if (suspendedState === null) {
diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js
index 614df0831f662..c2ea817f5b1a4 100644
--- a/packages/react-reconciler/src/ReactFiber.js
+++ b/packages/react-reconciler/src/ReactFiber.js
@@ -41,6 +41,7 @@ import {
disableLegacyMode,
enableObjectFiber,
enableViewTransition,
+ enableSuspenseyImages,
} from 'shared/ReactFeatureFlags';
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
import {ConcurrentRoot} from './ReactRootTags';
@@ -89,6 +90,7 @@ import {
StrictLegacyMode,
StrictEffectsMode,
NoStrictPassiveEffectsMode,
+ SuspenseyImagesMode,
} from './ReactTypeOfMode';
import {
REACT_FORWARD_REF_TYPE,
@@ -875,6 +877,11 @@ export function createFiberFromViewTransition(
lanes: Lanes,
key: null | string,
): Fiber {
+ if (!enableSuspenseyImages) {
+ // Render a ViewTransition component opts into SuspenseyImages mode even
+ // when the flag is off.
+ mode |= SuspenseyImagesMode;
+ }
const fiber = createFiber(ViewTransitionComponent, pendingProps, key, mode);
fiber.elementType = REACT_VIEW_TRANSITION_TYPE;
fiber.lanes = lanes;
diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.js b/packages/react-reconciler/src/ReactFiberCompleteWork.js
index 037c1d3bef42d..740de057d2658 100644
--- a/packages/react-reconciler/src/ReactFiberCompleteWork.js
+++ b/packages/react-reconciler/src/ReactFiberCompleteWork.js
@@ -42,6 +42,7 @@ import {
disableLegacyMode,
enableSiblingPrerendering,
enableViewTransition,
+ enableSuspenseyImages,
} from 'shared/ReactFeatureFlags';
import {now} from './Scheduler';
@@ -77,7 +78,12 @@ import {
ViewTransitionComponent,
ActivityComponent,
} from './ReactWorkTags';
-import {NoMode, ConcurrentMode, ProfileMode} from './ReactTypeOfMode';
+import {
+ NoMode,
+ ConcurrentMode,
+ ProfileMode,
+ SuspenseyImagesMode,
+} from './ReactTypeOfMode';
import {
Placement,
Update,
@@ -555,9 +561,11 @@ function preloadInstanceAndSuspendIfNeeded(
renderLanes: Lanes,
) {
const maySuspend =
- oldProps === null
+ (enableSuspenseyImages ||
+ (workInProgress.mode & SuspenseyImagesMode) !== NoMode) &&
+ (oldProps === null
? maySuspendCommit(type, newProps)
- : maySuspendCommitOnUpdate(type, oldProps, newProps);
+ : maySuspendCommitOnUpdate(type, oldProps, newProps));
if (!maySuspend) {
// If this flag was set previously, we can remove it. The flag
diff --git a/packages/react-reconciler/src/ReactTypeOfMode.js b/packages/react-reconciler/src/ReactTypeOfMode.js
index fd67d9979f8bb..4348fe2668647 100644
--- a/packages/react-reconciler/src/ReactTypeOfMode.js
+++ b/packages/react-reconciler/src/ReactTypeOfMode.js
@@ -12,8 +12,11 @@ export type TypeOfMode = number;
export const NoMode = /* */ 0b0000000;
// TODO: Remove ConcurrentMode by reading from the root tag instead
export const ConcurrentMode = /* */ 0b0000001;
-export const ProfileMode = /* */ 0b0000010;
+export const ProfileMode = /* */ 0b0000010;
//export const DebugTracingMode = /* */ 0b0000100; // Removed
export const StrictLegacyMode = /* */ 0b0001000;
export const StrictEffectsMode = /* */ 0b0010000;
export const NoStrictPassiveEffectsMode = /* */ 0b1000000;
+// Keep track of if we're in a SuspenseyImages eligible subtree.
+// TODO: Remove this when enableSuspenseyImages ship where it's always on.
+export const SuspenseyImagesMode = /* */ 0b0100000;
diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js
index 2b5707b8c554d..cad1a011817f6 100644
--- a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js
+++ b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js
@@ -50,6 +50,7 @@ describe('ReactSuspenseyCommitPhase', () => {
);
}
+ // @gate enableSuspenseyImages
it('suspend commit during initial mount', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
@@ -70,6 +71,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});
+ // @gate enableSuspenseyImages
it('suspend commit during update', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
@@ -105,6 +107,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});
+ // @gate enableSuspenseyImages
it('suspend commit during initial mount at the root', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
@@ -121,6 +124,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});
+ // @gate enableSuspenseyImages
it('suspend commit during update at the root', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
@@ -147,6 +151,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});
+ // @gate enableSuspenseyImages
it('suspend commit during urgent initial mount', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
@@ -165,6 +170,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});
+ // @gate enableSuspenseyImages
it('suspend commit during urgent update', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
@@ -203,6 +209,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});
+ // @gate enableSuspenseyImages
it('suspends commit during urgent initial mount at the root', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
@@ -217,6 +224,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});
+ // @gate enableSuspenseyImages
it('suspends commit during urgent update at the root', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
@@ -239,6 +247,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});
+ // @gate enableSuspenseyImages
it('does suspend commit during urgent initial mount at the root when sync rendering', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
@@ -256,6 +265,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="A" />);
});
+ // @gate enableSuspenseyImages
it('does suspend commit during urgent update at the root when sync rendering', async () => {
const root = ReactNoop.createRoot();
await act(() => resolveSuspenseyThing('A'));
@@ -283,6 +293,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput(<suspensey-thing src="B" />);
});
+ // @gate enableSuspenseyImages
it('an urgent update interrupts a suspended commit', async () => {
const root = ReactNoop.createRoot();
@@ -305,6 +316,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput('Something else');
});
+ // @gate enableSuspenseyImages
it('a transition update interrupts a suspended commit', async () => {
const root = ReactNoop.createRoot();
@@ -329,7 +341,7 @@ describe('ReactSuspenseyCommitPhase', () => {
expect(root).toMatchRenderedOutput('Something else');
});
- // @gate enableSuspenseList
+ // @gate enableSuspenseList && enableSuspenseyImages
it('demonstrate current behavior when used with SuspenseList (not ideal)', async () => {
function App() {
return (
@@ -381,6 +393,7 @@ describe('ReactSuspenseyCommitPhase', () => {
);
});
+ // @gate enableSuspenseyImages
it('avoid triggering a fallback if resource loads immediately', async () => {
const root = ReactNoop.createRoot();
await act(async () => {
@@ -429,7 +442,7 @@ describe('ReactSuspenseyCommitPhase', () => {
);
});
- // @gate enableActivity
+ // @gate enableActivity && enableSuspenseyImages
it("host instances don't suspend during prerendering, but do suspend when they are revealed", async () => {
function More() {
Scheduler.log('More');
@@ -493,7 +506,7 @@ describe('ReactSuspenseyCommitPhase', () => {
});
// FIXME: Should pass with `enableYieldingBeforePassive`
- // @gate !enableYieldingBeforePassive
+ // @gate !enableYieldingBeforePassive && enableSuspenseyImages
it('runs passive effects after suspended commit resolves', async () => {
function Effect() {
React.useEffect(() => {
diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js
index aed9b9bcfdb24..10bd08970f8e8 100644
--- a/packages/shared/ReactFeatureFlags.js
+++ b/packages/shared/ReactFeatureFlags.js
@@ -96,7 +96,7 @@ export const enableGestureTransition = __EXPERIMENTAL__;
export const enableScrollEndPolyfill = __EXPERIMENTAL__;
-export const enableSuspenseyImages = __EXPERIMENTAL__;
+export const enableSuspenseyImages = false;
export const enableSrcObject = __EXPERIMENTAL__;
| diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 7a930f8fe6e07..77771b5b19a69 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -107,6 +107,7 @@ import {
disableCommentsAsDOMContainers,
enableSuspenseyImages,
enableSrcObject,
+ enableViewTransition,
HostComponent,
@@ -5112,7 +5113,7 @@ export function isHostHoistableType(
}
export function maySuspendCommit(type: Type, props: Props): boolean {
return false;
// Suspensey images are the default, unless you opt-out of with either
@@ -5206,7 +5207,7 @@ export function suspendInstance(
type: Type,
props: Props,
): void {
return;
if (suspendedState === null) {
diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js
index 614df0831f662..c2ea817f5b1a4 100644
--- a/packages/react-reconciler/src/ReactFiber.js
+++ b/packages/react-reconciler/src/ReactFiber.js
@@ -41,6 +41,7 @@ import {
enableObjectFiber,
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
import {ConcurrentRoot} from './ReactRootTags';
@@ -89,6 +90,7 @@ import {
StrictLegacyMode,
StrictEffectsMode,
NoStrictPassiveEffectsMode,
} from './ReactTypeOfMode';
REACT_FORWARD_REF_TYPE,
@@ -875,6 +877,11 @@ export function createFiberFromViewTransition(
lanes: Lanes,
key: null | string,
): Fiber {
+ if (!enableSuspenseyImages) {
+ // Render a ViewTransition component opts into SuspenseyImages mode even
+ // when the flag is off.
+ }
const fiber = createFiber(ViewTransitionComponent, pendingProps, key, mode);
fiber.elementType = REACT_VIEW_TRANSITION_TYPE;
fiber.lanes = lanes;
diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.js b/packages/react-reconciler/src/ReactFiberCompleteWork.js
index 037c1d3bef42d..740de057d2658 100644
--- a/packages/react-reconciler/src/ReactFiberCompleteWork.js
+++ b/packages/react-reconciler/src/ReactFiberCompleteWork.js
@@ -42,6 +42,7 @@ import {
enableSiblingPrerendering,
import {now} from './Scheduler';
@@ -77,7 +78,12 @@ import {
ViewTransitionComponent,
ActivityComponent,
} from './ReactWorkTags';
-import {NoMode, ConcurrentMode, ProfileMode} from './ReactTypeOfMode';
+import {
+ NoMode,
+ ConcurrentMode,
+ ProfileMode,
+} from './ReactTypeOfMode';
Placement,
Update,
@@ -555,9 +561,11 @@ function preloadInstanceAndSuspendIfNeeded(
renderLanes: Lanes,
) {
const maySuspend =
- oldProps === null
+ (enableSuspenseyImages ||
+ (workInProgress.mode & SuspenseyImagesMode) !== NoMode) &&
+ (oldProps === null
? maySuspendCommit(type, newProps)
+ : maySuspendCommitOnUpdate(type, oldProps, newProps));
if (!maySuspend) {
// If this flag was set previously, we can remove it. The flag
diff --git a/packages/react-reconciler/src/ReactTypeOfMode.js b/packages/react-reconciler/src/ReactTypeOfMode.js
index fd67d9979f8bb..4348fe2668647 100644
--- a/packages/react-reconciler/src/ReactTypeOfMode.js
+++ b/packages/react-reconciler/src/ReactTypeOfMode.js
@@ -12,8 +12,11 @@ export type TypeOfMode = number;
export const NoMode = /* */ 0b0000000;
// TODO: Remove ConcurrentMode by reading from the root tag instead
export const ConcurrentMode = /* */ 0b0000001;
-export const ProfileMode = /* */ 0b0000010;
+export const ProfileMode = /* */ 0b0000010;
//export const DebugTracingMode = /* */ 0b0000100; // Removed
export const StrictLegacyMode = /* */ 0b0001000;
export const StrictEffectsMode = /* */ 0b0010000;
export const NoStrictPassiveEffectsMode = /* */ 0b1000000;
+// Keep track of if we're in a SuspenseyImages eligible subtree.
+// TODO: Remove this when enableSuspenseyImages ship where it's always on.
+export const SuspenseyImagesMode = /* */ 0b0100000;
diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js
index 2b5707b8c554d..cad1a011817f6 100644
--- a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js
+++ b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js
@@ -50,6 +50,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspend commit during initial mount', async () => {
@@ -70,6 +71,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspend commit during update', async () => {
@@ -105,6 +107,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspend commit during initial mount at the root', async () => {
@@ -121,6 +124,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspend commit during update at the root', async () => {
@@ -147,6 +151,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspend commit during urgent initial mount', async () => {
@@ -165,6 +170,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspend commit during urgent update', async () => {
@@ -203,6 +209,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspends commit during urgent initial mount at the root', async () => {
@@ -217,6 +224,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('suspends commit during urgent update at the root', async () => {
@@ -239,6 +247,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('does suspend commit during urgent initial mount at the root when sync rendering', async () => {
@@ -256,6 +265,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('does suspend commit during urgent update at the root when sync rendering', async () => {
@@ -283,6 +293,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('an urgent update interrupts a suspended commit', async () => {
@@ -305,6 +316,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('a transition update interrupts a suspended commit', async () => {
@@ -329,7 +341,7 @@ describe('ReactSuspenseyCommitPhase', () => {
- // @gate enableSuspenseList
+ // @gate enableSuspenseList && enableSuspenseyImages
it('demonstrate current behavior when used with SuspenseList (not ideal)', async () => {
function App() {
return (
@@ -381,6 +393,7 @@ describe('ReactSuspenseyCommitPhase', () => {
it('avoid triggering a fallback if resource loads immediately', async () => {
@@ -429,7 +442,7 @@ describe('ReactSuspenseyCommitPhase', () => {
- // @gate enableActivity
+ // @gate enableActivity && enableSuspenseyImages
it("host instances don't suspend during prerendering, but do suspend when they are revealed", async () => {
function More() {
Scheduler.log('More');
@@ -493,7 +506,7 @@ describe('ReactSuspenseyCommitPhase', () => {
// FIXME: Should pass with `enableYieldingBeforePassive`
- // @gate !enableYieldingBeforePassive
+ // @gate !enableYieldingBeforePassive && enableSuspenseyImages
it('runs passive effects after suspended commit resolves', async () => {
function Effect() {
React.useEffect(() => {
diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js
index aed9b9bcfdb24..10bd08970f8e8 100644
--- a/packages/shared/ReactFeatureFlags.js
+++ b/packages/shared/ReactFeatureFlags.js
@@ -96,7 +96,7 @@ export const enableGestureTransition = __EXPERIMENTAL__;
export const enableScrollEndPolyfill = __EXPERIMENTAL__;
-export const enableSuspenseyImages = __EXPERIMENTAL__;
+export const enableSuspenseyImages = false;
export const enableSrcObject = __EXPERIMENTAL__; | [
"+ mode |= SuspenseyImagesMode;",
"- : maySuspendCommitOnUpdate(type, oldProps, newProps);"
] | [
57,
97
] | {
"additions": 42,
"author": "sebmarkbage",
"deletions": 10,
"html_url": "https://github.com/facebook/react/pull/32820",
"issue_id": 32820,
"merged_at": "2025-04-08T21:55:16Z",
"omission_probability": 0.1,
"pr_number": 32820,
"repo": "facebook/react",
"title": "Enable Suspensey Images inside <ViewTransition> subtrees",
"total_changes": 52
} |
236 | diff --git a/fixtures/view-transition/src/components/Page.js b/fixtures/view-transition/src/components/Page.js
index d39b9bf45f9ca..9744313c4f5ea 100644
--- a/fixtures/view-transition/src/components/Page.js
+++ b/fixtures/view-transition/src/components/Page.js
@@ -113,7 +113,9 @@ export default function Page({url, navigate}) {
const exclamation = (
<ViewTransition name="exclamation" onShare={onTransition}>
- <span>!</span>
+ <span>
+ <div>!</div>
+ </span>
</ViewTransition>
);
return (
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 23056953aeb1d..63d9ded3fc94b 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -137,6 +137,11 @@ export type Props = {
'view-transition-name'?: string,
viewTransitionClass?: string,
'view-transition-class'?: string,
+ margin?: string,
+ marginTop?: string,
+ 'margin-top'?: string,
+ marginBottom?: string,
+ 'margin-bottom'?: string,
...
},
bottom?: null | number,
@@ -1161,6 +1166,59 @@ export function unhideTextInstance(
textInstance.nodeValue = text;
}
+function warnForBlockInsideInline(instance: HTMLElement) {
+ if (__DEV__) {
+ let nextNode = instance.firstChild;
+ outer: while (nextNode != null) {
+ let node: Node = nextNode;
+ if (
+ node.nodeType === ELEMENT_NODE &&
+ getComputedStyle((node: any)).display === 'block'
+ ) {
+ console.error(
+ "You're about to start a <ViewTransition> around a display: inline " +
+ 'element <%s>, which itself has a display: block element <%s> inside it. ' +
+ 'This might trigger a bug in Safari which causes the View Transition to ' +
+ 'be skipped with a duplicate name error.\n' +
+ 'https://bugs.webkit.org/show_bug.cgi?id=290923',
+ instance.tagName.toLocaleLowerCase(),
+ (node: any).tagName.toLocaleLowerCase(),
+ );
+ break;
+ }
+ if (node.firstChild != null) {
+ nextNode = node.firstChild;
+ continue;
+ }
+ if (node === instance) {
+ break;
+ }
+ while (node.nextSibling == null) {
+ if (node.parentNode == null || node.parentNode === instance) {
+ break;
+ }
+ node = node.parentNode;
+ }
+ nextNode = node.nextSibling;
+ }
+ }
+}
+
+function countClientRects(rects: Array<ClientRect>): number {
+ if (rects.length === 1) {
+ return 1;
+ }
+ // Count non-zero rects.
+ let count = 0;
+ for (let i = 0; i < rects.length; i++) {
+ const rect = rects[i];
+ if (rect.width > 0 && rect.height > 0) {
+ count++;
+ }
+ }
+ return count;
+}
+
export function applyViewTransitionName(
instance: Instance,
name: string,
@@ -1173,6 +1231,34 @@ export function applyViewTransitionName(
// $FlowFixMe[prop-missing]
instance.style.viewTransitionClass = className;
}
+ const computedStyle = getComputedStyle(instance);
+ if (computedStyle.display === 'inline') {
+ // WebKit has a bug where assigning a name to display: inline elements errors
+ // if they have display: block children. We try to work around this bug in the
+ // simple case by converting it automatically to display: inline-block.
+ // https://bugs.webkit.org/show_bug.cgi?id=290923
+ const rects = instance.getClientRects();
+ if (countClientRects(rects) === 1) {
+ // If the instance has a single client rect, that means that it can be
+ // expressed as a display: inline-block or block.
+ // This will cause layout thrash but we live with it since inline view transitions
+ // are unusual.
+ const style = instance.style;
+ // If there's literally only one rect, then it's likely on a single line like an
+ // inline-block. If it's multiple rects but all but one of them are empty it's
+ // likely because it's a single block that caused a line break.
+ style.display = rects.length === 1 ? 'inline-block' : 'block';
+ // Margin doesn't apply to inline so should be zero. However, padding top/bottom
+ // applies to inline-block positioning which we can offset by setting the margin
+ // to the negative padding to get it back into original position.
+ style.marginTop = '-' + computedStyle.paddingTop;
+ style.marginBottom = '-' + computedStyle.paddingBottom;
+ } else {
+ // This case cannot be easily fixed if it has blocks but it's also fine if
+ // it doesn't have blocks. So we only warn in DEV about this being an issue.
+ warnForBlockInsideInline(instance);
+ }
+ }
}
export function restoreViewTransitionName(
@@ -1180,6 +1266,7 @@ export function restoreViewTransitionName(
props: Props,
): void {
instance = ((instance: any): HTMLElement);
+ const style = instance.style;
const styleProp = props[STYLE];
const viewTransitionName =
styleProp != null
@@ -1190,7 +1277,7 @@ export function restoreViewTransitionName(
: null
: null;
// $FlowFixMe[prop-missing]
- instance.style.viewTransitionName =
+ style.viewTransitionName =
viewTransitionName == null || typeof viewTransitionName === 'boolean'
? ''
: // The value would've errored already if it wasn't safe.
@@ -1205,12 +1292,39 @@ export function restoreViewTransitionName(
: null
: null;
// $FlowFixMe[prop-missing]
- instance.style.viewTransitionClass =
+ style.viewTransitionClass =
viewTransitionClass == null || typeof viewTransitionClass === 'boolean'
? ''
: // The value would've errored already if it wasn't safe.
// eslint-disable-next-line react-internal/safe-string-coercion
('' + viewTransitionClass).trim();
+ if (style.display === 'inline-block') {
+ // We might have overridden the style. Reset it to what it should be.
+ if (styleProp == null) {
+ style.display = style.margin = '';
+ } else {
+ const display = styleProp.display;
+ style.display =
+ display == null || typeof display === 'boolean' ? '' : display;
+ const margin = styleProp.margin;
+ if (margin != null) {
+ style.margin = margin;
+ } else {
+ const marginTop = styleProp.hasOwnProperty('marginTop')
+ ? styleProp.marginTop
+ : styleProp['margin-top'];
+ style.marginTop =
+ marginTop == null || typeof marginTop === 'boolean' ? '' : marginTop;
+ const marginBottom = styleProp.hasOwnProperty('marginBottom')
+ ? styleProp.marginBottom
+ : styleProp['margin-bottom'];
+ style.marginBottom =
+ marginBottom == null || typeof marginBottom === 'boolean'
+ ? ''
+ : marginBottom;
+ }
+ }
+ }
}
export function cancelViewTransitionName(
diff --git a/packages/react-reconciler/src/ReactFiberApplyGesture.js b/packages/react-reconciler/src/ReactFiberApplyGesture.js
index 28f9ff3e3555d..d39413e45bcb6 100644
--- a/packages/react-reconciler/src/ReactFiberApplyGesture.js
+++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js
@@ -834,18 +834,18 @@ function insertDestinationClonesOfFiber(
}
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
+ appendChild(hostParentClone, clone);
+ unhideInstance(clone, finishedWork.memoizedProps);
recursivelyInsertClones(
finishedWork,
clone,
null,
CLONE_APPEARING_PAIR,
);
- appendChild(hostParentClone, clone);
- unhideInstance(clone, finishedWork.memoizedProps);
trackHostMutation();
} else {
- recursivelyInsertClones(finishedWork, clone, null, visitPhase);
appendChild(hostParentClone, clone);
+ recursivelyInsertClones(finishedWork, clone, null, visitPhase);
}
if (parentViewTransition !== null) {
if (parentViewTransition.clones === null) {
| diff --git a/fixtures/view-transition/src/components/Page.js b/fixtures/view-transition/src/components/Page.js
index d39b9bf45f9ca..9744313c4f5ea 100644
--- a/fixtures/view-transition/src/components/Page.js
+++ b/fixtures/view-transition/src/components/Page.js
@@ -113,7 +113,9 @@ export default function Page({url, navigate}) {
const exclamation = (
<ViewTransition name="exclamation" onShare={onTransition}>
- <span>!</span>
+ <span>
+ <div>!</div>
+ </span>
</ViewTransition>
);
return (
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index 23056953aeb1d..63d9ded3fc94b 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -137,6 +137,11 @@ export type Props = {
'view-transition-name'?: string,
viewTransitionClass?: string,
'view-transition-class'?: string,
+ margin?: string,
+ marginTop?: string,
+ 'margin-top'?: string,
+ marginBottom?: string,
+ 'margin-bottom'?: string,
...
},
bottom?: null | number,
@@ -1161,6 +1166,59 @@ export function unhideTextInstance(
textInstance.nodeValue = text;
+function warnForBlockInsideInline(instance: HTMLElement) {
+ if (__DEV__) {
+ let nextNode = instance.firstChild;
+ outer: while (nextNode != null) {
+ if (
+ node.nodeType === ELEMENT_NODE &&
+ getComputedStyle((node: any)).display === 'block'
+ ) {
+ console.error(
+ "You're about to start a <ViewTransition> around a display: inline " +
+ 'element <%s>, which itself has a display: block element <%s> inside it. ' +
+ 'This might trigger a bug in Safari which causes the View Transition to ' +
+ 'be skipped with a duplicate name error.\n' +
+ 'https://bugs.webkit.org/show_bug.cgi?id=290923',
+ instance.tagName.toLocaleLowerCase(),
+ (node: any).tagName.toLocaleLowerCase(),
+ );
+ if (node.firstChild != null) {
+ nextNode = node.firstChild;
+ continue;
+ if (node === instance) {
+ while (node.nextSibling == null) {
+ if (node.parentNode == null || node.parentNode === instance) {
+ break;
+ }
+ node = node.parentNode;
+ nextNode = node.nextSibling;
+function countClientRects(rects: Array<ClientRect>): number {
+ if (rects.length === 1) {
+ return 1;
+ // Count non-zero rects.
+ let count = 0;
+ for (let i = 0; i < rects.length; i++) {
+ const rect = rects[i];
+ if (rect.width > 0 && rect.height > 0) {
+ count++;
+ return count;
export function applyViewTransitionName(
instance: Instance,
name: string,
@@ -1173,6 +1231,34 @@ export function applyViewTransitionName(
// $FlowFixMe[prop-missing]
instance.style.viewTransitionClass = className;
}
+ const computedStyle = getComputedStyle(instance);
+ if (computedStyle.display === 'inline') {
+ // WebKit has a bug where assigning a name to display: inline elements errors
+ // if they have display: block children. We try to work around this bug in the
+ // simple case by converting it automatically to display: inline-block.
+ // https://bugs.webkit.org/show_bug.cgi?id=290923
+ if (countClientRects(rects) === 1) {
+ // If the instance has a single client rect, that means that it can be
+ // expressed as a display: inline-block or block.
+ // This will cause layout thrash but we live with it since inline view transitions
+ // are unusual.
+ const style = instance.style;
+ // If there's literally only one rect, then it's likely on a single line like an
+ // inline-block. If it's multiple rects but all but one of them are empty it's
+ // likely because it's a single block that caused a line break.
+ style.display = rects.length === 1 ? 'inline-block' : 'block';
+ // Margin doesn't apply to inline so should be zero. However, padding top/bottom
+ // applies to inline-block positioning which we can offset by setting the margin
+ // to the negative padding to get it back into original position.
+ style.marginTop = '-' + computedStyle.paddingTop;
+ style.marginBottom = '-' + computedStyle.paddingBottom;
+ // This case cannot be easily fixed if it has blocks but it's also fine if
+ // it doesn't have blocks. So we only warn in DEV about this being an issue.
+ warnForBlockInsideInline(instance);
export function restoreViewTransitionName(
@@ -1180,6 +1266,7 @@ export function restoreViewTransitionName(
props: Props,
): void {
instance = ((instance: any): HTMLElement);
+ const style = instance.style;
const styleProp = props[STYLE];
const viewTransitionName =
styleProp != null
@@ -1190,7 +1277,7 @@ export function restoreViewTransitionName(
- instance.style.viewTransitionName =
+ style.viewTransitionName =
viewTransitionName == null || typeof viewTransitionName === 'boolean'
@@ -1205,12 +1292,39 @@ export function restoreViewTransitionName(
- instance.style.viewTransitionClass =
+ style.viewTransitionClass =
viewTransitionClass == null || typeof viewTransitionClass === 'boolean'
// eslint-disable-next-line react-internal/safe-string-coercion
('' + viewTransitionClass).trim();
+ if (style.display === 'inline-block') {
+ // We might have overridden the style. Reset it to what it should be.
+ if (styleProp == null) {
+ style.display = style.margin = '';
+ const display = styleProp.display;
+ style.display =
+ display == null || typeof display === 'boolean' ? '' : display;
+ if (margin != null) {
+ style.margin = margin;
+ } else {
+ const marginTop = styleProp.hasOwnProperty('marginTop')
+ ? styleProp.marginTop
+ : styleProp['margin-top'];
+ style.marginTop =
+ marginTop == null || typeof marginTop === 'boolean' ? '' : marginTop;
+ const marginBottom = styleProp.hasOwnProperty('marginBottom')
+ ? styleProp.marginBottom
+ : styleProp['margin-bottom'];
+ style.marginBottom =
+ marginBottom == null || typeof marginBottom === 'boolean'
export function cancelViewTransitionName(
diff --git a/packages/react-reconciler/src/ReactFiberApplyGesture.js b/packages/react-reconciler/src/ReactFiberApplyGesture.js
index 28f9ff3e3555d..d39413e45bcb6 100644
--- a/packages/react-reconciler/src/ReactFiberApplyGesture.js
+++ b/packages/react-reconciler/src/ReactFiberApplyGesture.js
@@ -834,18 +834,18 @@ function insertDestinationClonesOfFiber(
if (visitPhase === CLONE_EXIT || visitPhase === CLONE_UNHIDE) {
+ appendChild(hostParentClone, clone);
+ unhideInstance(clone, finishedWork.memoizedProps);
recursivelyInsertClones(
finishedWork,
clone,
null,
CLONE_APPEARING_PAIR,
);
- unhideInstance(clone, finishedWork.memoizedProps);
trackHostMutation();
} else {
- recursivelyInsertClones(finishedWork, clone, null, visitPhase);
appendChild(hostParentClone, clone);
+ recursivelyInsertClones(finishedWork, clone, null, visitPhase);
if (parentViewTransition !== null) {
if (parentViewTransition.clones === null) { | [
"+ let node: Node = nextNode;",
"+ const rects = instance.getClientRects();",
"+ const margin = styleProp.margin;",
"+ ? ''",
"+ : marginBottom;",
"- appendChild(hostParentClone, clone);"
] | [
39,
101,
162,
176,
177,
200
] | {
"additions": 122,
"author": "sebmarkbage",
"deletions": 6,
"html_url": "https://github.com/facebook/react/pull/32822",
"issue_id": 32822,
"merged_at": "2025-04-07T14:08:08Z",
"omission_probability": 0.1,
"pr_number": 32822,
"repo": "facebook/react",
"title": "Workaround against display: inline bug in Safari",
"total_changes": 128
} |
237 | diff --git a/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js b/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
index 47ae48eb767bd..24a9c4308a2f9 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
@@ -776,6 +776,74 @@ describe('ReactDOMFiberAsync', () => {
});
});
+ it('regression: useDeferredValue in popState leads to infinite deferral loop', async () => {
+ // At the time this test was written, it simulated a particular crash that
+ // was happened due to a combination of very subtle implementation details.
+ // Rather than couple this test to those implementation details, I've chosen
+ // to keep it as high-level as possible so that it doesn't break if the
+ // details change. In the future, it might not be trigger the exact set of
+ // internal circumstances anymore, but it could be useful for catching
+ // similar bugs because it represents a realistic real world situation β
+ // namely, switching tabs repeatedly in an app that uses useDeferredValue.
+ //
+ // But don't worry too much about why this test is written the way it is.
+
+ // Represents the browser's current location
+ let browserPathname = '/path/a';
+
+ let setPathname;
+ function App({initialPathname}) {
+ const [pathname, _setPathname] = React.useState('/path/a');
+ setPathname = _setPathname;
+
+ const deferredPathname = React.useDeferredValue(pathname);
+
+ // Attach a popstate listener on mount. Normally this would be in the
+ // in the router implementation.
+ React.useEffect(() => {
+ function onPopstate() {
+ React.startTransition(() => {
+ setPathname(browserPathname);
+ });
+ }
+ window.addEventListener('popstate', onPopstate);
+ return () => window.removeEventListener('popstate', onPopstate);
+ }, []);
+
+ return `Current: ${pathname}\nDeferred: ${deferredPathname}`;
+ }
+
+ const root = ReactDOMClient.createRoot(container);
+ await act(async () => {
+ root.render(<App initialPathname={browserPathname} />);
+ });
+
+ // Simulate a series of popstate events that toggle back and forth between
+ // two locations. In the original regression case, a certain combination
+ // of transition lanes would cause React to fall into an infinite deferral
+ // loop β specifically, when the spawned by the useDeferredValue hook was
+ // assigned a "higher" bit value than the one assigned to the "popstate".
+
+ // For alignment reasons, call this once to advance the internal variable
+ // that assigns transition lanes. Because this is a no-op update, it will
+ // bump the counter, but it won't trigger the useDeferredValue hook.
+ setPathname(browserPathname);
+
+ // Trigger enough popstate events that the scenario occurs for every
+ // possible transition lane.
+ for (let i = 0; i < 50; i++) {
+ await act(async () => {
+ // Simulate a popstate event
+ browserPathname = browserPathname === '/path/a' ? '/path/b' : '/path/a';
+ const popStateEvent = new Event('popstate');
+ window.event = popStateEvent;
+ window.dispatchEvent(popStateEvent);
+ await waitForMicrotasks();
+ window.event = undefined;
+ });
+ }
+ });
+
it('regression: infinite deferral loop caused by unstable useDeferredValue input', async () => {
function Text({text}) {
Scheduler.log(text);
diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js
index 6499c4ec7f6be..967be9be94fae 100644
--- a/packages/react-reconciler/src/ReactFiberHooks.js
+++ b/packages/react-reconciler/src/ReactFiberHooks.js
@@ -3033,7 +3033,9 @@ function updateDeferredValueImpl<T>(
return resultValue;
}
- const shouldDeferValue = !includesOnlyNonUrgentLanes(renderLanes);
+ const shouldDeferValue =
+ !includesOnlyNonUrgentLanes(renderLanes) &&
+ !includesSomeLane(renderLanes, DeferredLane);
if (shouldDeferValue) {
// This is an urgent update. Since the value has changed, keep using the
// previous value and spawn a deferred render to update it later.
| diff --git a/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js b/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
index 47ae48eb767bd..24a9c4308a2f9 100644
--- a/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
+++ b/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
@@ -776,6 +776,74 @@ describe('ReactDOMFiberAsync', () => {
});
});
+ // At the time this test was written, it simulated a particular crash that
+ // was happened due to a combination of very subtle implementation details.
+ // Rather than couple this test to those implementation details, I've chosen
+ // to keep it as high-level as possible so that it doesn't break if the
+ // internal circumstances anymore, but it could be useful for catching
+ // similar bugs because it represents a realistic real world situation β
+ //
+ // But don't worry too much about why this test is written the way it is.
+ // Represents the browser's current location
+ let browserPathname = '/path/a';
+ let setPathname;
+ function App({initialPathname}) {
+ const [pathname, _setPathname] = React.useState('/path/a');
+ setPathname = _setPathname;
+ const deferredPathname = React.useDeferredValue(pathname);
+ // Attach a popstate listener on mount. Normally this would be in the
+ // in the router implementation.
+ React.useEffect(() => {
+ function onPopstate() {
+ React.startTransition(() => {
+ setPathname(browserPathname);
+ });
+ }
+ window.addEventListener('popstate', onPopstate);
+ return () => window.removeEventListener('popstate', onPopstate);
+ const root = ReactDOMClient.createRoot(container);
+ await act(async () => {
+ root.render(<App initialPathname={browserPathname} />);
+ });
+ // Simulate a series of popstate events that toggle back and forth between
+ // two locations. In the original regression case, a certain combination
+ // of transition lanes would cause React to fall into an infinite deferral
+ // loop β specifically, when the spawned by the useDeferredValue hook was
+ // assigned a "higher" bit value than the one assigned to the "popstate".
+ // that assigns transition lanes. Because this is a no-op update, it will
+ // bump the counter, but it won't trigger the useDeferredValue hook.
+ setPathname(browserPathname);
+ // Trigger enough popstate events that the scenario occurs for every
+ // possible transition lane.
+ for (let i = 0; i < 50; i++) {
+ await act(async () => {
+ // Simulate a popstate event
+ const popStateEvent = new Event('popstate');
+ window.event = popStateEvent;
+ window.dispatchEvent(popStateEvent);
+ await waitForMicrotasks();
+ window.event = undefined;
+ });
+ });
it('regression: infinite deferral loop caused by unstable useDeferredValue input', async () => {
function Text({text}) {
Scheduler.log(text);
diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js
index 6499c4ec7f6be..967be9be94fae 100644
--- a/packages/react-reconciler/src/ReactFiberHooks.js
+++ b/packages/react-reconciler/src/ReactFiberHooks.js
@@ -3033,7 +3033,9 @@ function updateDeferredValueImpl<T>(
return resultValue;
}
- const shouldDeferValue = !includesOnlyNonUrgentLanes(renderLanes);
+ const shouldDeferValue =
+ !includesOnlyNonUrgentLanes(renderLanes) &&
+ !includesSomeLane(renderLanes, DeferredLane);
if (shouldDeferValue) {
// This is an urgent update. Since the value has changed, keep using the
// previous value and spawn a deferred render to update it later. | [
"+ it('regression: useDeferredValue in popState leads to infinite deferral loop', async () => {",
"+ // details change. In the future, it might not be trigger the exact set of",
"+ // namely, switching tabs repeatedly in an app that uses useDeferredValue.",
"+ }, []);",
"+ return `Current: ${pathname}\\nDeferred: ${deferredPathname}`;",
"+ // For alignment reasons, call this once to advance the internal variable",
"+ browserPathname = browserPathname === '/path/a' ? '/path/b' : '/path/a';"
] | [
8,
13,
16,
40,
42,
56,
66
] | {
"additions": 71,
"author": "acdlite",
"deletions": 1,
"html_url": "https://github.com/facebook/react/pull/32821",
"issue_id": 32821,
"merged_at": "2025-04-05T04:49:29Z",
"omission_probability": 0.1,
"pr_number": 32821,
"repo": "facebook/react",
"title": "[Bugfix] Infinite uDV loop in popstate event",
"total_changes": 72
} |
238 | diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js
index e13a76b340023..8cb2084ef1d33 100644
--- a/packages/react-reconciler/src/ReactFiberCommitWork.js
+++ b/packages/react-reconciler/src/ReactFiberCommitWork.js
@@ -119,6 +119,8 @@ import {
resetComponentEffectTimers,
pushComponentEffectStart,
popComponentEffectStart,
+ pushComponentEffectDuration,
+ popComponentEffectDuration,
pushComponentEffectErrors,
popComponentEffectErrors,
componentEffectStartTime,
@@ -543,6 +545,7 @@ function commitLayoutEffectOnFiber(
committedLanes: Lanes,
): void {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
// When updating this function, also update reappearLayoutEffects, which does
// most of the same things when an offscreen tree goes from hidden -> visible.
@@ -581,7 +584,7 @@ function commitLayoutEffectOnFiber(
break;
}
case HostRoot: {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraverseLayoutEffects(
finishedRoot,
finishedWork,
@@ -591,8 +594,9 @@ function commitLayoutEffectOnFiber(
commitRootCallbacks(finishedWork);
}
if (enableProfilerTimer && enableProfilerCommitHooks) {
- finishedRoot.effectDuration +=
- popNestedEffectDurations(prevEffectDuration);
+ finishedRoot.effectDuration += popNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
break;
}
@@ -638,7 +642,7 @@ function commitLayoutEffectOnFiber(
// TODO: Should this fire inside an offscreen tree? Or should it wait to
// fire when the tree becomes visible again.
if (flags & Update) {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraverseLayoutEffects(
finishedRoot,
@@ -651,8 +655,9 @@ function commitLayoutEffectOnFiber(
if (enableProfilerTimer && enableProfilerCommitHooks) {
// Propagate layout effect durations to the next nearest Profiler ancestor.
// Do not reset these values until the next render so DevTools has a chance to read them first.
- profilerInstance.effectDuration +=
- bubbleNestedEffectDurations(prevEffectDuration);
+ profilerInstance.effectDuration += bubbleNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
commitProfilerUpdate(
@@ -804,6 +809,7 @@ function commitLayoutEffectOnFiber(
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -1300,6 +1306,10 @@ function commitDeletionEffectsOnFiber(
// TODO: Delete this Hook once new DevTools ships everywhere. No longer needed.
onCommitUnmount(deletedFiber);
+ const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
+ const prevEffectErrors = pushComponentEffectErrors();
+
// The cases in this outer switch modify the stack before they traverse
// into their subtree. There are simpler cases in the inner switch
// that don't modify the stack.
@@ -1319,7 +1329,7 @@ function commitDeletionEffectsOnFiber(
} else if (deletedFiber.stateNode) {
unmountHoistable(deletedFiber.stateNode);
}
- return;
+ break;
}
// Fall through
}
@@ -1351,7 +1361,7 @@ function commitDeletionEffectsOnFiber(
hostParent = prevHostParent;
hostParentIsContainer = prevHostParentIsContainer;
- return;
+ break;
}
// Fall through
}
@@ -1406,7 +1416,7 @@ function commitDeletionEffectsOnFiber(
deletedFiber,
);
}
- return;
+ break;
}
case DehydratedFragment: {
if (enableSuspenseCallback) {
@@ -1445,7 +1455,7 @@ function commitDeletionEffectsOnFiber(
}
}
}
- return;
+ break;
}
case HostPortal: {
if (supportsMutation) {
@@ -1476,7 +1486,7 @@ function commitDeletionEffectsOnFiber(
deletedFiber,
);
}
- return;
+ break;
}
case FunctionComponent:
case ForwardRef:
@@ -1505,7 +1515,7 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
deletedFiber,
);
- return;
+ break;
}
case ClassComponent: {
if (!offscreenSubtreeWasHidden) {
@@ -1524,7 +1534,7 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
deletedFiber,
);
- return;
+ break;
}
case ScopeComponent: {
if (enableScopeAPI) {
@@ -1537,7 +1547,7 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
deletedFiber,
);
- return;
+ break;
}
case OffscreenComponent: {
if (disableLegacyMode || deletedFiber.mode & ConcurrentMode) {
@@ -1582,7 +1592,7 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
deletedFiber,
);
- return;
+ break;
}
// Fallthrough
}
@@ -1596,7 +1606,7 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
deletedFiber,
);
- return;
+ break;
}
// Fallthrough
}
@@ -1606,10 +1616,33 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
deletedFiber,
);
- return;
+ break;
}
}
+
+ if (
+ enableProfilerTimer &&
+ enableProfilerCommitHooks &&
+ enableComponentPerformanceTrack &&
+ (deletedFiber.mode & ProfileMode) !== NoMode &&
+ componentEffectStartTime >= 0 &&
+ componentEffectEndTime >= 0 &&
+ componentEffectDuration > 0.05
+ ) {
+ logComponentEffect(
+ deletedFiber,
+ componentEffectStartTime,
+ componentEffectEndTime,
+ componentEffectDuration,
+ componentEffectErrors,
+ );
+ }
+
+ popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
+ popComponentEffectErrors(prevEffectErrors);
}
+
function commitSuspenseCallback(finishedWork: Fiber) {
// TODO: Delete this feature. It's not properly covered by DEV features.
const newState: SuspenseState | null = finishedWork.memoizedState;
@@ -1796,6 +1829,7 @@ function commitMutationEffectsOnFiber(
lanes: Lanes,
) {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
const current = finishedWork.alternate;
const flags = finishedWork.flags;
@@ -2019,7 +2053,7 @@ function commitMutationEffectsOnFiber(
break;
}
case HostRoot: {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
if (supportsResources) {
prepareToCommitHoistables();
@@ -2065,7 +2099,9 @@ function commitMutationEffectsOnFiber(
}
if (enableProfilerTimer && enableProfilerCommitHooks) {
- root.effectDuration += popNestedEffectDurations(prevEffectDuration);
+ root.effectDuration += popNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
break;
@@ -2105,7 +2141,7 @@ function commitMutationEffectsOnFiber(
break;
}
case Profiler: {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraverseMutationEffects(root, finishedWork, lanes);
commitReconciliationEffects(finishedWork, lanes);
@@ -2114,8 +2150,9 @@ function commitMutationEffectsOnFiber(
const profilerInstance = finishedWork.stateNode;
// Propagate layout effect durations to the next nearest Profiler ancestor.
// Do not reset these values until the next render so DevTools has a chance to read them first.
- profilerInstance.effectDuration +=
- bubbleNestedEffectDurations(prevEffectDuration);
+ profilerInstance.effectDuration += bubbleNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
break;
}
@@ -2347,6 +2384,7 @@ function commitMutationEffectsOnFiber(
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -2598,6 +2636,7 @@ function recursivelyTraverseLayoutEffects(
export function disappearLayoutEffects(finishedWork: Fiber) {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
switch (finishedWork.tag) {
case FunctionComponent:
@@ -2701,6 +2740,7 @@ export function disappearLayoutEffects(finishedWork: Fiber) {
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -2723,6 +2763,7 @@ export function reappearLayoutEffects(
includeWorkInProgressEffects: boolean,
) {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
// Turn on layout effects in a tree that previously disappeared.
const flags = finishedWork.flags;
@@ -2806,7 +2847,7 @@ export function reappearLayoutEffects(
case Profiler: {
// TODO: Figure out how Profiler updates should work with Offscreen
if (includeWorkInProgressEffects && flags & Update) {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraverseReappearLayoutEffects(
finishedRoot,
@@ -2819,8 +2860,9 @@ export function reappearLayoutEffects(
if (enableProfilerTimer && enableProfilerCommitHooks) {
// Propagate layout effect durations to the next nearest Profiler ancestor.
// Do not reset these values until the next render so DevTools has a chance to read them first.
- profilerInstance.effectDuration +=
- bubbleNestedEffectDurations(prevEffectDuration);
+ profilerInstance.effectDuration += bubbleNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
commitProfilerUpdate(
@@ -2919,6 +2961,7 @@ export function reappearLayoutEffects(
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -3169,6 +3212,7 @@ function commitPassiveMountOnFiber(
endTime: number, // Profiling-only. The start time of the next Fiber or root completion.
): void {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
const isViewTransitionEligible = enableViewTransition
@@ -3272,7 +3316,7 @@ function commitPassiveMountOnFiber(
break;
}
case HostRoot: {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
const wasInHydratedSubtree = inHydratedSubtree;
if (enableProfilerTimer && enableComponentPerformanceTrack) {
@@ -3349,15 +3393,16 @@ function commitPassiveMountOnFiber(
}
}
if (enableProfilerTimer && enableProfilerCommitHooks) {
- finishedRoot.passiveEffectDuration +=
- popNestedEffectDurations(prevEffectDuration);
+ finishedRoot.passiveEffectDuration += popNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
break;
}
case Profiler: {
// Only Profilers with work in their subtree will have a Passive effect scheduled.
if (flags & Passive) {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraversePassiveMountEffects(
finishedRoot,
@@ -3372,8 +3417,9 @@ function commitPassiveMountOnFiber(
if (enableProfilerTimer && enableProfilerCommitHooks) {
// Bubble times to the next nearest ancestor Profiler.
// After we process that Profiler, we'll bubble further up.
- profilerInstance.passiveEffectDuration +=
- bubbleNestedEffectDurations(prevEffectDuration);
+ profilerInstance.passiveEffectDuration += bubbleNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
commitProfilerPostCommit(
@@ -3657,6 +3703,7 @@ function commitPassiveMountOnFiber(
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -3717,6 +3764,7 @@ export function reconnectPassiveEffects(
endTime: number, // Profiling-only. The start time of the next Fiber or root completion.
) {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
// If this component rendered in Profiling mode (DEV or in Profiler component) then log its
// render time. We do this after the fact in the passive effect to avoid the overhead of this
@@ -3916,6 +3964,7 @@ export function reconnectPassiveEffects(
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -4218,6 +4267,7 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber: Fiber): void {
function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
switch (finishedWork.tag) {
case FunctionComponent:
@@ -4234,17 +4284,18 @@ function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
break;
}
case HostRoot: {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraversePassiveUnmountEffects(finishedWork);
if (enableProfilerTimer && enableProfilerCommitHooks) {
const finishedRoot: FiberRoot = finishedWork.stateNode;
- finishedRoot.passiveEffectDuration +=
- popNestedEffectDurations(prevEffectDuration);
+ finishedRoot.passiveEffectDuration += popNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
break;
}
case Profiler: {
- const prevEffectDuration = pushNestedEffectDurations();
+ const prevProfilerEffectDuration = pushNestedEffectDurations();
recursivelyTraversePassiveUnmountEffects(finishedWork);
@@ -4252,8 +4303,9 @@ function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
const profilerInstance = finishedWork.stateNode;
// Propagate layout effect durations to the next nearest Profiler ancestor.
// Do not reset these values until the next render so DevTools has a chance to read them first.
- profilerInstance.passiveEffectDuration +=
- bubbleNestedEffectDurations(prevEffectDuration);
+ profilerInstance.passiveEffectDuration += bubbleNestedEffectDurations(
+ prevProfilerEffectDuration,
+ );
}
break;
}
@@ -4308,6 +4360,7 @@ function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
@@ -4340,6 +4393,10 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber: Fiber): void {
}
export function disconnectPassiveEffect(finishedWork: Fiber): void {
+ const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
+ const prevEffectErrors = pushComponentEffectErrors();
+
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
@@ -4370,6 +4427,28 @@ export function disconnectPassiveEffect(finishedWork: Fiber): void {
break;
}
}
+
+ if (
+ enableProfilerTimer &&
+ enableProfilerCommitHooks &&
+ enableComponentPerformanceTrack &&
+ (finishedWork.mode & ProfileMode) !== NoMode &&
+ componentEffectStartTime >= 0 &&
+ componentEffectEndTime >= 0 &&
+ componentEffectDuration > 0.05
+ ) {
+ logComponentEffect(
+ finishedWork,
+ componentEffectStartTime,
+ componentEffectEndTime,
+ componentEffectDuration,
+ componentEffectErrors,
+ );
+ }
+
+ popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
+ popComponentEffectErrors(prevEffectErrors);
}
function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(
@@ -4428,6 +4507,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
nearestMountedAncestor: Fiber | null,
): void {
const prevEffectStart = pushComponentEffectStart();
+ const prevEffectDuration = pushComponentEffectDuration();
const prevEffectErrors = pushComponentEffectErrors();
switch (current.tag) {
case FunctionComponent:
@@ -4560,6 +4640,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
}
popComponentEffectStart(prevEffectStart);
+ popComponentEffectDuration(prevEffectDuration);
popComponentEffectErrors(prevEffectErrors);
}
diff --git a/packages/react-reconciler/src/ReactProfilerTimer.js b/packages/react-reconciler/src/ReactProfilerTimer.js
index bc289bcab6321..16f4ef1ae09b6 100644
--- a/packages/react-reconciler/src/ReactProfilerTimer.js
+++ b/packages/react-reconciler/src/ReactProfilerTimer.js
@@ -272,7 +272,6 @@ export function pushComponentEffectStart(): number {
}
const prevEffectStart = componentEffectStartTime;
componentEffectStartTime = -1.1; // Track the next start.
- componentEffectDuration = -0; // Reset component level duration.
return prevEffectStart;
}
@@ -287,6 +286,26 @@ export function popComponentEffectStart(prevEffectStart: number): void {
}
}
+export function pushComponentEffectDuration(): number {
+ if (!enableProfilerTimer || !enableProfilerCommitHooks) {
+ return 0;
+ }
+ const prevEffectDuration = componentEffectDuration;
+ componentEffectDuration = -0; // Reset component level duration.
+ return prevEffectDuration;
+}
+
+export function popComponentEffectDuration(prevEffectDuration: number): void {
+ if (!enableProfilerTimer || !enableProfilerCommitHooks) {
+ return;
+ }
+ // If the parent component didn't have a start time, we let this current time persist.
+ if (prevEffectDuration >= 0) {
+ // Otherwise, we restore the previous parent's start time.
+ componentEffectDuration = prevEffectDuration;
+ }
+}
+
export function pushComponentEffectErrors(): null | Array<
CapturedValue<mixed>,
> {
| diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js
index e13a76b340023..8cb2084ef1d33 100644
--- a/packages/react-reconciler/src/ReactFiberCommitWork.js
+++ b/packages/react-reconciler/src/ReactFiberCommitWork.js
@@ -119,6 +119,8 @@ import {
resetComponentEffectTimers,
pushComponentEffectStart,
popComponentEffectStart,
+ pushComponentEffectDuration,
+ popComponentEffectDuration,
pushComponentEffectErrors,
popComponentEffectErrors,
componentEffectStartTime,
@@ -543,6 +545,7 @@ function commitLayoutEffectOnFiber(
committedLanes: Lanes,
// When updating this function, also update reappearLayoutEffects, which does
// most of the same things when an offscreen tree goes from hidden -> visible.
@@ -581,7 +584,7 @@ function commitLayoutEffectOnFiber(
recursivelyTraverseLayoutEffects(
finishedRoot,
finishedWork,
@@ -591,8 +594,9 @@ function commitLayoutEffectOnFiber(
commitRootCallbacks(finishedWork);
- finishedRoot.effectDuration +=
+ finishedRoot.effectDuration += popNestedEffectDurations(
@@ -638,7 +642,7 @@ function commitLayoutEffectOnFiber(
// TODO: Should this fire inside an offscreen tree? Or should it wait to
// fire when the tree becomes visible again.
if (flags & Update) {
recursivelyTraverseLayoutEffects(
@@ -651,8 +655,9 @@ function commitLayoutEffectOnFiber(
@@ -804,6 +809,7 @@ function commitLayoutEffectOnFiber(
@@ -1300,6 +1306,10 @@ function commitDeletionEffectsOnFiber(
// TODO: Delete this Hook once new DevTools ships everywhere. No longer needed.
onCommitUnmount(deletedFiber);
// The cases in this outer switch modify the stack before they traverse
// into their subtree. There are simpler cases in the inner switch
// that don't modify the stack.
@@ -1319,7 +1329,7 @@ function commitDeletionEffectsOnFiber(
} else if (deletedFiber.stateNode) {
unmountHoistable(deletedFiber.stateNode);
@@ -1351,7 +1361,7 @@ function commitDeletionEffectsOnFiber(
hostParent = prevHostParent;
hostParentIsContainer = prevHostParentIsContainer;
@@ -1406,7 +1416,7 @@ function commitDeletionEffectsOnFiber(
case DehydratedFragment: {
if (enableSuspenseCallback) {
@@ -1445,7 +1455,7 @@ function commitDeletionEffectsOnFiber(
}
case HostPortal: {
if (supportsMutation) {
@@ -1476,7 +1486,7 @@ function commitDeletionEffectsOnFiber(
@@ -1505,7 +1515,7 @@ function commitDeletionEffectsOnFiber(
case ClassComponent: {
if (!offscreenSubtreeWasHidden) {
@@ -1524,7 +1534,7 @@ function commitDeletionEffectsOnFiber(
case ScopeComponent: {
if (enableScopeAPI) {
@@ -1537,7 +1547,7 @@ function commitDeletionEffectsOnFiber(
case OffscreenComponent: {
if (disableLegacyMode || deletedFiber.mode & ConcurrentMode) {
@@ -1582,7 +1592,7 @@ function commitDeletionEffectsOnFiber(
@@ -1596,7 +1606,7 @@ function commitDeletionEffectsOnFiber(
@@ -1606,10 +1616,33 @@ function commitDeletionEffectsOnFiber(
+ (deletedFiber.mode & ProfileMode) !== NoMode &&
+ deletedFiber,
function commitSuspenseCallback(finishedWork: Fiber) {
// TODO: Delete this feature. It's not properly covered by DEV features.
const newState: SuspenseState | null = finishedWork.memoizedState;
@@ -1796,6 +1829,7 @@ function commitMutationEffectsOnFiber(
lanes: Lanes,
const current = finishedWork.alternate;
@@ -2019,7 +2053,7 @@ function commitMutationEffectsOnFiber(
if (supportsResources) {
prepareToCommitHoistables();
@@ -2065,7 +2099,9 @@ function commitMutationEffectsOnFiber(
- root.effectDuration += popNestedEffectDurations(prevEffectDuration);
+ root.effectDuration += popNestedEffectDurations(
@@ -2105,7 +2141,7 @@ function commitMutationEffectsOnFiber(
recursivelyTraverseMutationEffects(root, finishedWork, lanes);
commitReconciliationEffects(finishedWork, lanes);
@@ -2114,8 +2150,9 @@ function commitMutationEffectsOnFiber(
- profilerInstance.effectDuration +=
+ profilerInstance.effectDuration += bubbleNestedEffectDurations(
@@ -2347,6 +2384,7 @@ function commitMutationEffectsOnFiber(
@@ -2598,6 +2636,7 @@ function recursivelyTraverseLayoutEffects(
export function disappearLayoutEffects(finishedWork: Fiber) {
@@ -2701,6 +2740,7 @@ export function disappearLayoutEffects(finishedWork: Fiber) {
@@ -2723,6 +2763,7 @@ export function reappearLayoutEffects(
includeWorkInProgressEffects: boolean,
// Turn on layout effects in a tree that previously disappeared.
@@ -2806,7 +2847,7 @@ export function reappearLayoutEffects(
// TODO: Figure out how Profiler updates should work with Offscreen
if (includeWorkInProgressEffects && flags & Update) {
recursivelyTraverseReappearLayoutEffects(
@@ -2819,8 +2860,9 @@ export function reappearLayoutEffects(
@@ -2919,6 +2961,7 @@ export function reappearLayoutEffects(
@@ -3169,6 +3212,7 @@ function commitPassiveMountOnFiber(
const isViewTransitionEligible = enableViewTransition
@@ -3272,7 +3316,7 @@ function commitPassiveMountOnFiber(
const wasInHydratedSubtree = inHydratedSubtree;
if (enableProfilerTimer && enableComponentPerformanceTrack) {
@@ -3349,15 +3393,16 @@ function commitPassiveMountOnFiber(
// Only Profilers with work in their subtree will have a Passive effect scheduled.
if (flags & Passive) {
recursivelyTraversePassiveMountEffects(
@@ -3372,8 +3417,9 @@ function commitPassiveMountOnFiber(
// Bubble times to the next nearest ancestor Profiler.
// After we process that Profiler, we'll bubble further up.
- profilerInstance.passiveEffectDuration +=
+ profilerInstance.passiveEffectDuration += bubbleNestedEffectDurations(
commitProfilerPostCommit(
@@ -3657,6 +3703,7 @@ function commitPassiveMountOnFiber(
@@ -3717,6 +3764,7 @@ export function reconnectPassiveEffects(
// If this component rendered in Profiling mode (DEV or in Profiler component) then log its
// render time. We do this after the fact in the passive effect to avoid the overhead of this
@@ -3916,6 +3964,7 @@ export function reconnectPassiveEffects(
@@ -4218,6 +4267,7 @@ function recursivelyTraversePassiveUnmountEffects(parentFiber: Fiber): void {
function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
@@ -4234,17 +4284,18 @@ function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
const finishedRoot: FiberRoot = finishedWork.stateNode;
@@ -4252,8 +4303,9 @@ function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
- profilerInstance.passiveEffectDuration +=
+ profilerInstance.passiveEffectDuration += bubbleNestedEffectDurations(
@@ -4308,6 +4360,7 @@ function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
@@ -4340,6 +4393,10 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber: Fiber): void {
export function disconnectPassiveEffect(finishedWork: Fiber): void {
@@ -4370,6 +4427,28 @@ export function disconnectPassiveEffect(finishedWork: Fiber): void {
+ (finishedWork.mode & ProfileMode) !== NoMode &&
+ finishedWork,
function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(
@@ -4428,6 +4507,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
nearestMountedAncestor: Fiber | null,
switch (current.tag) {
@@ -4560,6 +4640,7 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
diff --git a/packages/react-reconciler/src/ReactProfilerTimer.js b/packages/react-reconciler/src/ReactProfilerTimer.js
index bc289bcab6321..16f4ef1ae09b6 100644
--- a/packages/react-reconciler/src/ReactProfilerTimer.js
+++ b/packages/react-reconciler/src/ReactProfilerTimer.js
@@ -272,7 +272,6 @@ export function pushComponentEffectStart(): number {
const prevEffectStart = componentEffectStartTime;
componentEffectStartTime = -1.1; // Track the next start.
- componentEffectDuration = -0; // Reset component level duration.
return prevEffectStart;
@@ -287,6 +286,26 @@ export function popComponentEffectStart(prevEffectStart: number): void {
+export function pushComponentEffectDuration(): number {
+ return 0;
+ const prevEffectDuration = componentEffectDuration;
+ componentEffectDuration = -0; // Reset component level duration.
+ return prevEffectDuration;
+export function popComponentEffectDuration(prevEffectDuration: number): void {
+ return;
+ // If the parent component didn't have a start time, we let this current time persist.
+ if (prevEffectDuration >= 0) {
+ // Otherwise, we restore the previous parent's start time.
+ componentEffectDuration = prevEffectDuration;
export function pushComponentEffectErrors(): null | Array<
CapturedValue<mixed>,
> { | [] | [] | {
"additions": 138,
"author": "sebmarkbage",
"deletions": 38,
"html_url": "https://github.com/facebook/react/pull/32815",
"issue_id": 32815,
"merged_at": "2025-04-04T03:33:14Z",
"omission_probability": 0.1,
"pr_number": 32815,
"repo": "facebook/react",
"title": "Fix Bugs Measuring Performance Track for Effects",
"total_changes": 176
} |
239 | diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
index a98d2b76961f7..a1e4c49e15573 100644
--- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
+++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
@@ -1129,6 +1129,34 @@ const tests = {
`,
errors: [asyncComponentHookError('useState')],
},
+ {
+ code: normalizeIndent`
+ async function Page() {
+ useId();
+ React.useId();
+ }
+ `,
+ errors: [
+ asyncComponentHookError('useId'),
+ asyncComponentHookError('React.useId'),
+ ],
+ },
+ {
+ code: normalizeIndent`
+ async function useAsyncHook() {
+ useId();
+ }
+ `,
+ errors: [asyncComponentHookError('useId')],
+ },
+ {
+ code: normalizeIndent`
+ async function notAHook() {
+ useId();
+ }
+ `,
+ errors: [functionError('useId', 'notAHook')],
+ },
{
code: normalizeIndent`
Hook.use();
| diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
index a98d2b76961f7..a1e4c49e15573 100644
--- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
+++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
@@ -1129,6 +1129,34 @@ const tests = {
`,
errors: [asyncComponentHookError('useState')],
},
+ async function Page() {
+ React.useId();
+ errors: [
+ asyncComponentHookError('useId'),
+ asyncComponentHookError('React.useId'),
+ ],
+ async function useAsyncHook() {
+ errors: [asyncComponentHookError('useId')],
+ async function notAHook() {
{
code: normalizeIndent`
Hook.use(); | [
"+ errors: [functionError('useId', 'notAHook')],"
] | [
34
] | {
"additions": 28,
"author": "eps1lon",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/31208",
"issue_id": 31208,
"merged_at": "2024-10-15T15:17:41Z",
"omission_probability": 0.1,
"pr_number": 31208,
"repo": "facebook/react",
"title": "[ESLint] Add test for rejected `useId` in async Components",
"total_changes": 28
} |
240 | diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js
index 0c1acc99cbe58..2c047447eeb72 100644
--- a/packages/react-devtools-shared/src/backend/fiber/renderer.js
+++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js
@@ -3345,13 +3345,31 @@ export function attach(
fiberInstance.firstChild = null;
}
try {
- if (nextFiber.tag === HostHoistable) {
+ if (
+ nextFiber.tag === HostHoistable &&
+ prevFiber.memoizedState !== nextFiber.memoizedState
+ ) {
const nearestInstance = reconcilingParent;
if (nearestInstance === null) {
throw new Error('Did not expect a host hoistable to be the root');
}
releaseHostResource(nearestInstance, prevFiber.memoizedState);
aquireHostResource(nearestInstance, nextFiber.memoizedState);
+ } else if (
+ (nextFiber.tag === HostComponent ||
+ nextFiber.tag === HostText ||
+ nextFiber.tag === HostSingleton) &&
+ prevFiber.stateNode !== nextFiber.stateNode
+ ) {
+ // In persistent mode, it's possible for the stateNode to update with
+ // a new clone. In that case we need to release the old one and aquire
+ // new one instead.
+ const nearestInstance = reconcilingParent;
+ if (nearestInstance === null) {
+ throw new Error('Did not expect a host hoistable to be the root');
+ }
+ releaseHostInstance(nearestInstance, prevFiber.stateNode);
+ aquireHostInstance(nearestInstance, nextFiber.stateNode);
}
const isSuspense = nextFiber.tag === SuspenseComponent;
| diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js
index 0c1acc99cbe58..2c047447eeb72 100644
--- a/packages/react-devtools-shared/src/backend/fiber/renderer.js
+++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js
@@ -3345,13 +3345,31 @@ export function attach(
fiberInstance.firstChild = null;
}
try {
- if (nextFiber.tag === HostHoistable) {
+ if (
+ nextFiber.tag === HostHoistable &&
+ prevFiber.memoizedState !== nextFiber.memoizedState
const nearestInstance = reconcilingParent;
if (nearestInstance === null) {
throw new Error('Did not expect a host hoistable to be the root');
}
releaseHostResource(nearestInstance, prevFiber.memoizedState);
aquireHostResource(nearestInstance, nextFiber.memoizedState);
+ } else if (
+ (nextFiber.tag === HostComponent ||
+ nextFiber.tag === HostText ||
+ nextFiber.tag === HostSingleton) &&
+ prevFiber.stateNode !== nextFiber.stateNode
+ // In persistent mode, it's possible for the stateNode to update with
+ // a new clone. In that case we need to release the old one and aquire
+ // new one instead.
+ const nearestInstance = reconcilingParent;
+ throw new Error('Did not expect a host hoistable to be the root');
+ }
+ releaseHostInstance(nearestInstance, prevFiber.stateNode);
+ aquireHostInstance(nearestInstance, nextFiber.stateNode);
}
const isSuspense = nextFiber.tag === SuspenseComponent; | [
"+ if (nearestInstance === null) {"
] | [
29
] | {
"additions": 19,
"author": "sebmarkbage",
"deletions": 1,
"html_url": "https://github.com/facebook/react/pull/32812",
"issue_id": 32812,
"merged_at": "2025-04-03T14:06:04Z",
"omission_probability": 0.1,
"pr_number": 32812,
"repo": "facebook/react",
"title": "[DevTools] Release and aquire host instances when they're cloned in persistent mode",
"total_changes": 20
} |
241 | diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js
index d06a47e9d3d08..0c1acc99cbe58 100644
--- a/packages/react-devtools-shared/src/backend/fiber/renderer.js
+++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js
@@ -808,6 +808,27 @@ function getPublicInstance(instance: HostInstance): HostInstance {
return instance;
}
+function getNativeTag(instance: HostInstance): number | null {
+ if (typeof instance !== 'object' || instance === null) {
+ return null;
+ }
+
+ // Modern. Fabric.
+ if (
+ instance.canonical != null &&
+ typeof instance.canonical.nativeTag === 'number'
+ ) {
+ return instance.canonical.nativeTag;
+ }
+
+ // Legacy. Paper.
+ if (typeof instance._nativeTag === 'number') {
+ return instance._nativeTag;
+ }
+
+ return null;
+}
+
function aquireHostInstance(
nearestInstance: DevToolsInstance,
hostInstance: HostInstance,
@@ -4298,6 +4319,11 @@ export function attach(
componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
}
+ let nativeTag = null;
+ if (elementType === ElementTypeHostComponent) {
+ nativeTag = getNativeTag(fiber.stateNode);
+ }
+
return {
id: fiberInstance.id,
@@ -4364,6 +4390,8 @@ export function attach(
rendererVersion: renderer.version,
plugins,
+
+ nativeTag,
};
}
@@ -4457,6 +4485,8 @@ export function attach(
rendererVersion: renderer.version,
plugins,
+
+ nativeTag: null,
};
}
diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js
index 8e26dcae445ee..cbcc37e319ee6 100644
--- a/packages/react-devtools-shared/src/backend/legacy/renderer.js
+++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js
@@ -859,6 +859,8 @@ export function attach(
plugins: {
stylex: null,
},
+
+ nativeTag: null,
};
}
diff --git a/packages/react-devtools-shared/src/backend/types.js b/packages/react-devtools-shared/src/backend/types.js
index 56fb9a8ec315b..f9f11586a022d 100644
--- a/packages/react-devtools-shared/src/backend/types.js
+++ b/packages/react-devtools-shared/src/backend/types.js
@@ -294,6 +294,9 @@ export type InspectedElement = {
// UI plugins/visualizations for the inspected element.
plugins: Plugins,
+
+ // React Native only.
+ nativeTag: number | null,
};
export const InspectElementErrorType = 'error';
diff --git a/packages/react-devtools-shared/src/backendAPI.js b/packages/react-devtools-shared/src/backendAPI.js
index 7a8bb801445c1..b3668b9d98c99 100644
--- a/packages/react-devtools-shared/src/backendAPI.js
+++ b/packages/react-devtools-shared/src/backendAPI.js
@@ -239,6 +239,7 @@ export function convertInspectedElementBackendToFrontend(
key,
errors,
warnings,
+ nativeTag,
} = inspectedElementBackend;
const inspectedElement: InspectedElementFrontend = {
@@ -273,6 +274,7 @@ export function convertInspectedElementBackendToFrontend(
state: hydrateHelper(state),
errors,
warnings,
+ nativeTag,
};
return inspectedElement;
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js
index 9a069b484b5ed..07e303dbc71bc 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js
@@ -11,21 +11,25 @@ import * as React from 'react';
import Badge from './Badge';
import ForgetBadge from './ForgetBadge';
+import NativeTagBadge from './NativeTagBadge';
import styles from './InspectedElementBadges.css';
type Props = {
hocDisplayNames: null | Array<string>,
compiledWithForget: boolean,
+ nativeTag: number | null,
};
export default function InspectedElementBadges({
hocDisplayNames,
compiledWithForget,
+ nativeTag,
}: Props): React.Node {
if (
!compiledWithForget &&
- (hocDisplayNames == null || hocDisplayNames.length === 0)
+ (hocDisplayNames == null || hocDisplayNames.length === 0) &&
+ nativeTag === null
) {
return null;
}
@@ -33,6 +37,7 @@ export default function InspectedElementBadges({
return (
<div className={styles.Root}>
{compiledWithForget && <ForgetBadge indexable={false} />}
+ {nativeTag !== null && <NativeTagBadge nativeTag={nativeTag} />}
{hocDisplayNames !== null &&
hocDisplayNames.map(hocDisplayName => (
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
index 8eec411492976..7e18ad5cd715c 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
@@ -54,8 +54,14 @@ export default function InspectedElementView({
toggleParseHookNames,
symbolicatedSourcePromise,
}: Props): React.Node {
- const {owners, rendererPackageName, rendererVersion, rootType, source} =
- inspectedElement;
+ const {
+ owners,
+ rendererPackageName,
+ rendererVersion,
+ rootType,
+ source,
+ nativeTag,
+ } = inspectedElement;
const bridge = useContext(BridgeContext);
const store = useContext(StoreContext);
@@ -75,6 +81,7 @@ export default function InspectedElementView({
<InspectedElementBadges
hocDisplayNames={element.hocDisplayNames}
compiledWithForget={element.compiledWithForget}
+ nativeTag={nativeTag}
/>
</div>
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.css b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.css
new file mode 100644
index 0000000000000..7188a53743432
--- /dev/null
+++ b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.css
@@ -0,0 +1,11 @@
+.Toggle {
+ display: flex;
+}
+
+.Toggle > span { /* targets .ToggleContent */
+ padding: 0;
+}
+
+.Badge {
+ cursor: help;
+}
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.js b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.js
new file mode 100644
index 0000000000000..118255b536a09
--- /dev/null
+++ b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.js
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+import * as React from 'react';
+
+import Badge from './Badge';
+import Toggle from '../Toggle';
+
+import styles from './NativeTagBadge.css';
+
+type Props = {
+ nativeTag: number,
+};
+
+const noop = () => {};
+const title =
+ 'Unique identifier for the corresponding native component. React Native only.';
+
+export default function NativeTagBadge({nativeTag}: Props): React.Node {
+ return (
+ <Toggle onChange={noop} className={styles.Toggle} title={title}>
+ <Badge className={styles.Badge}>Tag {nativeTag}</Badge>
+ </Toggle>
+ );
+}
diff --git a/packages/react-devtools-shared/src/frontend/types.js b/packages/react-devtools-shared/src/frontend/types.js
index 827ba4dccb97e..af4aac55037f8 100644
--- a/packages/react-devtools-shared/src/frontend/types.js
+++ b/packages/react-devtools-shared/src/frontend/types.js
@@ -259,6 +259,9 @@ export type InspectedElement = {
// UI plugins/visualizations for the inspected element.
plugins: Plugins,
+
+ // React Native only.
+ nativeTag: number | null,
};
// TODO: Add profiling type
| diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js
index d06a47e9d3d08..0c1acc99cbe58 100644
--- a/packages/react-devtools-shared/src/backend/fiber/renderer.js
+++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js
@@ -808,6 +808,27 @@ function getPublicInstance(instance: HostInstance): HostInstance {
return instance;
}
+ if (typeof instance !== 'object' || instance === null) {
+ return null;
+ // Modern. Fabric.
+ if (
+ instance.canonical != null &&
+ typeof instance.canonical.nativeTag === 'number'
+ ) {
+ return instance.canonical.nativeTag;
+ // Legacy. Paper.
+ if (typeof instance._nativeTag === 'number') {
+ return instance._nativeTag;
+ return null;
function aquireHostInstance(
nearestInstance: DevToolsInstance,
hostInstance: HostInstance,
@@ -4298,6 +4319,11 @@ export function attach(
componentLogsEntry = fiberToComponentLogsMap.get(fiber.alternate);
}
+ let nativeTag = null;
+ if (elementType === ElementTypeHostComponent) {
+ nativeTag = getNativeTag(fiber.stateNode);
+ }
return {
id: fiberInstance.id,
@@ -4364,6 +4390,8 @@ export function attach(
+ nativeTag,
@@ -4457,6 +4485,8 @@ export function attach(
diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js
index 8e26dcae445ee..cbcc37e319ee6 100644
--- a/packages/react-devtools-shared/src/backend/legacy/renderer.js
+++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js
@@ -859,6 +859,8 @@ export function attach(
plugins: {
stylex: null,
},
diff --git a/packages/react-devtools-shared/src/backend/types.js b/packages/react-devtools-shared/src/backend/types.js
index 56fb9a8ec315b..f9f11586a022d 100644
--- a/packages/react-devtools-shared/src/backend/types.js
+++ b/packages/react-devtools-shared/src/backend/types.js
@@ -294,6 +294,9 @@ export type InspectedElement = {
export const InspectElementErrorType = 'error';
diff --git a/packages/react-devtools-shared/src/backendAPI.js b/packages/react-devtools-shared/src/backendAPI.js
index 7a8bb801445c1..b3668b9d98c99 100644
--- a/packages/react-devtools-shared/src/backendAPI.js
+++ b/packages/react-devtools-shared/src/backendAPI.js
@@ -239,6 +239,7 @@ export function convertInspectedElementBackendToFrontend(
key,
} = inspectedElementBackend;
const inspectedElement: InspectedElementFrontend = {
@@ -273,6 +274,7 @@ export function convertInspectedElementBackendToFrontend(
state: hydrateHelper(state),
};
return inspectedElement;
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js
index 9a069b484b5ed..07e303dbc71bc 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementBadges.js
@@ -11,21 +11,25 @@ import * as React from 'react';
import Badge from './Badge';
import ForgetBadge from './ForgetBadge';
+import NativeTagBadge from './NativeTagBadge';
import styles from './InspectedElementBadges.css';
type Props = {
hocDisplayNames: null | Array<string>,
compiledWithForget: boolean,
export default function InspectedElementBadges({
hocDisplayNames,
compiledWithForget,
+ nativeTag,
if (
!compiledWithForget &&
- (hocDisplayNames == null || hocDisplayNames.length === 0)
+ (hocDisplayNames == null || hocDisplayNames.length === 0) &&
+ nativeTag === null
) {
return null;
@@ -33,6 +37,7 @@ export default function InspectedElementBadges({
return (
<div className={styles.Root}>
{compiledWithForget && <ForgetBadge indexable={false} />}
+ {nativeTag !== null && <NativeTagBadge nativeTag={nativeTag} />}
{hocDisplayNames !== null &&
hocDisplayNames.map(hocDisplayName => (
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
index 8eec411492976..7e18ad5cd715c 100644
--- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
+++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js
@@ -54,8 +54,14 @@ export default function InspectedElementView({
toggleParseHookNames,
symbolicatedSourcePromise,
- const {owners, rendererPackageName, rendererVersion, rootType, source} =
- inspectedElement;
+ owners,
+ rendererPackageName,
+ rendererVersion,
+ rootType,
+ } = inspectedElement;
const bridge = useContext(BridgeContext);
const store = useContext(StoreContext);
@@ -75,6 +81,7 @@ export default function InspectedElementView({
<InspectedElementBadges
hocDisplayNames={element.hocDisplayNames}
compiledWithForget={element.compiledWithForget}
+ nativeTag={nativeTag}
/>
</div>
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.css b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.css
index 0000000000000..7188a53743432
+++ b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.css
@@ -0,0 +1,11 @@
+.Toggle {
+ display: flex;
+.Toggle > span { /* targets .ToggleContent */
+ padding: 0;
+.Badge {
+ cursor: help;
diff --git a/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.js b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.js
index 0000000000000..118255b536a09
+++ b/packages/react-devtools-shared/src/devtools/views/Components/NativeTagBadge.js
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ * @flow
+ */
+import * as React from 'react';
+import Badge from './Badge';
+import styles from './NativeTagBadge.css';
+type Props = {
+ nativeTag: number,
+};
+const noop = () => {};
+const title =
+ 'Unique identifier for the corresponding native component. React Native only.';
+export default function NativeTagBadge({nativeTag}: Props): React.Node {
+ return (
+ <Toggle onChange={noop} className={styles.Toggle} title={title}>
+ <Badge className={styles.Badge}>Tag {nativeTag}</Badge>
+ </Toggle>
+ );
diff --git a/packages/react-devtools-shared/src/frontend/types.js b/packages/react-devtools-shared/src/frontend/types.js
index 827ba4dccb97e..af4aac55037f8 100644
--- a/packages/react-devtools-shared/src/frontend/types.js
+++ b/packages/react-devtools-shared/src/frontend/types.js
@@ -259,6 +259,9 @@ export type InspectedElement = {
// TODO: Add profiling type | [
"+function getNativeTag(instance: HostInstance): number | null {",
"+ const {",
"+ source,",
"+import Toggle from '../Toggle';"
] | [
8,
158,
163,
212
] | {
"additions": 97,
"author": "hoxyq",
"deletions": 3,
"html_url": "https://github.com/facebook/react/pull/32762",
"issue_id": 32762,
"merged_at": "2025-04-02T21:44:38Z",
"omission_probability": 0.1,
"pr_number": 32762,
"repo": "facebook/react",
"title": "feat[devtools]: display native tag for host components for Native",
"total_changes": 100
} |
242 | diff --git a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js
index ae48ed383413a..3a36572e8ab02 100644
--- a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js
+++ b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js
@@ -284,7 +284,7 @@ export function logComponentEffect(
export function logYieldTime(startTime: number, endTime: number): void {
if (supportsUserTiming) {
const yieldDuration = endTime - startTime;
- if (yieldDuration < 1) {
+ if (yieldDuration < 3) {
// Skip sub-millisecond yields. This happens all the time and is not interesting.
return;
}
@@ -299,6 +299,10 @@ export function logYieldTime(startTime: number, endTime: number): void {
: 'error';
reusableComponentOptions.start = startTime;
reusableComponentOptions.end = endTime;
+ // This get logged in the components track if we don't commit which leaves them
+ // hanging by themselves without context. It's a useful indicator for why something
+ // might be starving this render though.
+ // TODO: Considering adding these to a queue and only logging them if we commit.
performance.measure('Blocked', reusableComponentOptions);
}
}
@@ -365,7 +369,11 @@ export function logBlockingStart(
reusableLaneOptions.start = updateTime;
reusableLaneOptions.end = renderStartTime;
performance.measure(
- isSpawnedUpdate ? 'Cascade' : 'Blocked',
+ isSpawnedUpdate
+ ? 'Cascading Update'
+ : renderStartTime - updateTime > 5
+ ? 'Update Blocked'
+ : 'Update',
reusableLaneOptions,
);
}
@@ -411,7 +419,10 @@ export function logTransitionStart(
reusableLaneDevToolDetails.color = 'primary-light';
reusableLaneOptions.start = updateTime;
reusableLaneOptions.end = renderStartTime;
- performance.measure('Blocked', reusableLaneOptions);
+ performance.measure(
+ renderStartTime - updateTime > 5 ? 'Update Blocked' : 'Update',
+ reusableLaneOptions,
+ );
}
}
}
@@ -588,7 +599,9 @@ export function logSuspendedCommitPhase(
reusableLaneDevToolDetails.color = 'secondary-light';
reusableLaneOptions.start = startTime;
reusableLaneOptions.end = endTime;
- performance.measure('Suspended', reusableLaneOptions);
+ // TODO: Make this conditionally "Suspended on Images" or both when we add Suspensey Images.
+ // TODO: This might also be Suspended while waiting on a View Transition.
+ performance.measure('Suspended on CSS', reusableLaneOptions);
}
}
| diff --git a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js
index ae48ed383413a..3a36572e8ab02 100644
--- a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js
+++ b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js
@@ -284,7 +284,7 @@ export function logComponentEffect(
export function logYieldTime(startTime: number, endTime: number): void {
if (supportsUserTiming) {
const yieldDuration = endTime - startTime;
- if (yieldDuration < 1) {
+ if (yieldDuration < 3) {
// Skip sub-millisecond yields. This happens all the time and is not interesting.
return;
@@ -299,6 +299,10 @@ export function logYieldTime(startTime: number, endTime: number): void {
: 'error';
reusableComponentOptions.start = startTime;
reusableComponentOptions.end = endTime;
+ // This get logged in the components track if we don't commit which leaves them
+ // might be starving this render though.
+ // TODO: Considering adding these to a queue and only logging them if we commit.
performance.measure('Blocked', reusableComponentOptions);
@@ -365,7 +369,11 @@ export function logBlockingStart(
performance.measure(
- isSpawnedUpdate ? 'Cascade' : 'Blocked',
+ isSpawnedUpdate
+ ? 'Cascading Update'
+ : renderStartTime - updateTime > 5
+ : 'Update',
reusableLaneOptions,
);
@@ -411,7 +419,10 @@ export function logTransitionStart(
reusableLaneDevToolDetails.color = 'primary-light';
- performance.measure('Blocked', reusableLaneOptions);
+ reusableLaneOptions,
+ );
@@ -588,7 +599,9 @@ export function logSuspendedCommitPhase(
reusableLaneDevToolDetails.color = 'secondary-light';
reusableLaneOptions.start = startTime;
reusableLaneOptions.end = endTime;
- performance.measure('Suspended', reusableLaneOptions);
+ // TODO: This might also be Suspended while waiting on a View Transition.
| [
"+ // hanging by themselves without context. It's a useful indicator for why something",
"+ ? 'Update Blocked'",
"+ performance.measure(",
"+ renderStartTime - updateTime > 5 ? 'Update Blocked' : 'Update',",
"+ // TODO: Make this conditionally \"Suspended on Images\" or both when we add Suspensey Images.",
"+ performance.measure('Suspended on CSS', reusableLaneOptions);"
] | [
18,
32,
42,
43,
54,
56
] | {
"additions": 17,
"author": "sebmarkbage",
"deletions": 4,
"html_url": "https://github.com/facebook/react/pull/32808",
"issue_id": 32808,
"merged_at": "2025-04-02T21:01:10Z",
"omission_probability": 0.1,
"pr_number": 32808,
"repo": "facebook/react",
"title": "Minor Tweak to Performance Track",
"total_changes": 21
} |
243 | diff --git a/CHANGELOG-canary.md b/CHANGELOG-canary.md
deleted file mode 100644
index 048f6a542e642..0000000000000
--- a/CHANGELOG-canary.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## March 22, 2024 (18.3.0-canary-670811593-20240322)
-
-## React
-- Added `useActionState` to replace `useFormState` and added `pending` value ([#28491](https://github.com/facebook/react/pull/28491)).
-
-## October 5, 2023 (18.3.0-canary-546178f91-20231005)
-
-### React
-
-- Added support for async functions to be passed to `startTransition`.
-- `useTransition` now triggers the nearest error boundary instead of a global error.
-- Added `useOptimistic`, a new Hook for handling optimistic UI updates. It optimistically updates the UI before receiving confirmation from a server or external source.
-
-### React DOM
-
-- Added support for passing async functions to the `action` prop on `<form>`. When the function passed to `action` is marked with [`'use server'`](https://react.dev/reference/react/use-server), the form is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).
-- Added `useFormStatus`, a new Hook for checking the submission state of a form.
-- Added `useFormState`, a new Hook for updating state upon form submission. When the function passed to `useFormState` is marked with [`'use server'`](https://react.dev/reference/react/use-server), the update is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).
| diff --git a/CHANGELOG-canary.md b/CHANGELOG-canary.md
deleted file mode 100644
index 048f6a542e642..0000000000000
--- a/CHANGELOG-canary.md
+++ /dev/null
@@ -1,18 +0,0 @@
-## March 22, 2024 (18.3.0-canary-670811593-20240322)
-## React
-- Added `useActionState` to replace `useFormState` and added `pending` value ([#28491](https://github.com/facebook/react/pull/28491)).
-## October 5, 2023 (18.3.0-canary-546178f91-20231005)
-### React
-- Added `useOptimistic`, a new Hook for handling optimistic UI updates. It optimistically updates the UI before receiving confirmation from a server or external source.
-### React DOM
-- Added support for passing async functions to the `action` prop on `<form>`. When the function passed to `action` is marked with [`'use server'`](https://react.dev/reference/react/use-server), the form is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement).
-- Added `useFormStatus`, a new Hook for checking the submission state of a form.
-- Added `useFormState`, a new Hook for updating state upon form submission. When the function passed to `useFormState` is marked with [`'use server'`](https://react.dev/reference/react/use-server), the update is [progressively enhanced](https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement). | [
"-- Added support for async functions to be passed to `startTransition`. ",
"-- `useTransition` now triggers the nearest error boundary instead of a global error."
] | [
15,
16
] | {
"additions": 0,
"author": "mattcarrollcode",
"deletions": 18,
"html_url": "https://github.com/facebook/react/pull/32807",
"issue_id": 32807,
"merged_at": "2025-04-02T20:05:43Z",
"omission_probability": 0.1,
"pr_number": 32807,
"repo": "facebook/react",
"title": "Delete CHANGELOG-canary.md",
"total_changes": 18
} |
244 | diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index b9e63fed94b5c..83092a87318ca 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -1802,6 +1802,12 @@ export function startViewTransition(
}
} finally {
// Continue the reset of the work.
+ // If the error happened in the snapshot phase before the update callback
+ // was invoked, then we need to first finish the mutation and layout phases.
+ // If they're already invoked it's still safe to call them due the status check.
+ mutationCallback();
+ layoutCallback();
+ // Skip afterMutationCallback() since we're not animating.
spawnedWorkCallback();
}
};
@@ -2137,7 +2143,13 @@ export function startGestureTransition(
}
} finally {
// Continue the reset of the work.
- readyCallback();
+ // If the error happened in the snapshot phase before the update callback
+ // was invoked, then we need to first finish the mutation and layout phases.
+ // If they're already invoked it's still safe to call them due the status check.
+ mutationCallback();
+ // Skip readyCallback() and go straight to animateCallbck() since we're not animating.
+ // animateCallback() is still required to restore states.
+ animateCallback();
}
};
transition.ready.then(readyForAnimations, handleError);
| diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index b9e63fed94b5c..83092a87318ca 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -1802,6 +1802,12 @@ export function startViewTransition(
+ layoutCallback();
+ // Skip afterMutationCallback() since we're not animating.
spawnedWorkCallback();
@@ -2137,7 +2143,13 @@ export function startGestureTransition(
- readyCallback();
+ // Skip readyCallback() and go straight to animateCallbck() since we're not animating.
+ // animateCallback() is still required to restore states.
+ animateCallback();
transition.ready.then(readyForAnimations, handleError); | [] | [] | {
"additions": 13,
"author": "sebmarkbage",
"deletions": 1,
"html_url": "https://github.com/facebook/react/pull/32803",
"issue_id": 32803,
"merged_at": "2025-04-02T14:49:45Z",
"omission_probability": 0.1,
"pr_number": 32803,
"repo": "facebook/react",
"title": "Follow through all the phases when an error happens during snapshotting",
"total_changes": 14
} |
245 | diff --git a/.eslintrc.js b/.eslintrc.js
index ae108a37e3da1..49846c1f5e9bc 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -615,6 +615,8 @@ module.exports = {
GetAnimationsOptions: 'readonly',
Animatable: 'readonly',
ScrollTimeline: 'readonly',
+ EventListenerOptionsOrUseCapture: 'readonly',
+ FocusOptions: 'readonly',
spyOnDev: 'readonly',
spyOnDevAndProd: 'readonly',
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index b9e63fed94b5c..4cad08575fe9e 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -2258,27 +2258,12 @@ export function getCurrentGestureOffset(provider: GestureTimeline): number {
return typeof time === 'number' ? time : time.value;
}
-type EventListenerOptionsOrUseCapture =
- | boolean
- | {
- capture?: boolean,
- once?: boolean,
- passive?: boolean,
- signal?: AbortSignal,
- ...
- };
-
type StoredEventListener = {
type: string,
listener: EventListener,
optionsOrUseCapture: void | EventListenerOptionsOrUseCapture,
};
-type FocusOptions = {
- preventScroll?: boolean,
- focusVisible?: boolean,
-};
-
export type FragmentInstanceType = {
_fragmentFiber: Fiber,
_eventListeners: null | Array<StoredEventListener>,
| diff --git a/.eslintrc.js b/.eslintrc.js
index ae108a37e3da1..49846c1f5e9bc 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -615,6 +615,8 @@ module.exports = {
GetAnimationsOptions: 'readonly',
Animatable: 'readonly',
ScrollTimeline: 'readonly',
+ EventListenerOptionsOrUseCapture: 'readonly',
+ FocusOptions: 'readonly',
spyOnDev: 'readonly',
spyOnDevAndProd: 'readonly',
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index b9e63fed94b5c..4cad08575fe9e 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -2258,27 +2258,12 @@ export function getCurrentGestureOffset(provider: GestureTimeline): number {
return typeof time === 'number' ? time : time.value;
}
-type EventListenerOptionsOrUseCapture =
- | boolean
- | {
- capture?: boolean,
- once?: boolean,
- passive?: boolean,
- signal?: AbortSignal,
- ...
- };
type StoredEventListener = {
type: string,
listener: EventListener,
optionsOrUseCapture: void | EventListenerOptionsOrUseCapture,
};
-type FocusOptions = {
- focusVisible?: boolean,
-};
export type FragmentInstanceType = {
_fragmentFiber: Fiber,
_eventListeners: null | Array<StoredEventListener>, | [
"- preventScroll?: boolean,"
] | [
38
] | {
"additions": 2,
"author": "sebmarkbage",
"deletions": 15,
"html_url": "https://github.com/facebook/react/pull/32801",
"issue_id": 32801,
"merged_at": "2025-04-01T18:22:58Z",
"omission_probability": 0.1,
"pr_number": 32801,
"repo": "facebook/react",
"title": "Don't shadow EventListenerOptionsOrUseCapture and FocusOptions types",
"total_changes": 17
} |
246 | diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js
index c8136f8fa03b2..c5ec0a16ef09a 100644
--- a/packages/react-reconciler/src/ReactFiberHooks.js
+++ b/packages/react-reconciler/src/ReactFiberHooks.js
@@ -2219,6 +2219,11 @@ function handleActionReturnValue<S, P>(
typeof returnValue.then === 'function'
) {
const thenable = ((returnValue: any): Thenable<Awaited<S>>);
+ if (__DEV__) {
+ // Keep track of the number of async transitions still running so we can warn.
+ ReactSharedInternals.asyncTransitions++;
+ thenable.then(releaseAsyncTransition, releaseAsyncTransition);
+ }
// Attach a listener to read the return state of the action. As soon as
// this resolves, we can run the next action in the sequence.
thenable.then(
@@ -3026,6 +3031,12 @@ function updateDeferredValueImpl<T>(
}
}
+function releaseAsyncTransition() {
+ if (__DEV__) {
+ ReactSharedInternals.asyncTransitions--;
+ }
+}
+
function startTransition<S>(
fiber: Fiber,
queue: UpdateQueue<S | Thenable<S>, BasicStateAction<S | Thenable<S>>>,
@@ -3083,6 +3094,11 @@ function startTransition<S>(
typeof returnValue.then === 'function'
) {
const thenable = ((returnValue: any): Thenable<mixed>);
+ if (__DEV__) {
+ // Keep track of the number of async transitions still running so we can warn.
+ ReactSharedInternals.asyncTransitions++;
+ thenable.then(releaseAsyncTransition, releaseAsyncTransition);
+ }
// Create a thenable that resolves to `finishedState` once the async
// action has completed.
const thenableForFinishedState = chainThenableValue(
diff --git a/packages/react/src/ReactSharedInternalsClient.js b/packages/react/src/ReactSharedInternalsClient.js
index f1bc3463644a8..725721c7a5d8a 100644
--- a/packages/react/src/ReactSharedInternalsClient.js
+++ b/packages/react/src/ReactSharedInternalsClient.js
@@ -39,6 +39,9 @@ export type SharedStateClient = {
// ReactCurrentActQueue
actQueue: null | Array<RendererTask>,
+ // When zero this means we're outside an async startTransition.
+ asyncTransitions: number,
+
// Used to reproduce behavior of `batchedUpdates` in legacy mode.
isBatchingLegacy: boolean,
didScheduleLegacyUpdate: boolean,
@@ -75,6 +78,7 @@ if (enableViewTransition) {
if (__DEV__) {
ReactSharedInternals.actQueue = null;
+ ReactSharedInternals.asyncTransitions = 0;
ReactSharedInternals.isBatchingLegacy = false;
ReactSharedInternals.didScheduleLegacyUpdate = false;
ReactSharedInternals.didUsePromise = false;
diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js
index f8a3f58013346..f56c99b5fccb5 100644
--- a/packages/react/src/ReactStartTransition.js
+++ b/packages/react/src/ReactStartTransition.js
@@ -37,6 +37,12 @@ export type Transition = {
...
};
+function releaseAsyncTransition() {
+ if (__DEV__) {
+ ReactSharedInternals.asyncTransitions--;
+ }
+}
+
export function startTransition(
scope: () => void,
options?: StartTransitionOptions,
@@ -67,6 +73,11 @@ export function startTransition(
returnValue !== null &&
typeof returnValue.then === 'function'
) {
+ if (__DEV__) {
+ // Keep track of the number of async transitions still running so we can warn.
+ ReactSharedInternals.asyncTransitions++;
+ returnValue.then(releaseAsyncTransition, releaseAsyncTransition);
+ }
returnValue.then(noop, reportGlobalError);
}
} catch (error) {
diff --git a/packages/react/src/ReactTransitionType.js b/packages/react/src/ReactTransitionType.js
index 4d72bb54c5a27..33f3b2d22fd8e 100644
--- a/packages/react/src/ReactTransitionType.js
+++ b/packages/react/src/ReactTransitionType.js
@@ -45,6 +45,25 @@ export function addTransitionType(type: string): void {
pendingTransitionTypes = pendingGestureTransitionTypes = [];
}
} else {
+ if (__DEV__) {
+ if (
+ ReactSharedInternals.T === null &&
+ ReactSharedInternals.asyncTransitions === 0
+ ) {
+ if (enableGestureTransition) {
+ console.error(
+ 'addTransitionType can only be called inside a `startTransition()` ' +
+ 'or `startGestureTransition()` callback. ' +
+ 'It must be associated with a specific Transition.',
+ );
+ } else {
+ console.error(
+ 'addTransitionType can only be called inside a `startTransition()` ' +
+ 'callback. It must be associated with a specific Transition.',
+ );
+ }
+ }
+ }
// Otherwise we're either inside a synchronous startTransition
// or in the async gap of one, which we track globally.
pendingTransitionTypes = ReactSharedInternals.V;
| diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js
index c8136f8fa03b2..c5ec0a16ef09a 100644
--- a/packages/react-reconciler/src/ReactFiberHooks.js
+++ b/packages/react-reconciler/src/ReactFiberHooks.js
@@ -2219,6 +2219,11 @@ function handleActionReturnValue<S, P>(
typeof returnValue.then === 'function'
) {
const thenable = ((returnValue: any): Thenable<Awaited<S>>);
+ // Keep track of the number of async transitions still running so we can warn.
+ ReactSharedInternals.asyncTransitions++;
+ }
// Attach a listener to read the return state of the action. As soon as
// this resolves, we can run the next action in the sequence.
thenable.then(
@@ -3026,6 +3031,12 @@ function updateDeferredValueImpl<T>(
}
}
function startTransition<S>(
fiber: Fiber,
queue: UpdateQueue<S | Thenable<S>, BasicStateAction<S | Thenable<S>>>,
@@ -3083,6 +3094,11 @@ function startTransition<S>(
const thenable = ((returnValue: any): Thenable<mixed>);
+ thenable.then(releaseAsyncTransition, releaseAsyncTransition);
// Create a thenable that resolves to `finishedState` once the async
// action has completed.
const thenableForFinishedState = chainThenableValue(
diff --git a/packages/react/src/ReactSharedInternalsClient.js b/packages/react/src/ReactSharedInternalsClient.js
index f1bc3463644a8..725721c7a5d8a 100644
--- a/packages/react/src/ReactSharedInternalsClient.js
+++ b/packages/react/src/ReactSharedInternalsClient.js
@@ -39,6 +39,9 @@ export type SharedStateClient = {
// ReactCurrentActQueue
actQueue: null | Array<RendererTask>,
+ // When zero this means we're outside an async startTransition.
+ asyncTransitions: number,
// Used to reproduce behavior of `batchedUpdates` in legacy mode.
isBatchingLegacy: boolean,
didScheduleLegacyUpdate: boolean,
@@ -75,6 +78,7 @@ if (enableViewTransition) {
if (__DEV__) {
ReactSharedInternals.actQueue = null;
+ ReactSharedInternals.asyncTransitions = 0;
ReactSharedInternals.isBatchingLegacy = false;
ReactSharedInternals.didScheduleLegacyUpdate = false;
ReactSharedInternals.didUsePromise = false;
diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js
index f8a3f58013346..f56c99b5fccb5 100644
--- a/packages/react/src/ReactStartTransition.js
+++ b/packages/react/src/ReactStartTransition.js
@@ -37,6 +37,12 @@ export type Transition = {
...
};
export function startTransition(
scope: () => void,
options?: StartTransitionOptions,
@@ -67,6 +73,11 @@ export function startTransition(
returnValue !== null &&
+ returnValue.then(releaseAsyncTransition, releaseAsyncTransition);
returnValue.then(noop, reportGlobalError);
}
} catch (error) {
diff --git a/packages/react/src/ReactTransitionType.js b/packages/react/src/ReactTransitionType.js
index 4d72bb54c5a27..33f3b2d22fd8e 100644
--- a/packages/react/src/ReactTransitionType.js
+++ b/packages/react/src/ReactTransitionType.js
@@ -45,6 +45,25 @@ export function addTransitionType(type: string): void {
pendingTransitionTypes = pendingGestureTransitionTypes = [];
}
} else {
+ if (
+ ReactSharedInternals.T === null &&
+ ReactSharedInternals.asyncTransitions === 0
+ ) {
+ if (enableGestureTransition) {
+ 'or `startGestureTransition()` callback. ' +
+ 'It must be associated with a specific Transition.',
+ } else {
+ 'callback. It must be associated with a specific Transition.',
+ }
+ }
// Otherwise we're either inside a synchronous startTransition
// or in the async gap of one, which we track globally.
pendingTransitionTypes = ReactSharedInternals.V; | [
"+ if (__DEV__) {",
"+ thenable.then(releaseAsyncTransition, releaseAsyncTransition);"
] | [
8,
11
] | {
"additions": 50,
"author": "sebmarkbage",
"deletions": 0,
"html_url": "https://github.com/facebook/react/pull/32793",
"issue_id": 32793,
"merged_at": "2025-04-01T16:10:10Z",
"omission_probability": 0.1,
"pr_number": 32793,
"repo": "facebook/react",
"title": "Warn if addTransitionType is called when there are no pending Actions",
"total_changes": 50
} |
247 | diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js b/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
index 3d60caeda000d..a5b070be494e4 100644
--- a/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
+++ b/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
@@ -211,7 +211,7 @@ export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
}
export function getFiberCurrentPropsFromNode(
- node: Instance | TextInstance | SuspenseInstance,
+ node: Container | Instance | TextInstance | SuspenseInstance,
): Props {
return (node: any)[internalPropsKey] || null;
}
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index e6b54a1e5e522..5fc6bea751968 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -30,6 +30,7 @@ import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
import {NotPending} from '../shared/ReactDOMFormActions';
import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext';
+import {runWithFiberInDEV} from 'react-reconciler/src/ReactCurrentFiber';
import hasOwnProperty from 'shared/hasOwnProperty';
import {checkAttributeStringCoercion} from 'shared/CheckStringCoercion';
@@ -43,6 +44,8 @@ export {
import {
precacheFiberNode,
updateFiberProps,
+ getFiberCurrentPropsFromNode,
+ getInstanceFromNode,
getClosestInstanceFromNode,
getFiberFromScopeInstance,
getInstanceFromNode as getInstanceFromNodeDOMTree,
@@ -821,10 +824,51 @@ export function appendChild(
}
}
+function warnForReactChildrenConflict(container: Container): void {
+ if (__DEV__) {
+ if ((container: any).__reactWarnedAboutChildrenConflict) {
+ return;
+ }
+ const props = getFiberCurrentPropsFromNode(container);
+ if (props !== null) {
+ const fiber = getInstanceFromNode(container);
+ if (fiber !== null) {
+ if (
+ typeof props.children === 'string' ||
+ typeof props.children === 'number'
+ ) {
+ (container: any).__reactWarnedAboutChildrenConflict = true;
+ // Run the warning with the Fiber of the container for context of where the children are specified.
+ // We could also maybe use the Portal. The current execution context is the child being added.
+ runWithFiberInDEV(fiber, () => {
+ console.error(
+ 'Cannot use a ref on a React element as a container to `createRoot` or `createPortal` ' +
+ 'if that element also sets "children" text content using React. It should be a leaf with no children. ' +
+ "Otherwise it's ambiguous which children should be used.",
+ );
+ });
+ } else if (props.dangerouslySetInnerHTML != null) {
+ (container: any).__reactWarnedAboutChildrenConflict = true;
+ runWithFiberInDEV(fiber, () => {
+ console.error(
+ 'Cannot use a ref on a React element as a container to `createRoot` or `createPortal` ' +
+ 'if that element also sets "dangerouslySetInnerHTML" using React. It should be a leaf with no children. ' +
+ "Otherwise it's ambiguous which children should be used.",
+ );
+ });
+ }
+ }
+ }
+ }
+}
+
export function appendChildToContainer(
container: Container,
child: Instance | TextInstance,
): void {
+ if (__DEV__) {
+ warnForReactChildrenConflict(container);
+ }
let parentNode: DocumentFragment | Element;
if (container.nodeType === DOCUMENT_NODE) {
parentNode = (container: any).body;
@@ -888,6 +932,9 @@ export function insertInContainerBefore(
child: Instance | TextInstance,
beforeChild: Instance | TextInstance | SuspenseInstance,
): void {
+ if (__DEV__) {
+ warnForReactChildrenConflict(container);
+ }
let parentNode: DocumentFragment | Element;
if (container.nodeType === DOCUMENT_NODE) {
parentNode = (container: any).body;
| diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js b/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
index 3d60caeda000d..a5b070be494e4 100644
--- a/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
+++ b/packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
@@ -211,7 +211,7 @@ export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
export function getFiberCurrentPropsFromNode(
- node: Instance | TextInstance | SuspenseInstance,
+ node: Container | Instance | TextInstance | SuspenseInstance,
): Props {
return (node: any)[internalPropsKey] || null;
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index e6b54a1e5e522..5fc6bea751968 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -30,6 +30,7 @@ import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
import {NotPending} from '../shared/ReactDOMFormActions';
import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostContext';
+import {runWithFiberInDEV} from 'react-reconciler/src/ReactCurrentFiber';
import hasOwnProperty from 'shared/hasOwnProperty';
import {checkAttributeStringCoercion} from 'shared/CheckStringCoercion';
@@ -43,6 +44,8 @@ export {
import {
precacheFiberNode,
updateFiberProps,
+ getFiberCurrentPropsFromNode,
+ getInstanceFromNode,
getClosestInstanceFromNode,
getFiberFromScopeInstance,
getInstanceFromNode as getInstanceFromNodeDOMTree,
@@ -821,10 +824,51 @@ export function appendChild(
}
+function warnForReactChildrenConflict(container: Container): void {
+ if ((container: any).__reactWarnedAboutChildrenConflict) {
+ if (props !== null) {
+ const fiber = getInstanceFromNode(container);
+ if (fiber !== null) {
+ if (
+ typeof props.children === 'string' ||
+ typeof props.children === 'number'
+ ) {
+ // Run the warning with the Fiber of the container for context of where the children are specified.
+ // We could also maybe use the Portal. The current execution context is the child being added.
+ 'if that element also sets "children" text content using React. It should be a leaf with no children. ' +
+ } else if (props.dangerouslySetInnerHTML != null) {
+ 'if that element also sets "dangerouslySetInnerHTML" using React. It should be a leaf with no children. ' +
+ }
+ }
+}
+
export function appendChildToContainer(
container: Container,
@@ -888,6 +932,9 @@ export function insertInContainerBefore(
beforeChild: Instance | TextInstance | SuspenseInstance, | [
"+ return;",
"+ const props = getFiberCurrentPropsFromNode(container);"
] | [
41,
43
] | {
"additions": 48,
"author": "sebmarkbage",
"deletions": 1,
"html_url": "https://github.com/facebook/react/pull/32774",
"issue_id": 32774,
"merged_at": "2025-04-01T16:11:29Z",
"omission_probability": 0.1,
"pr_number": 32774,
"repo": "facebook/react",
"title": "Warn for using a React owned node as a Container if it also has text content",
"total_changes": 49
} |
248 | diff --git a/fixtures/view-transition/src/components/Page.js b/fixtures/view-transition/src/components/Page.js
index 483f01372fca9..3de87a949e5c7 100644
--- a/fixtures/view-transition/src/components/Page.js
+++ b/fixtures/view-transition/src/components/Page.js
@@ -1,4 +1,5 @@
import React, {
+ unstable_addTransitionType as addTransitionType,
unstable_ViewTransition as ViewTransition,
unstable_Activity as Activity,
useLayoutEffect,
@@ -113,7 +114,12 @@ export default function Page({url, navigate}) {
<div className="swipe-recognizer">
<SwipeRecognizer
action={swipeAction}
- gesture={optimisticNavigate}
+ gesture={direction => {
+ addTransitionType(
+ direction === 'left' ? 'navigation-forward' : 'navigation-back'
+ );
+ optimisticNavigate(direction);
+ }}
direction={show ? 'left' : 'right'}>
<button
className="button"
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index a8616833f6680..a031fc22e5367 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -25,7 +25,7 @@ import type {
PreinitScriptOptions,
PreinitModuleScriptOptions,
} from 'react-dom/src/shared/ReactDOMTypes';
-import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
import {NotPending} from '../shared/ReactDOMFormActions';
diff --git a/packages/react-native-renderer/src/ReactFiberConfigNative.js b/packages/react-native-renderer/src/ReactFiberConfigNative.js
index b278310c8b20c..b022d82d4e6c7 100644
--- a/packages/react-native-renderer/src/ReactFiberConfigNative.js
+++ b/packages/react-native-renderer/src/ReactFiberConfigNative.js
@@ -8,7 +8,7 @@
*/
import type {InspectorData, TouchedViewDataAtPoint} from './ReactNativeTypes';
-import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
// Modules provided by RN:
import {
diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js
index 405edb7c53293..57d86c6df5a9d 100644
--- a/packages/react-noop-renderer/src/createReactNoop.js
+++ b/packages/react-noop-renderer/src/createReactNoop.js
@@ -22,7 +22,7 @@ import type {UpdateQueue} from 'react-reconciler/src/ReactFiberClassUpdateQueue'
import type {ReactNodeList} from 'shared/ReactTypes';
import type {RootTag} from 'react-reconciler/src/ReactRootTags';
import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
-import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
import * as Scheduler from 'scheduler/unstable_mock';
import {REACT_FRAGMENT_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
diff --git a/packages/react-reconciler/src/ReactFiberGestureScheduler.js b/packages/react-reconciler/src/ReactFiberGestureScheduler.js
index 7018506c4752a..ed61c59b05ae6 100644
--- a/packages/react-reconciler/src/ReactFiberGestureScheduler.js
+++ b/packages/react-reconciler/src/ReactFiberGestureScheduler.js
@@ -10,6 +10,7 @@
import type {FiberRoot} from './ReactInternalTypes';
import type {GestureOptions} from 'shared/ReactTypes';
import type {GestureTimeline, RunningViewTransition} from './ReactFiberConfig';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
import {
GestureLane,
@@ -25,6 +26,7 @@ export type ScheduledGesture = {
count: number, // The number of times this same provider has been started.
rangeStart: number, // The percentage along the timeline where the "current" state starts.
rangeEnd: number, // The percentage along the timeline where the "destination" state is reached.
+ types: null | TransitionTypes, // Any addTransitionType call made during startGestureTransition.
running: null | RunningViewTransition, // Used to cancel the running transition after we're done.
prev: null | ScheduledGesture, // The previous scheduled gesture in the queue for this root.
next: null | ScheduledGesture, // The next scheduled gesture in the queue for this root.
@@ -51,6 +53,7 @@ export function scheduleGesture(
count: 0,
rangeStart: 0, // Uninitialized
rangeEnd: 100, // Uninitialized
+ types: null,
running: null,
prev: prev,
next: null,
@@ -68,6 +71,7 @@ export function startScheduledGesture(
root: FiberRoot,
gestureTimeline: GestureTimeline,
gestureOptions: ?GestureOptions,
+ transitionTypes: null | TransitionTypes,
): null | ScheduledGesture {
const rangeStart =
gestureOptions && gestureOptions.rangeStart != null
@@ -87,6 +91,18 @@ export function startScheduledGesture(
// Update the options.
prev.rangeStart = rangeStart;
prev.rangeEnd = rangeEnd;
+ if (transitionTypes !== null) {
+ let scheduledTypes = prev.types;
+ if (scheduledTypes === null) {
+ scheduledTypes = prev.types = [];
+ }
+ for (let i = 0; i < transitionTypes.length; i++) {
+ const transitionType = transitionTypes[i];
+ if (scheduledTypes.indexOf(transitionType) === -1) {
+ scheduledTypes.push(transitionType);
+ }
+ }
+ }
return prev;
}
const next = prev.next;
diff --git a/packages/react-reconciler/src/ReactFiberTransition.js b/packages/react-reconciler/src/ReactFiberTransition.js
index 4bb123205e1b3..128f5fa2d1b50 100644
--- a/packages/react-reconciler/src/ReactFiberTransition.js
+++ b/packages/react-reconciler/src/ReactFiberTransition.js
@@ -17,6 +17,7 @@ import type {StackCursor} from './ReactFiberStack';
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent';
import type {Transition} from 'react/src/ReactStartTransition';
import type {ScheduledGesture} from './ReactFiberGestureScheduler';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
import {
enableTransitionTracing,
@@ -112,6 +113,7 @@ if (enableGestureTransition) {
transition: Transition,
provider: GestureProvider,
options: ?GestureOptions,
+ transitionTypes: null | TransitionTypes,
): () => void {
let cancel = null;
if (prevOnStartGestureTransitionFinish !== null) {
@@ -119,6 +121,7 @@ if (enableGestureTransition) {
transition,
provider,
options,
+ transitionTypes,
);
}
// For every root that has work scheduled, check if there's a ScheduledGesture
@@ -131,7 +134,12 @@ if (enableGestureTransition) {
// that it's conceptually started globally.
let root = firstScheduledRoot;
while (root !== null) {
- const scheduledGesture = startScheduledGesture(root, provider, options);
+ const scheduledGesture = startScheduledGesture(
+ root,
+ provider,
+ options,
+ transitionTypes,
+ );
if (scheduledGesture !== null) {
cancel = chainGestureCancellation(root, scheduledGesture, cancel);
}
diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js
index 3f3f733b86667..f748f309df5c3 100644
--- a/packages/react-reconciler/src/ReactFiberWorkLoop.js
+++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js
@@ -31,7 +31,7 @@ import {
getViewTransitionName,
type ViewTransitionState,
} from './ReactFiberViewTransitionComponent';
-import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
import {
enableCreateEventHandleAPI,
@@ -3925,8 +3925,7 @@ function commitGestureOnRoot(
setCurrentUpdatePriority(previousPriority);
ReactSharedInternals.T = prevTransition;
}
- // TODO: Collect transition types.
- pendingTransitionTypes = null;
+ pendingTransitionTypes = finishedGesture.types;
pendingEffectsStatus = PENDING_GESTURE_MUTATION_PHASE;
pendingViewTransition = finishedGesture.running = startGestureTransition(
diff --git a/packages/react-test-renderer/src/ReactFiberConfigTestHost.js b/packages/react-test-renderer/src/ReactFiberConfigTestHost.js
index 9145d8e7e487a..c0ebf59601817 100644
--- a/packages/react-test-renderer/src/ReactFiberConfigTestHost.js
+++ b/packages/react-test-renderer/src/ReactFiberConfigTestHost.js
@@ -8,7 +8,7 @@
*/
import type {ReactContext} from 'shared/ReactTypes';
-import type {TransitionTypes} from 'react/src/ReactTransitionType.js';
+import type {TransitionTypes} from 'react/src/ReactTransitionType';
import isArray from 'shared/isArray';
import {REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
diff --git a/packages/react/src/ReactSharedInternalsClient.js b/packages/react/src/ReactSharedInternalsClient.js
index 8fba0750ae9d9..f1bc3463644a8 100644
--- a/packages/react/src/ReactSharedInternalsClient.js
+++ b/packages/react/src/ReactSharedInternalsClient.js
@@ -18,12 +18,20 @@ import {
enableGestureTransition,
} from 'shared/ReactFeatureFlags';
+type onStartTransitionFinish = (Transition, mixed) => void;
+type onStartGestureTransitionFinish = (
+ Transition,
+ GestureProvider,
+ ?GestureOptions,
+ transitionTypes: null | TransitionTypes,
+) => () => void;
+
export type SharedStateClient = {
H: null | Dispatcher, // ReactCurrentDispatcher for Hooks
A: null | AsyncDispatcher, // ReactCurrentCache for Cache
T: null | Transition, // ReactCurrentBatchConfig for Transitions
- S: null | ((Transition, mixed) => void), // onStartTransitionFinish
- G: null | ((Transition, GestureProvider, ?GestureOptions) => () => void), // onStartGestureTransitionFinish
+ S: null | onStartTransitionFinish,
+ G: null | onStartGestureTransitionFinish,
V: null | TransitionTypes, // Pending Transition Types for the Next Transition
// DEV-only
diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js
index 249e4ca6d0dfd..f8a3f58013346 100644
--- a/packages/react/src/ReactStartTransition.js
+++ b/packages/react/src/ReactStartTransition.js
@@ -21,6 +21,12 @@ import {
enableGestureTransition,
} from 'shared/ReactFeatureFlags';
+import {
+ pendingGestureTransitionTypes,
+ pushPendingGestureTransitionTypes,
+ popPendingGestureTransitionTypes,
+} from './ReactTransitionType';
+
import reportGlobalError from 'shared/reportGlobalError';
export type Transition = {
@@ -105,6 +111,8 @@ export function startGestureTransition(
}
ReactSharedInternals.T = currentTransition;
+ const prevTransitionTypes = pushPendingGestureTransitionTypes();
+
try {
const returnValue = scope();
if (__DEV__) {
@@ -118,17 +126,20 @@ export function startGestureTransition(
);
}
}
+ const transitionTypes = pendingGestureTransitionTypes;
const onStartGestureTransitionFinish = ReactSharedInternals.G;
if (onStartGestureTransitionFinish !== null) {
return onStartGestureTransitionFinish(
currentTransition,
provider,
options,
+ transitionTypes,
);
}
} catch (error) {
reportGlobalError(error);
} finally {
+ popPendingGestureTransitionTypes(prevTransitionTypes);
ReactSharedInternals.T = prevTransition;
}
return function cancelGesture() {
diff --git a/packages/react/src/ReactTransitionType.js b/packages/react/src/ReactTransitionType.js
index 85a9f8682f4ce..4d72bb54c5a27 100644
--- a/packages/react/src/ReactTransitionType.js
+++ b/packages/react/src/ReactTransitionType.js
@@ -8,17 +8,51 @@
*/
import ReactSharedInternals from 'shared/ReactSharedInternals';
-import {enableViewTransition} from 'shared/ReactFeatureFlags';
+import {
+ enableViewTransition,
+ enableGestureTransition,
+} from 'shared/ReactFeatureFlags';
export type TransitionTypes = Array<string>;
+// This one is only available synchronously so we don't need to use ReactSharedInternals
+// for this state. Instead, we track it in isomorphic and pass it to the renderer.
+export let pendingGestureTransitionTypes: null | TransitionTypes = null;
+
+export function pushPendingGestureTransitionTypes(): null | TransitionTypes {
+ const prev = pendingGestureTransitionTypes;
+ pendingGestureTransitionTypes = null;
+ return prev;
+}
+
+export function popPendingGestureTransitionTypes(
+ prev: null | TransitionTypes,
+): void {
+ pendingGestureTransitionTypes = prev;
+}
+
export function addTransitionType(type: string): void {
if (enableViewTransition) {
- const pendingTransitionTypes: null | TransitionTypes =
- ReactSharedInternals.V;
- if (pendingTransitionTypes === null) {
- ReactSharedInternals.V = [type];
- } else if (pendingTransitionTypes.indexOf(type) === -1) {
+ let pendingTransitionTypes: null | TransitionTypes;
+ if (
+ enableGestureTransition &&
+ ReactSharedInternals.T !== null &&
+ ReactSharedInternals.T.gesture !== null
+ ) {
+ // We're inside a startGestureTransition which is always sync.
+ pendingTransitionTypes = pendingGestureTransitionTypes;
+ if (pendingTransitionTypes === null) {
+ pendingTransitionTypes = pendingGestureTransitionTypes = [];
+ }
+ } else {
+ // Otherwise we're either inside a synchronous startTransition
+ // or in the async gap of one, which we track globally.
+ pendingTransitionTypes = ReactSharedInternals.V;
+ if (pendingTransitionTypes === null) {
+ pendingTransitionTypes = ReactSharedInternals.V = [];
+ }
+ }
+ if (pendingTransitionTypes.indexOf(type) === -1) {
pendingTransitionTypes.push(type);
}
}
| diff --git a/fixtures/view-transition/src/components/Page.js b/fixtures/view-transition/src/components/Page.js
index 483f01372fca9..3de87a949e5c7 100644
--- a/fixtures/view-transition/src/components/Page.js
+++ b/fixtures/view-transition/src/components/Page.js
@@ -1,4 +1,5 @@
import React, {
+ unstable_addTransitionType as addTransitionType,
unstable_ViewTransition as ViewTransition,
unstable_Activity as Activity,
useLayoutEffect,
@@ -113,7 +114,12 @@ export default function Page({url, navigate}) {
<div className="swipe-recognizer">
<SwipeRecognizer
action={swipeAction}
+ gesture={direction => {
+ addTransitionType(
+ direction === 'left' ? 'navigation-forward' : 'navigation-back'
+ );
+ }}
direction={show ? 'left' : 'right'}>
<button
className="button"
diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
index a8616833f6680..a031fc22e5367 100644
--- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
+++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
@@ -25,7 +25,7 @@ import type {
PreinitScriptOptions,
PreinitModuleScriptOptions,
} from 'react-dom/src/shared/ReactDOMTypes';
import {NotPending} from '../shared/ReactDOMFormActions';
diff --git a/packages/react-native-renderer/src/ReactFiberConfigNative.js b/packages/react-native-renderer/src/ReactFiberConfigNative.js
index b278310c8b20c..b022d82d4e6c7 100644
--- a/packages/react-native-renderer/src/ReactFiberConfigNative.js
+++ b/packages/react-native-renderer/src/ReactFiberConfigNative.js
import type {InspectorData, TouchedViewDataAtPoint} from './ReactNativeTypes';
// Modules provided by RN:
diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js
index 405edb7c53293..57d86c6df5a9d 100644
--- a/packages/react-noop-renderer/src/createReactNoop.js
+++ b/packages/react-noop-renderer/src/createReactNoop.js
@@ -22,7 +22,7 @@ import type {UpdateQueue} from 'react-reconciler/src/ReactFiberClassUpdateQueue'
import type {ReactNodeList} from 'shared/ReactTypes';
import type {RootTag} from 'react-reconciler/src/ReactRootTags';
import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
import * as Scheduler from 'scheduler/unstable_mock';
import {REACT_FRAGMENT_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
diff --git a/packages/react-reconciler/src/ReactFiberGestureScheduler.js b/packages/react-reconciler/src/ReactFiberGestureScheduler.js
index 7018506c4752a..ed61c59b05ae6 100644
--- a/packages/react-reconciler/src/ReactFiberGestureScheduler.js
+++ b/packages/react-reconciler/src/ReactFiberGestureScheduler.js
@@ -10,6 +10,7 @@
import type {FiberRoot} from './ReactInternalTypes';
import type {GestureOptions} from 'shared/ReactTypes';
import type {GestureTimeline, RunningViewTransition} from './ReactFiberConfig';
GestureLane,
@@ -25,6 +26,7 @@ export type ScheduledGesture = {
count: number, // The number of times this same provider has been started.
rangeStart: number, // The percentage along the timeline where the "current" state starts.
rangeEnd: number, // The percentage along the timeline where the "destination" state is reached.
+ types: null | TransitionTypes, // Any addTransitionType call made during startGestureTransition.
running: null | RunningViewTransition, // Used to cancel the running transition after we're done.
prev: null | ScheduledGesture, // The previous scheduled gesture in the queue for this root.
next: null | ScheduledGesture, // The next scheduled gesture in the queue for this root.
@@ -51,6 +53,7 @@ export function scheduleGesture(
count: 0,
rangeStart: 0, // Uninitialized
rangeEnd: 100, // Uninitialized
+ types: null,
running: null,
prev: prev,
next: null,
@@ -68,6 +71,7 @@ export function startScheduledGesture(
root: FiberRoot,
gestureTimeline: GestureTimeline,
gestureOptions: ?GestureOptions,
): null | ScheduledGesture {
const rangeStart =
gestureOptions && gestureOptions.rangeStart != null
@@ -87,6 +91,18 @@ export function startScheduledGesture(
// Update the options.
prev.rangeStart = rangeStart;
prev.rangeEnd = rangeEnd;
+ if (transitionTypes !== null) {
+ let scheduledTypes = prev.types;
+ if (scheduledTypes === null) {
+ scheduledTypes = prev.types = [];
+ for (let i = 0; i < transitionTypes.length; i++) {
+ if (scheduledTypes.indexOf(transitionType) === -1) {
+ scheduledTypes.push(transitionType);
+ }
return prev;
const next = prev.next;
diff --git a/packages/react-reconciler/src/ReactFiberTransition.js b/packages/react-reconciler/src/ReactFiberTransition.js
index 4bb123205e1b3..128f5fa2d1b50 100644
--- a/packages/react-reconciler/src/ReactFiberTransition.js
+++ b/packages/react-reconciler/src/ReactFiberTransition.js
@@ -17,6 +17,7 @@ import type {StackCursor} from './ReactFiberStack';
import type {Cache, SpawnedCachePool} from './ReactFiberCacheComponent';
import type {Transition} from 'react/src/ReactStartTransition';
import type {ScheduledGesture} from './ReactFiberGestureScheduler';
enableTransitionTracing,
@@ -112,6 +113,7 @@ if (enableGestureTransition) {
transition: Transition,
provider: GestureProvider,
options: ?GestureOptions,
+ transitionTypes: null | TransitionTypes,
): () => void {
let cancel = null;
if (prevOnStartGestureTransitionFinish !== null) {
@@ -119,6 +121,7 @@ if (enableGestureTransition) {
transition,
// For every root that has work scheduled, check if there's a ScheduledGesture
@@ -131,7 +134,12 @@ if (enableGestureTransition) {
// that it's conceptually started globally.
let root = firstScheduledRoot;
while (root !== null) {
- const scheduledGesture = startScheduledGesture(root, provider, options);
+ const scheduledGesture = startScheduledGesture(
+ root,
+ provider,
+ options,
if (scheduledGesture !== null) {
cancel = chainGestureCancellation(root, scheduledGesture, cancel);
diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js
index 3f3f733b86667..f748f309df5c3 100644
--- a/packages/react-reconciler/src/ReactFiberWorkLoop.js
+++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js
@@ -31,7 +31,7 @@ import {
getViewTransitionName,
type ViewTransitionState,
} from './ReactFiberViewTransitionComponent';
enableCreateEventHandleAPI,
@@ -3925,8 +3925,7 @@ function commitGestureOnRoot(
setCurrentUpdatePriority(previousPriority);
- // TODO: Collect transition types.
- pendingTransitionTypes = null;
+ pendingTransitionTypes = finishedGesture.types;
pendingEffectsStatus = PENDING_GESTURE_MUTATION_PHASE;
pendingViewTransition = finishedGesture.running = startGestureTransition(
diff --git a/packages/react-test-renderer/src/ReactFiberConfigTestHost.js b/packages/react-test-renderer/src/ReactFiberConfigTestHost.js
index 9145d8e7e487a..c0ebf59601817 100644
--- a/packages/react-test-renderer/src/ReactFiberConfigTestHost.js
+++ b/packages/react-test-renderer/src/ReactFiberConfigTestHost.js
import type {ReactContext} from 'shared/ReactTypes';
import isArray from 'shared/isArray';
import {REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
diff --git a/packages/react/src/ReactSharedInternalsClient.js b/packages/react/src/ReactSharedInternalsClient.js
index 8fba0750ae9d9..f1bc3463644a8 100644
--- a/packages/react/src/ReactSharedInternalsClient.js
+++ b/packages/react/src/ReactSharedInternalsClient.js
@@ -18,12 +18,20 @@ import {
+type onStartTransitionFinish = (Transition, mixed) => void;
+type onStartGestureTransitionFinish = (
+ Transition,
+ GestureProvider,
+ ?GestureOptions,
+) => () => void;
export type SharedStateClient = {
H: null | Dispatcher, // ReactCurrentDispatcher for Hooks
A: null | AsyncDispatcher, // ReactCurrentCache for Cache
T: null | Transition, // ReactCurrentBatchConfig for Transitions
- S: null | ((Transition, mixed) => void), // onStartTransitionFinish
- G: null | ((Transition, GestureProvider, ?GestureOptions) => () => void), // onStartGestureTransitionFinish
+ S: null | onStartTransitionFinish,
+ G: null | onStartGestureTransitionFinish,
V: null | TransitionTypes, // Pending Transition Types for the Next Transition
// DEV-only
diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js
index 249e4ca6d0dfd..f8a3f58013346 100644
--- a/packages/react/src/ReactStartTransition.js
+++ b/packages/react/src/ReactStartTransition.js
@@ -21,6 +21,12 @@ import {
+ pendingGestureTransitionTypes,
+ popPendingGestureTransitionTypes,
+} from './ReactTransitionType';
import reportGlobalError from 'shared/reportGlobalError';
export type Transition = {
@@ -105,6 +111,8 @@ export function startGestureTransition(
ReactSharedInternals.T = currentTransition;
try {
const returnValue = scope();
if (__DEV__) {
@@ -118,17 +126,20 @@ export function startGestureTransition(
);
+ const transitionTypes = pendingGestureTransitionTypes;
const onStartGestureTransitionFinish = ReactSharedInternals.G;
if (onStartGestureTransitionFinish !== null) {
return onStartGestureTransitionFinish(
currentTransition,
} catch (error) {
reportGlobalError(error);
} finally {
+ popPendingGestureTransitionTypes(prevTransitionTypes);
return function cancelGesture() {
diff --git a/packages/react/src/ReactTransitionType.js b/packages/react/src/ReactTransitionType.js
index 85a9f8682f4ce..4d72bb54c5a27 100644
--- a/packages/react/src/ReactTransitionType.js
+++ b/packages/react/src/ReactTransitionType.js
@@ -8,17 +8,51 @@
import ReactSharedInternals from 'shared/ReactSharedInternals';
-import {enableViewTransition} from 'shared/ReactFeatureFlags';
+ enableViewTransition,
+ enableGestureTransition,
+} from 'shared/ReactFeatureFlags';
export type TransitionTypes = Array<string>;
+// This one is only available synchronously so we don't need to use ReactSharedInternals
+// for this state. Instead, we track it in isomorphic and pass it to the renderer.
+export function pushPendingGestureTransitionTypes(): null | TransitionTypes {
+ const prev = pendingGestureTransitionTypes;
+ pendingGestureTransitionTypes = null;
+export function popPendingGestureTransitionTypes(
+ prev: null | TransitionTypes,
+): void {
+ pendingGestureTransitionTypes = prev;
export function addTransitionType(type: string): void {
if (enableViewTransition) {
- const pendingTransitionTypes: null | TransitionTypes =
- ReactSharedInternals.V;
- if (pendingTransitionTypes === null) {
- ReactSharedInternals.V = [type];
- } else if (pendingTransitionTypes.indexOf(type) === -1) {
+ if (
+ enableGestureTransition &&
+ ReactSharedInternals.T !== null &&
+ ReactSharedInternals.T.gesture !== null
+ ) {
+ // We're inside a startGestureTransition which is always sync.
+ pendingTransitionTypes = pendingGestureTransitionTypes;
+ pendingTransitionTypes = pendingGestureTransitionTypes = [];
+ } else {
+ // Otherwise we're either inside a synchronous startTransition
+ // or in the async gap of one, which we track globally.
+ pendingTransitionTypes = ReactSharedInternals.V;
+ pendingTransitionTypes = ReactSharedInternals.V = [];
pendingTransitionTypes.push(type); | [
"- gesture={optimisticNavigate}",
"+ optimisticNavigate(direction);",
"+ const transitionType = transitionTypes[i];",
"+ );",
"+ pushPendingGestureTransitionTypes,",
"+ const prevTransitionTypes = pushPendingGestureTransitionTypes();",
"+export let pendingGestureTransitionTypes: null | TransitionTypes = null;",
"+ return prev;",
"+ let pendingTransitionTypes: null | TransitionTypes;",
"+ }",
"+ if (pendingTransitionTypes.indexOf(type) === -1) {"
] | [
14,
19,
109,
156,
233,
244,
288,
293,
309,
327,
328
] | {
"additions": 99,
"author": "sebmarkbage",
"deletions": 17,
"html_url": "https://github.com/facebook/react/pull/32792",
"issue_id": 32792,
"merged_at": "2025-04-01T16:08:55Z",
"omission_probability": 0.1,
"pr_number": 32792,
"repo": "facebook/react",
"title": "Support addTransitionType in startGestureTransition",
"total_changes": 116
} |
249 | diff --git a/runtime/themes/tokyonight_day.toml b/runtime/themes/tokyonight_day.toml
index 54caf8d6fb73..18c3b45f55d0 100644
--- a/runtime/themes/tokyonight_day.toml
+++ b/runtime/themes/tokyonight_day.toml
@@ -36,6 +36,6 @@ border = "#e9e9ed"
border-highlight = "#2496ac"
bg = "#e1e2e7"
bg-inlay = "#acd7eb"
-bg-highlight = "#c4c8da"
+bg-selection = "#c4c8da"
bg-menu = "#e9e9ec"
-bg-visual = "#b6bfe2"
+bg-focus = "#b6bfe2"
diff --git a/runtime/themes/tokyonight_moon.toml b/runtime/themes/tokyonight_moon.toml
index 8468051e6714..09b38db35e4a 100644
--- a/runtime/themes/tokyonight_moon.toml
+++ b/runtime/themes/tokyonight_moon.toml
@@ -36,6 +36,6 @@ border = "#1b1d2b"
border-highlight = "#589ed7"
bg = "#222436"
bg-inlay = "#273644"
-bg-highlight = "#2f334d"
+bg-selection = "#2f334d"
bg-menu = "#1e2030"
-bg-visual = "#2d3f76"
+bg-focus = "#2d3f76"
diff --git a/runtime/themes/tokyonight_storm.toml b/runtime/themes/tokyonight_storm.toml
index 5ec4a16a008f..7bdddd8b45b3 100644
--- a/runtime/themes/tokyonight_storm.toml
+++ b/runtime/themes/tokyonight_storm.toml
@@ -6,7 +6,7 @@ inherits = "tokyonight"
border = "#1d202f"
bg = "#24283b"
bg-inlay = "#233745"
-bg-highlight = "#373d5a"
+bg-selection = "#373d5a"
bg-menu = "#1f2335"
-bg-visual = "#2e3c64"
+bg-focus = "#2e3c64"
border-highlight = "#29a4bd"
| diff --git a/runtime/themes/tokyonight_day.toml b/runtime/themes/tokyonight_day.toml
index 54caf8d6fb73..18c3b45f55d0 100644
--- a/runtime/themes/tokyonight_day.toml
+++ b/runtime/themes/tokyonight_day.toml
@@ -36,6 +36,6 @@ border = "#e9e9ed"
border-highlight = "#2496ac"
bg = "#e1e2e7"
bg-inlay = "#acd7eb"
-bg-highlight = "#c4c8da"
+bg-selection = "#c4c8da"
bg-menu = "#e9e9ec"
+bg-focus = "#b6bfe2"
diff --git a/runtime/themes/tokyonight_moon.toml b/runtime/themes/tokyonight_moon.toml
index 8468051e6714..09b38db35e4a 100644
--- a/runtime/themes/tokyonight_moon.toml
+++ b/runtime/themes/tokyonight_moon.toml
@@ -36,6 +36,6 @@ border = "#1b1d2b"
border-highlight = "#589ed7"
bg = "#222436"
bg-inlay = "#273644"
-bg-highlight = "#2f334d"
+bg-selection = "#2f334d"
bg-menu = "#1e2030"
-bg-visual = "#2d3f76"
+bg-focus = "#2d3f76"
diff --git a/runtime/themes/tokyonight_storm.toml b/runtime/themes/tokyonight_storm.toml
index 5ec4a16a008f..7bdddd8b45b3 100644
--- a/runtime/themes/tokyonight_storm.toml
+++ b/runtime/themes/tokyonight_storm.toml
@@ -6,7 +6,7 @@ inherits = "tokyonight"
border = "#1d202f"
bg = "#24283b"
bg-inlay = "#233745"
-bg-highlight = "#373d5a"
+bg-selection = "#373d5a"
bg-menu = "#1f2335"
-bg-visual = "#2e3c64"
+bg-focus = "#2e3c64"
border-highlight = "#29a4bd" | [
"-bg-visual = \"#b6bfe2\""
] | [
11
] | {
"additions": 6,
"author": "tamakiii",
"deletions": 6,
"html_url": "https://github.com/helix-editor/helix/pull/13375",
"issue_id": 13375,
"merged_at": "2025-04-18T14:59:53Z",
"omission_probability": 0.1,
"pr_number": 13375,
"repo": "helix-editor/helix",
"title": "Fix tokyonight_* theme color keys",
"total_changes": 12
} |
250 | diff --git a/runtime/themes/serika-dark.toml b/runtime/themes/serika-dark.toml
index 10ceacd152a1..b86796db65de 100644
--- a/runtime/themes/serika-dark.toml
+++ b/runtime/themes/serika-dark.toml
@@ -11,7 +11,7 @@
"constant" = "purple"
"number" = "purple"
"string" = "fg"
-"comment" = "grey2"
+"comment" = { fg = "grey2", modifiers = [ "italic" ] }
"variable" = "yellow"
"variable.builtin" = "blue"
"variable.parameter" = "yellow"
@@ -33,33 +33,49 @@
"special" = "orange"
"ui.background" = { bg = "bg0" }
-"ui.cursor" = { fg = "bg0", bg = "fg" }
-"ui.cursor.match" = { fg = "grey0", bg = "grey2" }
-"ui.cursor.insert" = { fg = "bg0", bg = "bg_yellow" }
-"ui.cursor.select" = { fg = "bg0", bg = "bg_yellow" }
-"ui.linenr" = "yellow"
-"ui.linenr.selected" = { fg = "fg", modifiers = ["bold", "underlined"] }
+"ui.background.separator" = { fg = "bg2" }
+"ui.bufferline" = { fg = "grey1" }
+"ui.bufferline.active" = { fg = "yellow" }
+"ui.bufferline.background" = { bg = "bg2" }
+"ui.cursor" = { fg = "fg", bg = "dark-red" }
+"ui.cursor.match" = { fg = "grey2", bg = "pale-yellow" }
+"ui.cursor.insert" = { fg = "bg0", bg = "pale-yellow" }
+"ui.cursor.select" = { fg = "bg0", bg = "bg-yellow" }
+"ui.cursor.primary" = { fg = "dark-red", bg = "fg" }
+"ui.cursor.primary.match" = { fg = "pale-yellow", bg = "grey2" }
+"ui.cursor.primary.insert" = { fg = "dark-red", bg = "bg-yellow" }
+"ui.cursor.primary.select" = { fg = "yellow", bg = "nasty-red" }
+"ui.linenr" = { fg = "yellow", modifiers = ["dim"] }
+"ui.linenr.selected" = { fg = "fg", modifiers = ["dim"], underline.style = "line" }
"ui.cursorline" = { fg = "grey1", bg = "bg2" }
"ui.statusline" = { fg = "grey1", bg = "bg2" }
-"ui.statusline.inactive" = { fg = "grey2", bg = "bg1" }
+"ui.statusline.inactive" = { fg = "bg5", bg = "bg1" }
+"ui.statusline.insert" = { fg = "blue" }
+"ui.statusline.select" = { fg = "pale-yellow" }
"ui.popup" = { fg = "grey2", bg = "bg1" }
-"ui.window" = { fg = "grey2", bg = "bg1" }
+"ui.picker.header" = { fg = "bg2", underline.style = "dashed" }
+"ui.window" = { fg = "bg1", bg = "bg1" }
"ui.help" = { fg = "fg", bg = "bg1" }
"ui.text" = "fg"
"ui.text.focus" = "yellow"
+"ui.text.inactive" = { fg = "fg", modifiers = [ "dim" ] }
+"ui.text.directory" = "grey0"
"ui.menu" = { fg = "fg", bg = "bg2" }
-"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
-"ui.selection" = { bg = "bg3" }
-"ui.virtual.whitespace" = "bg2"
-"ui.virtual.ruler" = { bg = "grey2" }
+"ui.menu.selected" = { fg = "bg0", bg = "bg-yellow" }
+"ui.selection" = { bg = "yellow", modifiers = [ "dim" ] }
+"ui.selection.prime" = { underline.style = "line" }
"ui.virtual.inlay-hint" = { fg = "grey2", modifiers = ["italic"] }
"ui.virtual.jump-label" = { fg = "nasty-red", modifiers = ["bold"] }
+"ui.virtual.ruler" = { bg = "bg1" }
+"ui.virtual.whitespace" = { fg = "grey2", modifiers = [ "italic" ] }
+"ui.virtual.wrap" = { fg = "grey2", modifiers = [ "italic" ] }
"hint" = "blue"
"info" = "aqua"
"warning" = "yellow"
"error" = "nasty-red"
+"diagnostic" = { underline = { style = "curl", color = "purple" } }
"diagnostic.hint" = { underline = { style = "curl", color = "blue" } }
"diagnostic.info" = { underline = { style = "curl", color = "aqua" } }
"diagnostic.warning" = { underline = { style = "curl", color = "yellow" } }
@@ -89,22 +105,23 @@ bg2 = "#55585e"
bg3 = "#61656b"
bg4 = "#6d7278"
bg5 = "#797e86"
-bg_visual = "#646669"
-bg_red = "#7e2a33"
-bg_green = "#86b365"
-bg_blue = "#6a89af"
-bg_yellow = "#e2b714"
+bg-visual = "#646669"
+bg-red = "#7e2a33"
+bg-green = "#86b365"
+bg-blue = "#6a89af"
+bg-yellow = "#e2b714"
fg = "#d1d0c5"
-red = "#f9ebed"
+red = "#e29da7"
nasty-red = "#ca4754"
dark-red = "#7e2a33"
orange = "#dd8a3c"
yellow = "#e2b714"
-green = "#e5eae1"
+pale-yellow = "#f3e0a1"
+green = "#bcd5a8"
aqua = "#b9c2c6"
-blue = "#bdcadb"
-purple = "#d0c4d4"
+blue = "#adc9db"
+purple = "#be9ec9"
grey0 = "#aaaeb3"
grey1 = "#e1e1e3"
grey2 = "#646669"
diff --git a/runtime/themes/serika-light.toml b/runtime/themes/serika-light.toml
index 00fa84cbb5f7..ccc7cebffca3 100644
--- a/runtime/themes/serika-light.toml
+++ b/runtime/themes/serika-light.toml
@@ -11,7 +11,7 @@
"constant" = "purple"
"number" = "purple"
"string" = "fg"
-"comment" = "grey2"
+"comment" = { fg = "grey2", modifiers = [ "italic" ] }
"variable" = "yellow"
"variable.builtin" = "blue"
"variable.parameter" = "yellow"
@@ -21,7 +21,7 @@
"punctuation.delimiter" = "grey2"
"punctuation.bracket" = "fg"
"keyword" = "red"
-"operator" = "grey0"
+"operator" = "grey2"
"function" = "green"
"function.builtin" = "blue"
"function.macro" = "aqua"
@@ -33,32 +33,49 @@
"special" = "orange"
"ui.background" = { bg = "bg0" }
-"ui.cursor" = { fg = "bg0", bg = "fg" }
-"ui.cursor.match" = { fg = "grey1", bg = "grey2" }
-"ui.cursor.insert" = { fg = "bg0", bg = "bg_yellow" }
-"ui.cursor.select" = { fg = "bg0", bg = "bg_yellow" }
-"ui.linenr" = "yellow"
-"ui.linenr.selected" = { fg = "fg", modifiers = ["bold", "underlined"] }
-"ui.cursorline" = { bg = "bg01" }
+"ui.background.separator" = { fg = "bg5" }
+"ui.bufferline" = { fg = "grey1" }
+"ui.bufferline.active" = { fg = "pale-yellow" }
+"ui.bufferline.background" = { bg = "bg5" }
+"ui.cursor" = { fg = "bg0", bg = "dark-red" }
+"ui.cursor.match" = { fg = "pale-yellow", bg = "bg5" }
+"ui.cursor.insert" = { fg = "fg", bg = "pale-yellow" }
+"ui.cursor.select" = { fg = "fg", bg = "bg-yellow" }
+"ui.cursor.primary" = { fg = "nasty-red", bg = "grey0" }
+"ui.cursor.primary.match" = { fg = "grey2", bg = "pale-yellow" }
+"ui.cursor.primary.insert" = { fg = "dark-red", bg = "yellow" }
+"ui.cursor.primary.select" = { fg = "yellow", bg = "dark-red" }
+"ui.linenr" = { fg = "yellow", modifiers = ["dim"] }
+"ui.linenr.selected" = { fg = "fg", modifiers = ["dim"], underline.style = "line" }
+"ui.cursorline" = { bg = "bg0", modifiers = ["dim"] }
"ui.statusline" = { fg = "grey1", bg = "bg5" }
-"ui.statusline.inactive" = { fg = "grey2", bg = "bg1" }
+"ui.statusline.inactive" = { fg = "grey1", bg = "bg3" }
+"ui.statusline.insert" = { fg = "blue" }
+"ui.statusline.select" = { fg = "pale-yellow" }
"ui.popup" = { fg = "bg0", bg = "bg5" }
-"ui.window" = { fg = "bg0", bg = "bg5" }
+"ui.picker.header" = { fg = "bg2", underline.style = "dashed" }
+"ui.window" = { fg = "bg5", bg = "bg5" }
"ui.help" = { fg = "bg0", bg = "bg5" }
"ui.text" = "fg"
"ui.text.focus" = "yellow"
+"ui.text.inactive" = { fg = "fg", modifiers = [ "dim" ] }
+"ui.text.directory" = "grey2"
"ui.menu" = { fg = "bg0", bg = "bg3" }
-"ui.menu.selected" = { fg = "bg0", bg = "bg_yellow" }
-"ui.selection" = { fg = "bg0", bg = "bg3" }
-"ui.virtual.whitespace" = { fg = "bg2" }
-"ui.virtual.ruler" = { bg = "bg01" }
+"ui.menu.selected" = { fg = "bg0", bg = "bg-yellow" }
+"ui.selection" = { bg = "grey0", modifiers = [ "dim" ] }
+"ui.selection.prime" = { underline.style = "line" }
"ui.virtual.inlay-hint" = { fg = "grey2", modifiers = ["italic"] }
+"ui.virtual.jump-label" = { fg = "nasty-red", modifiers = ["bold"] }
+"ui.virtual.ruler" = { bg = "bg0", modifiers = ["dim"] }
+"ui.virtual.whitespace" = { fg = "grey2", modifiers = [ "italic" ] }
+"ui.virtual.wrap" = { fg = "grey2", modifiers = [ "italic" ] }
"hint" = "blue"
"info" = "aqua"
"warning" = "yellow"
"error" = "nasty-red"
+"diagnostic" = { underline = { style = "curl", color = "purple" } }
"diagnostic.hint" = { underline = { style = "curl", color = "blue" } }
"diagnostic.info" = { underline = { style = "curl", color = "aqua" } }
"diagnostic.warning" = { underline = { style = "curl", color = "yellow" } }
@@ -66,8 +83,8 @@
"diagnostic.unnecessary" = { modifiers = ["dim"] }
"diagnostic.deprecated" = { modifiers = ["crossed_out"] }
-"diff.plus" = { fg = "bg_green" }
-"diff.delta" = { fg = "bg_blue" }
+"diff.plus" = { fg = "bg-green" }
+"diff.delta" = { fg = "bg-blue" }
"diff.minus" = { fg = "nasty-red" }
"markup.heading" = { fg = "purple", modifiers = ["bold"] }
@@ -82,18 +99,17 @@
[palette]
-bg0 = "#e1e1e3"
-bg01 = "#eaeaec"
+bg0 = "#d1d0c5"
bg1 = "#494c50"
bg2 = "#55585e"
bg3 = "#61656b"
bg4 = "#6d7278"
bg5 = "#797e86"
-bg_visual = "#646669"
-bg_red = "#7e2a33"
-bg_green = "#86b365"
-bg_blue = "#6a89af"
-bg_yellow = "#e2b714"
+bg-visual = "#646669"
+bg-red = "#7e2a33"
+bg-green = "#86b365"
+bg-blue = "#6a89af"
+bg-yellow = "#e2b714"
fg = "#323437"
red = "#621d28"
@@ -101,10 +117,11 @@ nasty-red = "#da3333"
dark-red = "#791717"
orange = "#57320f"
yellow = "#9a7d0e"
-green = "#3f4b34"
+pale-yellow = "#e2b714"
+green = "#3d5128"
aqua = "#455054"
blue = "#3f5673"
-purple = "#534059"
+purple = "#5a4066"
grey0 = "#aaaeb3"
grey1 = "#e1e1e3"
grey2 = "#646669"
| diff --git a/runtime/themes/serika-dark.toml b/runtime/themes/serika-dark.toml
index 10ceacd152a1..b86796db65de 100644
--- a/runtime/themes/serika-dark.toml
+++ b/runtime/themes/serika-dark.toml
@@ -33,33 +33,49 @@
-"ui.cursor.match" = { fg = "grey0", bg = "grey2" }
+"ui.background.separator" = { fg = "bg2" }
+"ui.bufferline.active" = { fg = "yellow" }
+"ui.bufferline.background" = { bg = "bg2" }
+"ui.cursor" = { fg = "fg", bg = "dark-red" }
+"ui.cursor.match" = { fg = "grey2", bg = "pale-yellow" }
+"ui.cursor.insert" = { fg = "bg0", bg = "pale-yellow" }
+"ui.cursor.primary" = { fg = "dark-red", bg = "fg" }
+"ui.cursor.primary.match" = { fg = "pale-yellow", bg = "grey2" }
+"ui.cursor.primary.insert" = { fg = "dark-red", bg = "bg-yellow" }
+"ui.cursor.primary.select" = { fg = "yellow", bg = "nasty-red" }
"ui.cursorline" = { fg = "grey1", bg = "bg2" }
"ui.statusline" = { fg = "grey1", bg = "bg2" }
+"ui.statusline.inactive" = { fg = "bg5", bg = "bg1" }
"ui.popup" = { fg = "grey2", bg = "bg1" }
-"ui.window" = { fg = "grey2", bg = "bg1" }
"ui.help" = { fg = "fg", bg = "bg1" }
+"ui.text.directory" = "grey0"
"ui.menu" = { fg = "fg", bg = "bg2" }
-"ui.selection" = { bg = "bg3" }
-"ui.virtual.whitespace" = "bg2"
-"ui.virtual.ruler" = { bg = "grey2" }
+"ui.selection" = { bg = "yellow", modifiers = [ "dim" ] }
"ui.virtual.jump-label" = { fg = "nasty-red", modifiers = ["bold"] }
+"ui.virtual.ruler" = { bg = "bg1" }
@@ -89,22 +105,23 @@ bg2 = "#55585e"
fg = "#d1d0c5"
+red = "#e29da7"
nasty-red = "#ca4754"
dark-red = "#7e2a33"
orange = "#dd8a3c"
yellow = "#e2b714"
-green = "#e5eae1"
+pale-yellow = "#f3e0a1"
+green = "#bcd5a8"
aqua = "#b9c2c6"
-blue = "#bdcadb"
-purple = "#d0c4d4"
+blue = "#adc9db"
+purple = "#be9ec9"
diff --git a/runtime/themes/serika-light.toml b/runtime/themes/serika-light.toml
index 00fa84cbb5f7..ccc7cebffca3 100644
--- a/runtime/themes/serika-light.toml
+++ b/runtime/themes/serika-light.toml
@@ -21,7 +21,7 @@
"punctuation.delimiter" = "grey2"
"punctuation.bracket" = "fg"
"keyword" = "red"
-"operator" = "grey0"
+"operator" = "grey2"
"function" = "green"
"function.builtin" = "blue"
"function.macro" = "aqua"
@@ -33,32 +33,49 @@
-"ui.cursor.match" = { fg = "grey1", bg = "grey2" }
-"ui.cursorline" = { bg = "bg01" }
+"ui.background.separator" = { fg = "bg5" }
+"ui.bufferline.active" = { fg = "pale-yellow" }
+"ui.bufferline.background" = { bg = "bg5" }
+"ui.cursor" = { fg = "bg0", bg = "dark-red" }
+"ui.cursor.match" = { fg = "pale-yellow", bg = "bg5" }
+"ui.cursor.insert" = { fg = "fg", bg = "pale-yellow" }
+"ui.cursor.select" = { fg = "fg", bg = "bg-yellow" }
+"ui.cursor.primary" = { fg = "nasty-red", bg = "grey0" }
+"ui.cursor.primary.match" = { fg = "grey2", bg = "pale-yellow" }
+"ui.cursor.primary.insert" = { fg = "dark-red", bg = "yellow" }
+"ui.cursor.primary.select" = { fg = "yellow", bg = "dark-red" }
+"ui.cursorline" = { bg = "bg0", modifiers = ["dim"] }
"ui.statusline" = { fg = "grey1", bg = "bg5" }
+"ui.statusline.inactive" = { fg = "grey1", bg = "bg3" }
"ui.popup" = { fg = "bg0", bg = "bg5" }
-"ui.window" = { fg = "bg0", bg = "bg5" }
+"ui.window" = { fg = "bg5", bg = "bg5" }
"ui.help" = { fg = "bg0", bg = "bg5" }
+"ui.text.directory" = "grey2"
"ui.menu" = { fg = "bg0", bg = "bg3" }
-"ui.selection" = { fg = "bg0", bg = "bg3" }
-"ui.virtual.ruler" = { bg = "bg01" }
+"ui.selection" = { bg = "grey0", modifiers = [ "dim" ] }
+"ui.virtual.jump-label" = { fg = "nasty-red", modifiers = ["bold"] }
+"ui.virtual.ruler" = { bg = "bg0", modifiers = ["dim"] }
@@ -66,8 +83,8 @@
"diagnostic.unnecessary" = { modifiers = ["dim"] }
"diagnostic.deprecated" = { modifiers = ["crossed_out"] }
-"diff.delta" = { fg = "bg_blue" }
+"diff.plus" = { fg = "bg-green" }
+"diff.delta" = { fg = "bg-blue" }
"diff.minus" = { fg = "nasty-red" }
"markup.heading" = { fg = "purple", modifiers = ["bold"] }
@@ -82,18 +99,17 @@
[palette]
-bg0 = "#e1e1e3"
-bg01 = "#eaeaec"
+bg0 = "#d1d0c5"
bg1 = "#494c50"
bg2 = "#55585e"
fg = "#323437"
red = "#621d28"
@@ -101,10 +117,11 @@ nasty-red = "#da3333"
dark-red = "#791717"
orange = "#57320f"
yellow = "#9a7d0e"
-green = "#3f4b34"
+pale-yellow = "#e2b714"
aqua = "#455054"
blue = "#3f5673"
+purple = "#5a4066" | [
"+\"ui.cursor.select\" = { fg = \"bg0\", bg = \"bg-yellow\" }",
"+\"ui.window\" = { fg = \"bg1\", bg = \"bg1\" }",
"-red = \"#f9ebed\"",
"-\"ui.virtual.whitespace\" = { fg = \"bg2\" }",
"-\"diff.plus\" = { fg = \"bg_green\" }",
"+green = \"#3d5128\"",
"-purple = \"#534059\""
] | [
30,
46,
91,
173,
197,
235,
238
] | {
"additions": 82,
"author": "VuiMuich",
"deletions": 48,
"html_url": "https://github.com/helix-editor/helix/pull/13341",
"issue_id": 13341,
"merged_at": "2025-04-15T23:17:05Z",
"omission_probability": 0.1,
"pr_number": 13341,
"repo": "helix-editor/helix",
"title": "update serika themes",
"total_changes": 130
} |
251 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index f866c4b4ab07..39c974ccf3a6 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -182,6 +182,7 @@
| purescript | β | β | | `purescript-language-server` |
| python | β | β | β | `ruff`, `jedi-language-server`, `pylsp` |
| qml | β | | β | `qmlls` |
+| quarto | β | | β | |
| quint | β | | | `quint-language-server` |
| r | β | | | `R` |
| racket | β | | β | `racket` |
diff --git a/languages.toml b/languages.toml
index f871d1b31257..68e8c07a74fc 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2047,6 +2047,16 @@ auto-format = true
name = "gleam"
source = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "426e67087fd62be5f4533581b5916b2cf010fb5b" }
+[[language]]
+name = "quarto"
+scope = "source.qmd"
+language-id = "qmd"
+injection-regex = "qmd"
+file-types = ["qmd"]
+indent = { tab-width = 2, unit = " " }
+grammar = "markdown"
+block-comment-tokens = { start = "<!--", end = "-->" }
+
[[language]]
name = "ron"
scope = "source.ron"
diff --git a/runtime/queries/quarto/highlights.scm b/runtime/queries/quarto/highlights.scm
new file mode 100644
index 000000000000..a3a30e342921
--- /dev/null
+++ b/runtime/queries/quarto/highlights.scm
@@ -0,0 +1 @@
+; inherits: markdown
diff --git a/runtime/queries/quarto/indents.scm b/runtime/queries/quarto/indents.scm
new file mode 100644
index 000000000000..a3a30e342921
--- /dev/null
+++ b/runtime/queries/quarto/indents.scm
@@ -0,0 +1 @@
+; inherits: markdown
diff --git a/runtime/queries/quarto/injections.scm b/runtime/queries/quarto/injections.scm
new file mode 100644
index 000000000000..a3a30e342921
--- /dev/null
+++ b/runtime/queries/quarto/injections.scm
@@ -0,0 +1 @@
+; inherits: markdown
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index f866c4b4ab07..39c974ccf3a6 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -182,6 +182,7 @@
| purescript | β | β | | `purescript-language-server` |
| python | β | β | β | `ruff`, `jedi-language-server`, `pylsp` |
| qml | β | | β | `qmlls` |
+| quarto | β | | β | |
| quint | β | | | `quint-language-server` |
| r | β | | | `R` |
| racket | β | | β | `racket` |
diff --git a/languages.toml b/languages.toml
index f871d1b31257..68e8c07a74fc 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2047,6 +2047,16 @@ auto-format = true
name = "gleam"
source = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "426e67087fd62be5f4533581b5916b2cf010fb5b" }
+[[language]]
+name = "quarto"
+scope = "source.qmd"
+language-id = "qmd"
+file-types = ["qmd"]
+indent = { tab-width = 2, unit = " " }
+grammar = "markdown"
+block-comment-tokens = { start = "<!--", end = "-->" }
+
[[language]]
name = "ron"
scope = "source.ron"
diff --git a/runtime/queries/quarto/highlights.scm b/runtime/queries/quarto/highlights.scm
+++ b/runtime/queries/quarto/highlights.scm
diff --git a/runtime/queries/quarto/indents.scm b/runtime/queries/quarto/indents.scm
+++ b/runtime/queries/quarto/indents.scm
diff --git a/runtime/queries/quarto/injections.scm b/runtime/queries/quarto/injections.scm
+++ b/runtime/queries/quarto/injections.scm | [
"+injection-regex = \"qmd\""
] | [
24
] | {
"additions": 14,
"author": "jamesturk",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13339",
"issue_id": 13339,
"merged_at": "2025-04-16T13:03:21Z",
"omission_probability": 0.1,
"pr_number": 13339,
"repo": "helix-editor/helix",
"title": "feat: add basic Quarto support",
"total_changes": 14
} |
252 | diff --git a/runtime/themes/gruvbox-material.toml b/runtime/themes/gruvbox-material.toml
new file mode 100644
index 000000000000..6f4c861e3f6b
--- /dev/null
+++ b/runtime/themes/gruvbox-material.toml
@@ -0,0 +1,128 @@
+# Gruvbox Material for Helix
+# Original Author: @sainnhe (https://github.com/sainnhe/gruvbox-material)
+# Ported by: @satoqz
+# License: MIT
+
+"attribute" = "green"
+"comment" = { fg = "grey1", modifiers = ["italic"] }
+"constant" = "fg0"
+"constant.builtin" = "purple"
+"constant.character.escape" = "green"
+"constant.numeric" = "purple"
+"constructor" = "green"
+"function" = "green"
+"keyword" = "red"
+"keyword.directive" = "purple"
+"keyword.operator" = "orange"
+"label" = "red"
+"namespace" = "yellow"
+"operator" = "orange"
+"punctuation" = "grey1"
+"punctuation.bracket" = "fg0"
+"punctuation.delimiter" = "grey1"
+"punctuation.special" = "blue"
+"special" = "green"
+"string" = "aqua"
+"string.regexp" = "green"
+"string.special.path" = "yellow"
+"string.special.symbol" = "fg0"
+"string.special.url" = { fg = "fg0", modifiers = ["underlined"] }
+"tag" = "orange"
+"type" = "yellow"
+"type.enum.variant" = "purple"
+"variable" = "fg0"
+"variable.builtin" = "purple"
+"variable.other.member" = "blue"
+"variable.parameter" = "fg0"
+
+"markup.heading.1" = "red"
+"markup.heading.2" = "orange"
+"markup.heading.3" = "yellow"
+"markup.heading.4" = "green"
+"markup.heading.5" = "blue"
+"markup.heading.6" = "purple"
+
+"markup.bold" = { fg = "fg0", modifiers = ["bold"] }
+"markup.italic" = { fg = "fg0", modifiers = ["italic"] }
+"markup.strikethrough" = { fg = "fg0", modifiers = ["crossed_out"] }
+
+"markup.link.label" = "blue"
+"markup.link.text" = "yellow"
+"markup.link.url" = { fg = "blue", modifiers = ["underlined"] }
+"markup.list" = "blue"
+"markup.list.checked" = "green"
+"markup.list.unchecked" = "grey1"
+"markup.quote" = "grey1"
+"markup.raw" = "green"
+
+"diff.delta" = "blue"
+"diff.minus" = "red"
+"diff.plus" = "green"
+
+"diagnostic.error" = { underline = { color = "red", style = "curl" } }
+"diagnostic.hint" = { underline = { color = "green", style = "curl" } }
+"diagnostic.info" = { underline = { color = "blue", style = "curl" } }
+"diagnostic.unnecessary" = { modifiers = ["dim"] }
+"diagnostic.warning" = { underline = { color = "yellow", style = "curl" } }
+
+error = "red"
+hint = "green"
+info = "blue"
+warning = "yellow"
+
+"ui.background" = { fg = "fg0", bg = "bg0" }
+"ui.bufferline" = { fg = "fg1", bg = "bg4" }
+"ui.bufferline.active" = { fg = "bg0", bg = "grey2" }
+"ui.bufferline.background" = { bg = "bg1" }
+"ui.cursor" = { fg = "bg0", bg = "grey1" }
+"ui.cursor.primary" = { fg = "bg0", bg = "fg0" }
+"ui.cursor.match" = { bg = "bg2" }
+"ui.cursorline.primary" = { bg = "bg1" }
+"ui.help" = { fg = "grey1", bg = "bg0" }
+"ui.highlight" = { bg = "bg2" }
+"ui.linenr" = "bg3"
+"ui.linenr.selected" = "grey1"
+"ui.menu" = { fg = "fg1", bg = "bg2" }
+"ui.menu.scroll" = { fg = "grey0", bg = "bg1" }
+"ui.menu.selected" = { fg = "bg2", bg = "grey2" }
+"ui.popup" = { fg = "fg1", bg = "bg2" }
+"ui.popup.info" = { "fg" = "grey1", bg = "bg0" }
+"ui.selection" = { bg = "bg2" }
+"ui.statusline" = { fg = "fg1", bg = "bg1" }
+"ui.statusline.inactive" = { fg = "grey1", bg = "bg1" }
+"ui.statusline.insert" = { fg = "bg0", bg = "green" }
+"ui.statusline.normal" = { fg = "bg0", bg = "grey2" }
+"ui.statusline.select" = { fg = "bg0", bg = "red" }
+"ui.text" = "fg0"
+"ui.text.directory" = { fg = "blue" }
+"ui.text.focus" = { bg = "bg2" }
+"ui.text.inactive" = { fg = "grey1" }
+"ui.text.info" = "grey1"
+"ui.virtual" = "grey0"
+"ui.virtual.indent-guide" = "bg3"
+"ui.virtual.inlay-hint" = "grey0"
+"ui.virtual.jump-label" = "grey2"
+"ui.virtual.ruler" = { bg = "bg1" }
+"ui.window" = { fg = "bg3" }
+
+[palette]
+fg0 = "#d4be98"
+fg1 = "#ddc7a1"
+
+bg0 = "#282828"
+bg1 = "#32302f"
+bg2 = "#45403d"
+bg3 = "#5a524c"
+bg4 = "#504945"
+
+grey0 = "#7c6f64"
+grey1 = "#928374"
+grey2 = "#a89984"
+
+aqua = "#89b482"
+blue = "#7daea3"
+green = "#a9b665"
+orange = "#e78a4e"
+purple = "#d3869b"
+red = "#ea6962"
+yellow = "#d8a657"
| diff --git a/runtime/themes/gruvbox-material.toml b/runtime/themes/gruvbox-material.toml
new file mode 100644
index 000000000000..6f4c861e3f6b
--- /dev/null
+++ b/runtime/themes/gruvbox-material.toml
@@ -0,0 +1,128 @@
+# Gruvbox Material for Helix
+# Original Author: @sainnhe (https://github.com/sainnhe/gruvbox-material)
+# License: MIT
+"attribute" = "green"
+"comment" = { fg = "grey1", modifiers = ["italic"] }
+"constant" = "fg0"
+"constant.character.escape" = "green"
+"constant.numeric" = "purple"
+"constructor" = "green"
+"keyword" = "red"
+"keyword.directive" = "purple"
+"keyword.operator" = "orange"
+"label" = "red"
+"namespace" = "yellow"
+"operator" = "orange"
+"punctuation" = "grey1"
+"punctuation.delimiter" = "grey1"
+"punctuation.special" = "blue"
+"special" = "green"
+"string" = "aqua"
+"string.regexp" = "green"
+"string.special.path" = "yellow"
+"string.special.symbol" = "fg0"
+"string.special.url" = { fg = "fg0", modifiers = ["underlined"] }
+"type.enum.variant" = "purple"
+"variable" = "fg0"
+"variable.builtin" = "purple"
+"variable.other.member" = "blue"
+"variable.parameter" = "fg0"
+"markup.heading.1" = "red"
+"markup.heading.2" = "orange"
+"markup.heading.3" = "yellow"
+"markup.heading.4" = "green"
+"markup.heading.5" = "blue"
+"markup.heading.6" = "purple"
+"markup.bold" = { fg = "fg0", modifiers = ["bold"] }
+"markup.italic" = { fg = "fg0", modifiers = ["italic"] }
+"markup.strikethrough" = { fg = "fg0", modifiers = ["crossed_out"] }
+"markup.link.label" = "blue"
+"markup.link.text" = "yellow"
+"markup.link.url" = { fg = "blue", modifiers = ["underlined"] }
+"markup.list" = "blue"
+"markup.list.checked" = "green"
+"markup.list.unchecked" = "grey1"
+"markup.quote" = "grey1"
+"markup.raw" = "green"
+"diff.delta" = "blue"
+"diff.plus" = "green"
+"diagnostic.error" = { underline = { color = "red", style = "curl" } }
+"diagnostic.hint" = { underline = { color = "green", style = "curl" } }
+"diagnostic.info" = { underline = { color = "blue", style = "curl" } }
+"diagnostic.unnecessary" = { modifiers = ["dim"] }
+"diagnostic.warning" = { underline = { color = "yellow", style = "curl" } }
+error = "red"
+hint = "green"
+info = "blue"
+warning = "yellow"
+"ui.background" = { fg = "fg0", bg = "bg0" }
+"ui.bufferline" = { fg = "fg1", bg = "bg4" }
+"ui.bufferline.active" = { fg = "bg0", bg = "grey2" }
+"ui.bufferline.background" = { bg = "bg1" }
+"ui.cursor" = { fg = "bg0", bg = "grey1" }
+"ui.cursor.match" = { bg = "bg2" }
+"ui.cursorline.primary" = { bg = "bg1" }
+"ui.help" = { fg = "grey1", bg = "bg0" }
+"ui.highlight" = { bg = "bg2" }
+"ui.linenr.selected" = "grey1"
+"ui.menu.scroll" = { fg = "grey0", bg = "bg1" }
+"ui.menu.selected" = { fg = "bg2", bg = "grey2" }
+"ui.popup" = { fg = "fg1", bg = "bg2" }
+"ui.popup.info" = { "fg" = "grey1", bg = "bg0" }
+"ui.selection" = { bg = "bg2" }
+"ui.statusline" = { fg = "fg1", bg = "bg1" }
+"ui.statusline.inactive" = { fg = "grey1", bg = "bg1" }
+"ui.statusline.insert" = { fg = "bg0", bg = "green" }
+"ui.statusline.normal" = { fg = "bg0", bg = "grey2" }
+"ui.text" = "fg0"
+"ui.text.directory" = { fg = "blue" }
+"ui.text.focus" = { bg = "bg2" }
+"ui.text.inactive" = { fg = "grey1" }
+"ui.text.info" = "grey1"
+"ui.virtual" = "grey0"
+"ui.virtual.indent-guide" = "bg3"
+"ui.virtual.inlay-hint" = "grey0"
+"ui.virtual.jump-label" = "grey2"
+"ui.virtual.ruler" = { bg = "bg1" }
+"ui.window" = { fg = "bg3" }
+[palette]
+fg0 = "#d4be98"
+bg0 = "#282828"
+bg1 = "#32302f"
+bg2 = "#45403d"
+bg3 = "#5a524c"
+bg4 = "#504945"
+grey0 = "#7c6f64"
+grey1 = "#928374"
+grey2 = "#a89984"
+aqua = "#89b482"
+blue = "#7daea3"
+green = "#a9b665"
+orange = "#e78a4e"
+purple = "#d3869b"
+red = "#ea6962"
+yellow = "#d8a657" | [
"+# Ported by: @satoqz",
"+\"constant.builtin\" = \"purple\"",
"+\"function\" = \"green\"",
"+\"punctuation.bracket\" = \"fg0\"",
"+\"tag\" = \"orange\"",
"+\"type\" = \"yellow\"",
"+\"diff.minus\" = \"red\"",
"+\"ui.cursor.primary\" = { fg = \"bg0\", bg = \"fg0\" }",
"+\"ui.linenr\" = \"bg3\"",
"+\"ui.menu\" = { fg = \"fg1\", bg = \"bg2\" }",
"+\"ui.statusline.select\" = { fg = \"bg0\", bg = \"red\" }",
"+fg1 = \"#ddc7a1\""
] | [
8,
14,
18,
26,
35,
36,
64,
83,
88,
90,
100,
115
] | {
"additions": 128,
"author": "satoqz",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13311",
"issue_id": 13311,
"merged_at": "2025-04-15T23:19:03Z",
"omission_probability": 0.1,
"pr_number": 13311,
"repo": "helix-editor/helix",
"title": "feat(themes): add gruvbox-material",
"total_changes": 128
} |
253 | diff --git a/Cargo.lock b/Cargo.lock
index 2087b9a438a8..f606cc6f3d58 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,9 +68,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.97"
+version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
+checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
[[package]]
name = "arc-swap"
@@ -145,9 +145,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "cc"
-version = "1.2.18"
+version = "1.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "525046617d8376e3db1deffb079e91cef90a89fc3ca5c185bbf8c9ecdd15cd5c"
+checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
dependencies = [
"shlex",
]
@@ -2931,13 +2931,13 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]]
name = "which"
-version = "7.0.2"
+version = "7.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
+checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762"
dependencies = [
"either",
"env_home",
- "rustix 0.38.44",
+ "rustix 1.0.5",
"winsafe",
]
| diff --git a/Cargo.lock b/Cargo.lock
index 2087b9a438a8..f606cc6f3d58 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,9 +68,9 @@ dependencies = [
name = "anyhow"
-version = "1.0.97"
+version = "1.0.98"
-checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
+checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
name = "arc-swap"
@@ -145,9 +145,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
name = "cc"
-version = "1.2.18"
-checksum = "525046617d8376e3db1deffb079e91cef90a89fc3ca5c185bbf8c9ecdd15cd5c"
+checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
"shlex",
@@ -2931,13 +2931,13 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
name = "which"
-version = "7.0.2"
-checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
+checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762"
"either",
"env_home",
- "rustix 0.38.44",
+ "rustix 1.0.5",
"winsafe", | [
"+version = \"1.2.19\"",
"+version = \"7.0.3\""
] | [
21,
33
] | {
"additions": 7,
"author": "dependabot[bot]",
"deletions": 7,
"html_url": "https://github.com/helix-editor/helix/pull/13351",
"issue_id": 13351,
"merged_at": "2025-04-15T13:23:27Z",
"omission_probability": 0.1,
"pr_number": 13351,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group with 3 updates",
"total_changes": 14
} |
254 | diff --git a/book/src/editor.md b/book/src/editor.md
index 1e5c2a507749..b79792058b80 100644
--- a/book/src/editor.md
+++ b/book/src/editor.md
@@ -104,6 +104,8 @@ separator = "β"
mode.normal = "NORMAL"
mode.insert = "INSERT"
mode.select = "SELECT"
+diagnostics = ["warning", "error"]
+workspace-diagnostics = ["warning", "error"]
```
The `[editor.statusline]` key takes the following sub-keys:
@@ -116,6 +118,8 @@ The `[editor.statusline]` key takes the following sub-keys:
| `mode.normal` | The text shown in the `mode` element for normal mode | `"NOR"` |
| `mode.insert` | The text shown in the `mode` element for insert mode | `"INS"` |
| `mode.select` | The text shown in the `mode` element for select mode | `"SEL"` |
+| `diagnostics` | A list of severities which are displayed for the current buffer | `["warning", "error"]` |
+| `workspace-diagnostics` | A list of severities which are displayed for the workspace | `["warning", "error"]` |
The following statusline elements can be configured:
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index 7437cbd074e5..adf01bdade52 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -226,36 +226,58 @@ fn render_diagnostics<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
- let (warnings, errors) = context
- .doc
- .diagnostics()
- .iter()
- .fold((0, 0), |mut counts, diag| {
- use helix_core::diagnostic::Severity;
- match diag.severity {
- Some(Severity::Warning) => counts.0 += 1,
- Some(Severity::Error) | None => counts.1 += 1,
- _ => {}
- }
- counts
- });
-
- if warnings > 0 {
- write(
- context,
- "β".to_string(),
- Some(context.editor.theme.get("warning")),
- );
- write(context, format!(" {} ", warnings), None);
- }
+ use helix_core::diagnostic::Severity;
+ let (hints, info, warnings, errors) =
+ context
+ .doc
+ .diagnostics()
+ .iter()
+ .fold((0, 0, 0, 0), |mut counts, diag| {
+ match diag.severity {
+ Some(Severity::Hint) | None => counts.0 += 1,
+ Some(Severity::Info) => counts.1 += 1,
+ Some(Severity::Warning) => counts.2 += 1,
+ Some(Severity::Error) => counts.3 += 1,
+ }
+ counts
+ });
- if errors > 0 {
- write(
- context,
- "β".to_string(),
- Some(context.editor.theme.get("error")),
- );
- write(context, format!(" {} ", errors), None);
+ for sev in &context.editor.config().statusline.diagnostics {
+ match sev {
+ Severity::Hint if hints > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("hint")),
+ );
+ write(context, format!(" {} ", hints), None);
+ }
+ Severity::Info if info > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("info")),
+ );
+ write(context, format!(" {} ", info), None);
+ }
+ Severity::Warning if warnings > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("warning")),
+ );
+ write(context, format!(" {} ", warnings), None);
+ }
+ Severity::Error if errors > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("error")),
+ );
+ write(context, format!(" {} ", errors), None);
+ }
+ _ => {}
+ }
}
}
@@ -263,41 +285,61 @@ fn render_workspace_diagnostics<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
- let (warnings, errors) =
- context
- .editor
- .diagnostics
- .values()
- .flatten()
- .fold((0, 0), |mut counts, (diag, _)| {
- match diag.severity {
- Some(DiagnosticSeverity::WARNING) => counts.0 += 1,
- Some(DiagnosticSeverity::ERROR) | None => counts.1 += 1,
- _ => {}
- }
- counts
- });
+ use helix_core::diagnostic::Severity;
+ let (hints, info, warnings, errors) = context.editor.diagnostics.values().flatten().fold(
+ (0, 0, 0, 0),
+ |mut counts, (diag, _)| {
+ match diag.severity {
+ Some(DiagnosticSeverity::HINT) | None => counts.0 += 1,
+ Some(DiagnosticSeverity::INFORMATION) => counts.1 += 1,
+ Some(DiagnosticSeverity::WARNING) => counts.2 += 1,
+ Some(DiagnosticSeverity::ERROR) => counts.3 += 1,
+ _ => {}
+ }
+ counts
+ },
+ );
- if warnings > 0 || errors > 0 {
+ if hints > 0 || info > 0 || warnings > 0 || errors > 0 {
write(context, " W ".into(), None);
}
- if warnings > 0 {
- write(
- context,
- "β".to_string(),
- Some(context.editor.theme.get("warning")),
- );
- write(context, format!(" {} ", warnings), None);
- }
-
- if errors > 0 {
- write(
- context,
- "β".to_string(),
- Some(context.editor.theme.get("error")),
- );
- write(context, format!(" {} ", errors), None);
+ for sev in &context.editor.config().statusline.workspace_diagnostics {
+ match sev {
+ Severity::Hint if hints > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("hint")),
+ );
+ write(context, format!(" {} ", hints), None);
+ }
+ Severity::Info if info > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("info")),
+ );
+ write(context, format!(" {} ", info), None);
+ }
+ Severity::Warning if warnings > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("warning")),
+ );
+ write(context, format!(" {} ", warnings), None);
+ }
+ Severity::Error if errors > 0 => {
+ write(
+ context,
+ "β".to_string(),
+ Some(context.editor.theme.get("error")),
+ );
+ write(context, format!(" {} ", errors), None);
+ }
+ _ => {}
+ }
}
}
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index be22189977cc..eab291e44adf 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -497,6 +497,8 @@ pub struct StatusLineConfig {
pub right: Vec<StatusLineElement>,
pub separator: String,
pub mode: ModeConfig,
+ pub diagnostics: Vec<Severity>,
+ pub workspace_diagnostics: Vec<Severity>,
}
impl Default for StatusLineConfig {
@@ -521,6 +523,8 @@ impl Default for StatusLineConfig {
],
separator: String::from("β"),
mode: ModeConfig::default(),
+ diagnostics: vec![Severity::Warning, Severity::Error],
+ workspace_diagnostics: vec![Severity::Warning, Severity::Error],
}
}
}
| diff --git a/book/src/editor.md b/book/src/editor.md
index 1e5c2a507749..b79792058b80 100644
--- a/book/src/editor.md
+++ b/book/src/editor.md
@@ -104,6 +104,8 @@ separator = "β"
mode.normal = "NORMAL"
mode.insert = "INSERT"
mode.select = "SELECT"
+diagnostics = ["warning", "error"]
+workspace-diagnostics = ["warning", "error"]
```
The `[editor.statusline]` key takes the following sub-keys:
@@ -116,6 +118,8 @@ The `[editor.statusline]` key takes the following sub-keys:
| `mode.normal` | The text shown in the `mode` element for normal mode | `"NOR"` |
| `mode.insert` | The text shown in the `mode` element for insert mode | `"INS"` |
| `mode.select` | The text shown in the `mode` element for select mode | `"SEL"` |
+| `diagnostics` | A list of severities which are displayed for the current buffer | `["warning", "error"]` |
+| `workspace-diagnostics` | A list of severities which are displayed for the workspace | `["warning", "error"]` |
The following statusline elements can be configured:
diff --git a/helix-term/src/ui/statusline.rs b/helix-term/src/ui/statusline.rs
index 7437cbd074e5..adf01bdade52 100644
--- a/helix-term/src/ui/statusline.rs
+++ b/helix-term/src/ui/statusline.rs
@@ -226,36 +226,58 @@ fn render_diagnostics<F>(context: &mut RenderContext, write: F)
- let (warnings, errors) = context
- .doc
- .diagnostics()
- .iter()
- .fold((0, 0), |mut counts, diag| {
- match diag.severity {
- Some(Severity::Warning) => counts.0 += 1,
- Some(Severity::Error) | None => counts.1 += 1,
- _ => {}
- }
- counts
- });
+ let (hints, info, warnings, errors) =
+ context
+ .doc
+ .diagnostics()
+ .iter()
+ .fold((0, 0, 0, 0), |mut counts, diag| {
+ match diag.severity {
+ Some(Severity::Hint) | None => counts.0 += 1,
+ Some(Severity::Info) => counts.1 += 1,
+ Some(Severity::Warning) => counts.2 += 1,
+ Some(Severity::Error) => counts.3 += 1,
+ }
+ counts
+ });
@@ -263,41 +285,61 @@ fn render_workspace_diagnostics<F>(context: &mut RenderContext, write: F)
- context
- .editor
- .diagnostics
- .values()
- .fold((0, 0), |mut counts, (diag, _)| {
- match diag.severity {
- Some(DiagnosticSeverity::ERROR) | None => counts.1 += 1,
- }
- counts
- });
+ let (hints, info, warnings, errors) = context.editor.diagnostics.values().flatten().fold(
+ (0, 0, 0, 0),
+ |mut counts, (diag, _)| {
+ match diag.severity {
+ Some(DiagnosticSeverity::HINT) | None => counts.0 += 1,
+ Some(DiagnosticSeverity::WARNING) => counts.2 += 1,
+ Some(DiagnosticSeverity::ERROR) => counts.3 += 1,
+ _ => {}
+ counts
+ },
+ );
- if warnings > 0 || errors > 0 {
+ if hints > 0 || info > 0 || warnings > 0 || errors > 0 {
write(context, " W ".into(), None);
+ for sev in &context.editor.config().statusline.workspace_diagnostics {
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index be22189977cc..eab291e44adf 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -497,6 +497,8 @@ pub struct StatusLineConfig {
pub right: Vec<StatusLineElement>,
pub separator: String,
pub mode: ModeConfig,
+ pub diagnostics: Vec<Severity>,
+ pub workspace_diagnostics: Vec<Severity>,
impl Default for StatusLineConfig {
@@ -521,6 +523,8 @@ impl Default for StatusLineConfig {
],
separator: String::from("β"),
mode: ModeConfig::default(),
+ diagnostics: vec![Severity::Warning, Severity::Error],
+ workspace_diagnostics: vec![Severity::Warning, Severity::Error],
} | [
"- use helix_core::diagnostic::Severity;",
"+ for sev in &context.editor.config().statusline.diagnostics {",
"- let (warnings, errors) =",
"- .flatten()",
"- Some(DiagnosticSeverity::WARNING) => counts.0 += 1,",
"- _ => {}",
"+ Some(DiagnosticSeverity::INFORMATION) => counts.1 += 1,"
] | [
35,
75,
118,
123,
126,
128,
138
] | {
"additions": 110,
"author": "RoloEdits",
"deletions": 60,
"html_url": "https://github.com/helix-editor/helix/pull/13288",
"issue_id": 13288,
"merged_at": "2025-04-08T18:58:15Z",
"omission_probability": 0.1,
"pr_number": 13288,
"repo": "helix-editor/helix",
"title": "feat(config): add `[workspace-]diagnostics` fields to statusline",
"total_changes": 170
} |
255 | diff --git a/helix-core/src/test.rs b/helix-core/src/test.rs
index 7183302c6c69..71c71cce2812 100644
--- a/helix-core/src/test.rs
+++ b/helix-core/src/test.rs
@@ -65,7 +65,7 @@ pub fn print(s: &str) -> (String, Selection) {
let head_at_beg = iter.next_if_eq(&"|").is_some();
let last_grapheme = |s: &str| {
UnicodeSegmentation::graphemes(s, true)
- .last()
+ .next_back()
.map(String::from)
};
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index f2b78a118ae9..f82751051ade 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -39,7 +39,7 @@ fn workspace_for_uri(uri: lsp::Url) -> WorkspaceFolder {
lsp::WorkspaceFolder {
name: uri
.path_segments()
- .and_then(|segments| segments.last())
+ .and_then(|mut segments| segments.next_back())
.map(|basename| basename.to_string())
.unwrap_or_default(),
uri,
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 03adeb05bbf5..3c97a93cd63b 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -732,7 +732,7 @@ impl Component for Prompt {
fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
let area = area
.clip_left(self.prompt.len() as u16)
- .clip_right(if self.prompt.len() > 0 { 0 } else { 2 });
+ .clip_right(if self.prompt.is_empty() { 2 } else { 0 });
let anchor = self.anchor.min(self.line.len().saturating_sub(1));
let mut col = area.left() as usize
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 41c9ee1ef6e4..92c1e3ca0dcb 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -854,7 +854,7 @@ impl Document {
} else if !output.stderr.is_empty() {
log::debug!(
"Formatter printed to stderr: {}",
- String::from_utf8_lossy(&output.stderr).to_string()
+ String::from_utf8_lossy(&output.stderr)
);
}
diff --git a/helix-view/src/register.rs b/helix-view/src/register.rs
index d286a85ccafe..b2bb53ac2029 100644
--- a/helix-view/src/register.rs
+++ b/helix-view/src/register.rs
@@ -145,7 +145,8 @@ impl Registers {
}
pub fn last<'a>(&'a self, name: char, editor: &'a Editor) -> Option<Cow<'a, str>> {
- self.read(name, editor).and_then(|values| values.last())
+ self.read(name, editor)
+ .and_then(|mut values| values.next_back())
}
pub fn iter_preview(&self) -> impl Iterator<Item = (char, &str)> {
| diff --git a/helix-core/src/test.rs b/helix-core/src/test.rs
index 7183302c6c69..71c71cce2812 100644
--- a/helix-core/src/test.rs
+++ b/helix-core/src/test.rs
@@ -65,7 +65,7 @@ pub fn print(s: &str) -> (String, Selection) {
let head_at_beg = iter.next_if_eq(&"|").is_some();
let last_grapheme = |s: &str| {
UnicodeSegmentation::graphemes(s, true)
- .last()
.map(String::from)
};
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index f2b78a118ae9..f82751051ade 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -39,7 +39,7 @@ fn workspace_for_uri(uri: lsp::Url) -> WorkspaceFolder {
lsp::WorkspaceFolder {
name: uri
.path_segments()
- .and_then(|segments| segments.last())
+ .and_then(|mut segments| segments.next_back())
.map(|basename| basename.to_string())
.unwrap_or_default(),
uri,
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 03adeb05bbf5..3c97a93cd63b 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -732,7 +732,7 @@ impl Component for Prompt {
fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
let area = area
.clip_left(self.prompt.len() as u16)
- .clip_right(if self.prompt.len() > 0 { 0 } else { 2 });
+ .clip_right(if self.prompt.is_empty() { 2 } else { 0 });
let anchor = self.anchor.min(self.line.len().saturating_sub(1));
let mut col = area.left() as usize
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 41c9ee1ef6e4..92c1e3ca0dcb 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -854,7 +854,7 @@ impl Document {
} else if !output.stderr.is_empty() {
log::debug!(
"Formatter printed to stderr: {}",
+ String::from_utf8_lossy(&output.stderr)
);
}
diff --git a/helix-view/src/register.rs b/helix-view/src/register.rs
index d286a85ccafe..b2bb53ac2029 100644
--- a/helix-view/src/register.rs
+++ b/helix-view/src/register.rs
@@ -145,7 +145,8 @@ impl Registers {
pub fn last<'a>(&'a self, name: char, editor: &'a Editor) -> Option<Cow<'a, str>> {
- self.read(name, editor).and_then(|values| values.last())
+ self.read(name, editor)
+ .and_then(|mut values| values.next_back())
pub fn iter_preview(&self) -> impl Iterator<Item = (char, &str)> { | [
"+ .next_back()",
"- String::from_utf8_lossy(&output.stderr).to_string()"
] | [
9,
47
] | {
"additions": 6,
"author": "RoloEdits",
"deletions": 5,
"html_url": "https://github.com/helix-editor/helix/pull/13266",
"issue_id": 13266,
"merged_at": "2025-04-06T17:03:15Z",
"omission_probability": 0.1,
"pr_number": 13266,
"repo": "helix-editor/helix",
"title": "fix(lints): clippy 1.86",
"total_changes": 11
} |
256 | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f712a531537e..5cdc795fc4bf 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,8 +35,8 @@ jobs:
uses: actions/cache@v4
with:
path: runtime/grammars
- key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
- restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+ key: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
- name: Run cargo check
run: cargo check
@@ -65,8 +65,8 @@ jobs:
uses: actions/cache@v4
with:
path: runtime/grammars
- key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
- restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+ key: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
- name: Run cargo test
run: cargo test --workspace
@@ -76,7 +76,7 @@ jobs:
strategy:
matrix:
- os: [ubuntu-latest, macos-latest, windows-latest]
+ os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm]
lints:
name: Lints
@@ -100,8 +100,8 @@ jobs:
uses: actions/cache@v4
with:
path: runtime/grammars
- key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
- restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+ key: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
- name: Run cargo fmt
run: cargo fmt --all --check
@@ -135,8 +135,8 @@ jobs:
uses: actions/cache@v4
with:
path: runtime/grammars
- key: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
- restore-keys: ${{ runner.os }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
+ key: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-${{ hashFiles('languages.toml') }}
+ restore-keys: ${{ runner.os }}-${{ runner.arch }}-stable-v${{ env.GRAMMAR_CACHE_VERSION }}-tree-sitter-grammars-
- name: Validate queries
run: cargo xtask query-check
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index de0a25f67721..273680e49cdb 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -58,18 +58,18 @@ jobs:
strategy:
fail-fast: false # don't fail other jobs if one fails
matrix:
- build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
+ build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
include:
- build: x86_64-linux
- os: ubuntu-22.04
+ os: ubuntu-24.04
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
- build: aarch64-linux
- os: ubuntu-22.04
+ os: ubuntu-24.04-arm
rust: stable
target: aarch64-unknown-linux-gnu
- cross: true
+ cross: false
# - build: riscv64-linux
# os: ubuntu-22.04
# rust: stable
| diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f712a531537e..5cdc795fc4bf 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,8 +35,8 @@ jobs:
- name: Run cargo check
run: cargo check
@@ -65,8 +65,8 @@ jobs:
- name: Run cargo test
run: cargo test --workspace
@@ -76,7 +76,7 @@ jobs:
- os: [ubuntu-latest, macos-latest, windows-latest]
+ os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm]
lints:
name: Lints
@@ -100,8 +100,8 @@ jobs:
- name: Run cargo fmt
run: cargo fmt --all --check
@@ -135,8 +135,8 @@ jobs:
- name: Validate queries
run: cargo xtask query-check
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index de0a25f67721..273680e49cdb 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -58,18 +58,18 @@ jobs:
fail-fast: false # don't fail other jobs if one fails
- build: [x86_64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
+ build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows] #, x86_64-win-gnu, win32-msvc
include:
- build: x86_64-linux
+ os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
cross: false
- build: aarch64-linux
target: aarch64-unknown-linux-gnu
- cross: true
+ cross: false
# - build: riscv64-linux
# os: ubuntu-22.04
# rust: stable | [
"+ os: ubuntu-24.04-arm"
] | [
76
] | {
"additions": 13,
"author": "RoloEdits",
"deletions": 13,
"html_url": "https://github.com/helix-editor/helix/pull/13273",
"issue_id": 13273,
"merged_at": "2025-04-08T16:54:12Z",
"omission_probability": 0.1,
"pr_number": 13273,
"repo": "helix-editor/helix",
"title": "ci: add arm64 runner",
"total_changes": 26
} |
257 | diff --git a/book/src/generated/static-cmd.md b/book/src/generated/static-cmd.md
index af7515b8e824..f6a82020f7e1 100644
--- a/book/src/generated/static-cmd.md
+++ b/book/src/generated/static-cmd.md
@@ -126,8 +126,10 @@
| `add_newline_below` | Add newline below | normal: `` ]<space> ``, select: `` ]<space> `` |
| `goto_type_definition` | Goto type definition | normal: `` gy ``, select: `` gy `` |
| `goto_implementation` | Goto implementation | normal: `` gi ``, select: `` gi `` |
-| `goto_file_start` | Goto line number <n> else file start | normal: `` gg ``, select: `` gg `` |
+| `goto_file_start` | Goto line number <n> else file start | normal: `` gg `` |
| `goto_file_end` | Goto file end | |
+| `extend_to_file_start` | Extend to line number<n> else file start | select: `` gg `` |
+| `extend_to_file_end` | Extend to file end | |
| `goto_file` | Goto files/URLs in selections | normal: `` gf ``, select: `` gf `` |
| `goto_file_hsplit` | Goto files in selections (hsplit) | normal: `` <C-w>f ``, `` <space>wf ``, select: `` <C-w>f ``, `` <space>wf `` |
| `goto_file_vsplit` | Goto files in selections (vsplit) | normal: `` <C-w>F ``, `` <space>wF ``, select: `` <C-w>F ``, `` <space>wF `` |
@@ -139,7 +141,8 @@
| `goto_last_modified_file` | Goto last modified file | normal: `` gm ``, select: `` gm `` |
| `goto_last_modification` | Goto last modification | normal: `` g. ``, select: `` g. `` |
| `goto_line` | Goto line | normal: `` G ``, select: `` G `` |
-| `goto_last_line` | Goto last line | normal: `` ge ``, select: `` ge `` |
+| `goto_last_line` | Goto last line | normal: `` ge `` |
+| `extend_to_last_line` | Extend to last line | select: `` ge `` |
| `goto_first_diag` | Goto first diagnostic | normal: `` [D ``, select: `` [D `` |
| `goto_last_diag` | Goto last diagnostic | normal: `` ]D ``, select: `` ]D `` |
| `goto_next_diag` | Goto next diagnostic | normal: `` ]d ``, select: `` ]d `` |
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index a197792eff59..0b2a48607921 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -427,6 +427,8 @@ impl MappableCommand {
goto_implementation, "Goto implementation",
goto_file_start, "Goto line number <n> else file start",
goto_file_end, "Goto file end",
+ extend_to_file_start, "Extend to line number<n> else file start",
+ extend_to_file_end, "Extend to file end",
goto_file, "Goto files/URLs in selections",
goto_file_hsplit, "Goto files in selections (hsplit)",
goto_file_vsplit, "Goto files in selections (vsplit)",
@@ -439,6 +441,7 @@ impl MappableCommand {
goto_last_modification, "Goto last modification",
goto_line, "Goto line",
goto_last_line, "Goto last line",
+ extend_to_last_line, "Extend to last line",
goto_first_diag, "Goto first diagnostic",
goto_last_diag, "Goto last diagnostic",
goto_next_diag, "Goto next diagnostic",
@@ -1254,28 +1257,44 @@ fn goto_next_paragraph(cx: &mut Context) {
}
fn goto_file_start(cx: &mut Context) {
+ goto_file_start_impl(cx, Movement::Move);
+}
+
+fn extend_to_file_start(cx: &mut Context) {
+ goto_file_start_impl(cx, Movement::Extend);
+}
+
+fn goto_file_start_impl(cx: &mut Context, movement: Movement) {
if cx.count.is_some() {
- goto_line(cx);
+ goto_line_impl(cx, movement);
} else {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc
.selection(view.id)
.clone()
- .transform(|range| range.put_cursor(text, 0, cx.editor.mode == Mode::Select));
+ .transform(|range| range.put_cursor(text, 0, movement == Movement::Extend));
push_jump(view, doc);
doc.set_selection(view.id, selection);
}
}
fn goto_file_end(cx: &mut Context) {
+ goto_file_end_impl(cx, Movement::Move);
+}
+
+fn extend_to_file_end(cx: &mut Context) {
+ goto_file_end_impl(cx, Movement::Extend)
+}
+
+fn goto_file_end_impl(cx: &mut Context, movement: Movement) {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let pos = doc.text().len_chars();
let selection = doc
.selection(view.id)
.clone()
- .transform(|range| range.put_cursor(text, pos, cx.editor.mode == Mode::Select));
+ .transform(|range| range.put_cursor(text, pos, movement == Movement::Extend));
push_jump(view, doc);
doc.set_selection(view.id, selection);
}
@@ -3747,15 +3766,23 @@ fn push_jump(view: &mut View, doc: &Document) {
}
fn goto_line(cx: &mut Context) {
+ goto_line_impl(cx, Movement::Move);
+}
+
+fn goto_line_impl(cx: &mut Context, movement: Movement) {
if cx.count.is_some() {
let (view, doc) = current!(cx.editor);
push_jump(view, doc);
- goto_line_without_jumplist(cx.editor, cx.count);
+ goto_line_without_jumplist(cx.editor, cx.count, movement);
}
}
-fn goto_line_without_jumplist(editor: &mut Editor, count: Option<NonZeroUsize>) {
+fn goto_line_without_jumplist(
+ editor: &mut Editor,
+ count: Option<NonZeroUsize>,
+ movement: Movement,
+) {
if let Some(count) = count {
let (view, doc) = current!(editor);
let text = doc.text().slice(..);
@@ -3770,13 +3797,21 @@ fn goto_line_without_jumplist(editor: &mut Editor, count: Option<NonZeroUsize>)
let selection = doc
.selection(view.id)
.clone()
- .transform(|range| range.put_cursor(text, pos, editor.mode == Mode::Select));
+ .transform(|range| range.put_cursor(text, pos, movement == Movement::Extend));
doc.set_selection(view.id, selection);
}
}
fn goto_last_line(cx: &mut Context) {
+ goto_last_line_impl(cx, Movement::Move)
+}
+
+fn extend_to_last_line(cx: &mut Context) {
+ goto_last_line_impl(cx, Movement::Extend)
+}
+
+fn goto_last_line_impl(cx: &mut Context, movement: Movement) {
let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let line_idx = if text.line(text.len_lines() - 1).len_chars() == 0 {
@@ -3789,7 +3824,7 @@ fn goto_last_line(cx: &mut Context) {
let selection = doc
.selection(view.id)
.clone()
- .transform(|range| range.put_cursor(text, pos, cx.editor.mode == Mode::Select));
+ .transform(|range| range.put_cursor(text, pos, movement == Movement::Extend));
push_jump(view, doc);
doc.set_selection(view.id, selection);
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 1d57930cc70b..6e2a92ce5e16 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1819,7 +1819,15 @@ fn update_goto_line_number_preview(cx: &mut compositor::Context, args: Args) ->
let scrolloff = cx.editor.config().scrolloff;
let line = args[0].parse::<usize>()?;
- goto_line_without_jumplist(cx.editor, NonZeroUsize::new(line));
+ goto_line_without_jumplist(
+ cx.editor,
+ NonZeroUsize::new(line),
+ if cx.editor.mode == Mode::Select {
+ Movement::Extend
+ } else {
+ Movement::Move
+ },
+ );
let (view, doc) = current!(cx.editor);
view.ensure_cursor_in_view(doc, scrolloff);
diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs
index e160b2246b1e..b9189eb304ca 100644
--- a/helix-term/src/keymap/default.rs
+++ b/helix-term/src/keymap/default.rs
@@ -367,6 +367,8 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
"v" => normal_mode,
"g" => { "Goto"
+ "g" => extend_to_file_start,
+ "e" => extend_to_last_line,
"k" => extend_line_up,
"j" => extend_line_down,
"w" => extend_to_word,
| diff --git a/book/src/generated/static-cmd.md b/book/src/generated/static-cmd.md
index af7515b8e824..f6a82020f7e1 100644
--- a/book/src/generated/static-cmd.md
+++ b/book/src/generated/static-cmd.md
@@ -126,8 +126,10 @@
| `add_newline_below` | Add newline below | normal: `` ]<space> ``, select: `` ]<space> `` |
| `goto_type_definition` | Goto type definition | normal: `` gy ``, select: `` gy `` |
| `goto_implementation` | Goto implementation | normal: `` gi ``, select: `` gi `` |
-| `goto_file_start` | Goto line number <n> else file start | normal: `` gg ``, select: `` gg `` |
+| `goto_file_start` | Goto line number <n> else file start | normal: `` gg `` |
| `goto_file_end` | Goto file end | |
+| `extend_to_file_start` | Extend to line number<n> else file start | select: `` gg `` |
+| `extend_to_file_end` | Extend to file end | |
| `goto_file` | Goto files/URLs in selections | normal: `` gf ``, select: `` gf `` |
| `goto_file_hsplit` | Goto files in selections (hsplit) | normal: `` <C-w>f ``, `` <space>wf ``, select: `` <C-w>f ``, `` <space>wf `` |
| `goto_file_vsplit` | Goto files in selections (vsplit) | normal: `` <C-w>F ``, `` <space>wF ``, select: `` <C-w>F ``, `` <space>wF `` |
@@ -139,7 +141,8 @@
| `goto_last_modified_file` | Goto last modified file | normal: `` gm ``, select: `` gm `` |
| `goto_last_modification` | Goto last modification | normal: `` g. ``, select: `` g. `` |
| `goto_line` | Goto line | normal: `` G ``, select: `` G `` |
-| `goto_last_line` | Goto last line | normal: `` ge ``, select: `` ge `` |
+| `goto_last_line` | Goto last line | normal: `` ge `` |
+| `extend_to_last_line` | Extend to last line | select: `` ge `` |
| `goto_first_diag` | Goto first diagnostic | normal: `` [D ``, select: `` [D `` |
| `goto_last_diag` | Goto last diagnostic | normal: `` ]D ``, select: `` ]D `` |
| `goto_next_diag` | Goto next diagnostic | normal: `` ]d ``, select: `` ]d `` |
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index a197792eff59..0b2a48607921 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -427,6 +427,8 @@ impl MappableCommand {
goto_implementation, "Goto implementation",
goto_file_start, "Goto line number <n> else file start",
goto_file_end, "Goto file end",
+ extend_to_file_start, "Extend to line number<n> else file start",
+ extend_to_file_end, "Extend to file end",
goto_file, "Goto files/URLs in selections",
goto_file_hsplit, "Goto files in selections (hsplit)",
goto_file_vsplit, "Goto files in selections (vsplit)",
@@ -439,6 +441,7 @@ impl MappableCommand {
goto_last_modification, "Goto last modification",
goto_line, "Goto line",
goto_last_line, "Goto last line",
+ extend_to_last_line, "Extend to last line",
goto_first_diag, "Goto first diagnostic",
goto_last_diag, "Goto last diagnostic",
goto_next_diag, "Goto next diagnostic",
@@ -1254,28 +1257,44 @@ fn goto_next_paragraph(cx: &mut Context) {
fn goto_file_start(cx: &mut Context) {
+ goto_file_start_impl(cx, Movement::Move);
+fn extend_to_file_start(cx: &mut Context) {
+ goto_file_start_impl(cx, Movement::Extend);
- goto_line(cx);
} else {
- .transform(|range| range.put_cursor(text, 0, cx.editor.mode == Mode::Select));
+ .transform(|range| range.put_cursor(text, 0, movement == Movement::Extend));
fn goto_file_end(cx: &mut Context) {
+ goto_file_end_impl(cx, Movement::Move);
+fn extend_to_file_end(cx: &mut Context) {
+ goto_file_end_impl(cx, Movement::Extend)
+fn goto_file_end_impl(cx: &mut Context, movement: Movement) {
let pos = doc.text().len_chars();
@@ -3747,15 +3766,23 @@ fn push_jump(view: &mut View, doc: &Document) {
fn goto_line(cx: &mut Context) {
+ goto_line_impl(cx, Movement::Move);
+fn goto_line_impl(cx: &mut Context, movement: Movement) {
- goto_line_without_jumplist(cx.editor, cx.count);
+ goto_line_without_jumplist(cx.editor, cx.count, movement);
-fn goto_line_without_jumplist(editor: &mut Editor, count: Option<NonZeroUsize>) {
+fn goto_line_without_jumplist(
+ editor: &mut Editor,
+ count: Option<NonZeroUsize>,
+ movement: Movement,
+) {
if let Some(count) = count {
let (view, doc) = current!(editor);
@@ -3770,13 +3797,21 @@ fn goto_line_without_jumplist(editor: &mut Editor, count: Option<NonZeroUsize>)
- .transform(|range| range.put_cursor(text, pos, editor.mode == Mode::Select));
+ .transform(|range| range.put_cursor(text, pos, movement == Movement::Extend));
fn goto_last_line(cx: &mut Context) {
+ goto_last_line_impl(cx, Movement::Move)
+fn extend_to_last_line(cx: &mut Context) {
+ goto_last_line_impl(cx, Movement::Extend)
+fn goto_last_line_impl(cx: &mut Context, movement: Movement) {
let line_idx = if text.line(text.len_lines() - 1).len_chars() == 0 {
@@ -3789,7 +3824,7 @@ fn goto_last_line(cx: &mut Context) {
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 1d57930cc70b..6e2a92ce5e16 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1819,7 +1819,15 @@ fn update_goto_line_number_preview(cx: &mut compositor::Context, args: Args) ->
let scrolloff = cx.editor.config().scrolloff;
let line = args[0].parse::<usize>()?;
+ goto_line_without_jumplist(
+ cx.editor,
+ if cx.editor.mode == Mode::Select {
+ } else {
+ Movement::Move
+ },
+ );
view.ensure_cursor_in_view(doc, scrolloff);
diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs
index e160b2246b1e..b9189eb304ca 100644
--- a/helix-term/src/keymap/default.rs
+++ b/helix-term/src/keymap/default.rs
@@ -367,6 +367,8 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
"v" => normal_mode,
"g" => { "Goto"
+ "g" => extend_to_file_start,
+ "e" => extend_to_last_line,
"k" => extend_line_up,
"j" => extend_line_down,
"w" => extend_to_word, | [
"+fn goto_file_start_impl(cx: &mut Context, movement: Movement) {",
"+ goto_line_impl(cx, movement);",
"- goto_line_without_jumplist(cx.editor, NonZeroUsize::new(line));",
"+ NonZeroUsize::new(line),",
"+ Movement::Extend"
] | [
58,
61,
161,
164,
166
] | {
"additions": 58,
"author": "hadronized",
"deletions": 10,
"html_url": "https://github.com/helix-editor/helix/pull/11767",
"issue_id": 11767,
"merged_at": "2025-04-06T18:18:48Z",
"omission_probability": 0.1,
"pr_number": 11767,
"repo": "helix-editor/helix",
"title": "Add support for extend_file_{start,end}.",
"total_changes": 68
} |
258 | diff --git a/Cargo.lock b/Cargo.lock
index 03c43148ea3d..2087b9a438a8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -145,9 +145,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "cc"
-version = "1.2.17"
+version = "1.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
+checksum = "525046617d8376e3db1deffb079e91cef90a89fc3ca5c185bbf8c9ecdd15cd5c"
dependencies = [
"shlex",
]
@@ -1500,7 +1500,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
- "rustix 1.0.3",
+ "rustix 1.0.5",
"tempfile",
"unicode-segmentation",
"which",
@@ -1607,7 +1607,7 @@ dependencies = [
"log",
"once_cell",
"parking_lot",
- "rustix 1.0.3",
+ "rustix 1.0.5",
"serde",
"serde_json",
"slotmap",
@@ -1823,9 +1823,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.8.0"
+version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
+checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
@@ -2323,9 +2323,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "1.0.3"
+version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
+checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
dependencies = [
"bitflags",
"errno",
@@ -2491,9 +2491,9 @@ dependencies = [
[[package]]
name = "smallvec"
-version = "1.14.0"
+version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
+checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
[[package]]
name = "smartstring"
@@ -2571,7 +2571,7 @@ dependencies = [
"fastrand",
"getrandom 0.3.1",
"once_cell",
- "rustix 1.0.3",
+ "rustix 1.0.5",
"windows-sys 0.59.0",
]
@@ -2671,9 +2671,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.44.1"
+version = "1.44.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
+checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48"
dependencies = [
"backtrace",
"bytes",
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index 10fb5a52cdee..fe9a8c939168 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -21,7 +21,7 @@ helix-loader = { path = "../helix-loader" }
helix-parsec = { path = "../helix-parsec" }
ropey.workspace = true
-smallvec = "1.14"
+smallvec = "1.15"
smartstring = "1.0.1"
unicode-segmentation.workspace = true
# unicode-width is changing width definitions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 9ea2d4589e46..7709d741b940 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -61,7 +61,7 @@ tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
arc-swap = { version = "1.7.1" }
termini = "1"
-indexmap = "2.8"
+indexmap = "2.9"
# Logging
fern = "0.7"
@@ -102,7 +102,7 @@ crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc
helix-loader = { path = "../helix-loader" }
[dev-dependencies]
-smallvec = "1.14"
+smallvec = "1.15"
indoc = "2.0.6"
tempfile.workspace = true
same-file = "1.0.1"
| diff --git a/Cargo.lock b/Cargo.lock
index 03c43148ea3d..2087b9a438a8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -145,9 +145,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
name = "cc"
-version = "1.2.17"
+version = "1.2.18"
"shlex",
@@ -1500,7 +1500,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
"tempfile",
"unicode-segmentation",
"which",
@@ -1607,7 +1607,7 @@ dependencies = [
"log",
"parking_lot",
"serde",
"serde_json",
"slotmap",
@@ -1823,9 +1823,9 @@ dependencies = [
name = "indexmap"
-version = "2.8.0"
+version = "2.9.0"
-checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
+checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
"equivalent",
"hashbrown 0.15.2",
@@ -2323,9 +2323,9 @@ dependencies = [
name = "rustix"
-version = "1.0.3"
+version = "1.0.5"
-checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
+checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
"bitflags",
"errno",
@@ -2491,9 +2491,9 @@ dependencies = [
name = "smallvec"
-version = "1.14.0"
+version = "1.15.0"
-checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
+checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
name = "smartstring"
@@ -2571,7 +2571,7 @@ dependencies = [
"fastrand",
"getrandom 0.3.1",
"windows-sys 0.59.0",
@@ -2671,9 +2671,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
name = "tokio"
-version = "1.44.1"
+version = "1.44.2"
-checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
+checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48"
"backtrace",
"bytes",
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index 10fb5a52cdee..fe9a8c939168 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -21,7 +21,7 @@ helix-loader = { path = "../helix-loader" }
helix-parsec = { path = "../helix-parsec" }
ropey.workspace = true
smartstring = "1.0.1"
unicode-segmentation.workspace = true
# unicode-width is changing width definitions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 9ea2d4589e46..7709d741b940 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -61,7 +61,7 @@ tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
arc-swap = { version = "1.7.1" }
termini = "1"
-indexmap = "2.8"
+indexmap = "2.9"
# Logging
fern = "0.7"
@@ -102,7 +102,7 @@ crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc
helix-loader = { path = "../helix-loader" }
[dev-dependencies]
indoc = "2.0.6"
tempfile.workspace = true
same-file = "1.0.1" | [
"-checksum = \"1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a\"",
"+checksum = \"525046617d8376e3db1deffb079e91cef90a89fc3ca5c185bbf8c9ecdd15cd5c\""
] | [
11,
12
] | {
"additions": 16,
"author": "dependabot[bot]",
"deletions": 16,
"html_url": "https://github.com/helix-editor/helix/pull/13301",
"issue_id": 13301,
"merged_at": "2025-04-08T02:33:46Z",
"omission_probability": 0.1,
"pr_number": 13301,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group across 1 directory with 5 updates",
"total_changes": 32
} |
259 | diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm
index 5e2a576f3519..4be4bb94b1ae 100644
--- a/runtime/queries/ocaml/highlights.scm
+++ b/runtime/queries/ocaml/highlights.scm
@@ -37,6 +37,13 @@
[(constructor_name) (tag)] @constructor
+; Variables
+;----------
+
+[(value_name) (type_variable)] @variable
+
+(value_pattern) @variable.parameter
+
; Functions
;----------
@@ -75,13 +82,6 @@
(application_expression
function: (value_path (value_name) @function))
-; Variables
-;----------
-
-[(value_name) (type_variable)] @variable
-
-(value_pattern) @variable.parameter
-
; Properties
;-----------
| diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm
index 5e2a576f3519..4be4bb94b1ae 100644
--- a/runtime/queries/ocaml/highlights.scm
+++ b/runtime/queries/ocaml/highlights.scm
@@ -37,6 +37,13 @@
[(constructor_name) (tag)] @constructor
+; Variables
+;----------
+[(value_name) (type_variable)] @variable
+(value_pattern) @variable.parameter
; Functions
;----------
@@ -75,13 +82,6 @@
(application_expression
function: (value_path (value_name) @function))
-; Variables
-;----------
-[(value_name) (type_variable)] @variable
-(value_pattern) @variable.parameter
; Properties
;----------- | [] | [] | {
"additions": 7,
"author": "supersurviveur",
"deletions": 7,
"html_url": "https://github.com/helix-editor/helix/pull/13293",
"issue_id": 13293,
"merged_at": "2025-04-08T00:16:31Z",
"omission_probability": 0.1,
"pr_number": 13293,
"repo": "helix-editor/helix",
"title": "fix: Ocaml highlights queries order",
"total_changes": 14
} |
260 | diff --git a/runtime/queries/_typescript/highlights.scm b/runtime/queries/_typescript/highlights.scm
index a5bfd9ed0118..8ce9cb653bb2 100644
--- a/runtime/queries/_typescript/highlights.scm
+++ b/runtime/queries/_typescript/highlights.scm
@@ -64,6 +64,10 @@
(array_pattern
(identifier) @variable.parameter))
+(public_field_definition) @punctuation.special
+(this_type) @variable.builtin
+(type_predicate) @keyword.operator
+
; Punctuation
; -----------
@@ -82,6 +86,7 @@
[
"abstract"
"declare"
+ "module"
"export"
"infer"
"implements"
@@ -127,9 +132,16 @@
">"
] @punctuation.bracket)
+(omitting_type_annotation) @punctuation.special
+(opting_type_annotation) @punctuation.special
+
; Literals
; --------
[
(template_literal_type)
] @string
+
+(import_require_clause
+ (identifier) "="
+ ("require") @keyword)
diff --git a/runtime/queries/ecma/highlights.scm b/runtime/queries/ecma/highlights.scm
index d56bbe14a2e1..fcc47ce11180 100644
--- a/runtime/queries/ecma/highlights.scm
+++ b/runtime/queries/ecma/highlights.scm
@@ -74,16 +74,12 @@
[
"async"
"debugger"
- "delete"
"extends"
"from"
"get"
"new"
"set"
"target"
- "typeof"
- "instanceof"
- "void"
"with"
] @keyword
@@ -91,6 +87,10 @@
"of"
"as"
"in"
+ "delete"
+ "typeof"
+ "instanceof"
+ "void"
] @keyword.operator
[
| diff --git a/runtime/queries/_typescript/highlights.scm b/runtime/queries/_typescript/highlights.scm
index a5bfd9ed0118..8ce9cb653bb2 100644
--- a/runtime/queries/_typescript/highlights.scm
+++ b/runtime/queries/_typescript/highlights.scm
@@ -64,6 +64,10 @@
(array_pattern
(identifier) @variable.parameter))
+(public_field_definition) @punctuation.special
+(type_predicate) @keyword.operator
; Punctuation
; -----------
@@ -82,6 +86,7 @@
"abstract"
"declare"
+ "module"
"export"
"infer"
"implements"
@@ -127,9 +132,16 @@
">"
] @punctuation.bracket)
+(omitting_type_annotation) @punctuation.special
+(opting_type_annotation) @punctuation.special
; Literals
; --------
(template_literal_type)
] @string
+(import_require_clause
+ (identifier) "="
+ ("require") @keyword)
diff --git a/runtime/queries/ecma/highlights.scm b/runtime/queries/ecma/highlights.scm
index d56bbe14a2e1..fcc47ce11180 100644
--- a/runtime/queries/ecma/highlights.scm
+++ b/runtime/queries/ecma/highlights.scm
@@ -74,16 +74,12 @@
"async"
"debugger"
- "delete"
"extends"
"from"
"get"
"new"
"set"
"target"
- "typeof"
- "instanceof"
"with"
] @keyword
@@ -91,6 +87,10 @@
"of"
"as"
"in"
+ "delete"
+ "typeof"
+ "instanceof"
+ "void"
] @keyword.operator | [
"+(this_type) @variable.builtin",
"- \"void\""
] | [
9,
57
] | {
"additions": 16,
"author": "Nikita0x",
"deletions": 4,
"html_url": "https://github.com/helix-editor/helix/pull/13250",
"issue_id": 13250,
"merged_at": "2025-04-07T15:00:03Z",
"omission_probability": 0.1,
"pr_number": 13250,
"repo": "helix-editor/helix",
"title": "Added: missing highlighting to `queries/_typescript`",
"total_changes": 20
} |
261 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index f6aee3fe3410..1d9fd5888cd7 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -36,6 +36,7 @@
| d | β | β | β | `serve-d` |
| dart | β | β | β | `dart` |
| dbml | β | | | |
+| debian | β | | | |
| devicetree | β | | | |
| dhall | β | β | | `dhall-lsp-server` |
| diff | β | | | |
diff --git a/languages.toml b/languages.toml
index cf6471deaae3..c5256121b9a6 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4255,3 +4255,18 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "werk"
source = { git = "https://github.com/little-bonsai/tree-sitter-werk", rev = "92b0f7fe98465c4c435794a58e961306193d1c1e" }
+
+[[language]]
+name = "debian"
+scope = "text.debian"
+file-types = [
+ "dsc",
+ "changes",
+ { glob = "debian/**/control" },
+ { glob = "etc/apt/sources.list.d/*.sources"}
+]
+comment-tokens = "#"
+
+[[grammar]]
+name = "debian"
+source = { git = "https://gitlab.com/MggMuggins/tree-sitter-debian", rev = "9b3f4b78c45aab8a2f25a5f9e7bbc00995bc3dde" }
diff --git a/runtime/queries/debian/highlights.scm b/runtime/queries/debian/highlights.scm
new file mode 100644
index 000000000000..d62f0278c85a
--- /dev/null
+++ b/runtime/queries/debian/highlights.scm
@@ -0,0 +1,2 @@
+(comment) @comment
+(field_name) @tag
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index f6aee3fe3410..1d9fd5888cd7 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -36,6 +36,7 @@
| d | β | β | β | `serve-d` |
| dart | β | β | β | `dart` |
| dbml | β | | | |
+| debian | β | | | |
| devicetree | β | | | |
| dhall | β | β | | `dhall-lsp-server` |
| diff | β | | | |
diff --git a/languages.toml b/languages.toml
index cf6471deaae3..c5256121b9a6 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4255,3 +4255,18 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "werk"
source = { git = "https://github.com/little-bonsai/tree-sitter-werk", rev = "92b0f7fe98465c4c435794a58e961306193d1c1e" }
+file-types = [
+ "dsc",
+ "changes",
+ { glob = "debian/**/control" },
+ { glob = "etc/apt/sources.list.d/*.sources"}
+]
+[[grammar]]
diff --git a/runtime/queries/debian/highlights.scm b/runtime/queries/debian/highlights.scm
new file mode 100644
index 000000000000..d62f0278c85a
--- /dev/null
+++ b/runtime/queries/debian/highlights.scm
@@ -0,0 +1,2 @@
+(comment) @comment
+(field_name) @tag | [
"+[[language]]",
"+scope = \"text.debian\"",
"+comment-tokens = \"#\"",
"+source = { git = \"https://gitlab.com/MggMuggins/tree-sitter-debian\", rev = \"9b3f4b78c45aab8a2f25a5f9e7bbc00995bc3dde\" }"
] | [
21,
23,
30,
34
] | {
"additions": 18,
"author": "MggMuggins",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13245",
"issue_id": 13245,
"merged_at": "2025-04-06T17:05:44Z",
"omission_probability": 0.1,
"pr_number": 13245,
"repo": "helix-editor/helix",
"title": "Debian control file syntax highlighting",
"total_changes": 18
} |
262 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index fd621c943bd7..aa9fe9db0262 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -175,7 +175,7 @@
| ponylang | β | β | β | |
| powershell | β | | | |
| prisma | β | β | | `prisma-language-server` |
-| prolog | | | | `swipl` |
+| prolog | β | | β | `swipl` |
| protobuf | β | β | β | `buf`, `pb`, `protols` |
| prql | β | | | |
| purescript | β | β | | `purescript-language-server` |
diff --git a/languages.toml b/languages.toml
index a0f59717c3c0..594498f02bcd 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1500,6 +1500,10 @@ comment-token = "%"
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [ "swipl" ]
+[[grammar]]
+name = "prolog"
+source = { git = "https://codeberg.org/foxy/tree-sitter-prolog", subpath = "grammars/prolog", rev = "d8d415f6a1cf80ca138524bcc395810b176d40fa" }
+
[[language]]
name = "tsq"
scope = "source.tsq"
diff --git a/runtime/queries/prolog/folds.scm b/runtime/queries/prolog/folds.scm
new file mode 100644
index 000000000000..70a401511957
--- /dev/null
+++ b/runtime/queries/prolog/folds.scm
@@ -0,0 +1,6 @@
+[
+ (directive_term)
+ (clause_term)
+ (arg_list)
+ (list_notation)
+] @fold
diff --git a/runtime/queries/prolog/highlights.scm b/runtime/queries/prolog/highlights.scm
new file mode 100644
index 000000000000..e496a88a2b85
--- /dev/null
+++ b/runtime/queries/prolog/highlights.scm
@@ -0,0 +1,43 @@
+(comment) @comment
+
+(atom) @constant
+
+((atom) @constant.builtin.boolean
+ (#any-of? @constant.builtin.boolean "true" "false"))
+
+(functional_notation
+ function: (atom) @function)
+
+(integer) @constant.numeric.integer
+
+(float_number) @constant.numeric.float
+
+(directive_head) @operator
+
+(operator_notation
+ operator: _ @operator)
+
+[
+ (open)
+ (open_ct)
+ (close)
+ (open_list)
+ "|"
+ (close_list)
+ (open_curly)
+ (close_curly)
+] @punctuation.bracket
+
+[
+ (arg_list_separator)
+ (comma)
+ (end)
+ (list_notation_separator)
+] @punctuation.delimiter
+
+(operator_notation
+ operator: (semicolon) @punctuation.delimiter)
+
+(double_quoted_list_notation) @string
+
+(variable_term) @variable
diff --git a/runtime/queries/prolog/indents.scm b/runtime/queries/prolog/indents.scm
new file mode 100644
index 000000000000..335d06bbb5e5
--- /dev/null
+++ b/runtime/queries/prolog/indents.scm
@@ -0,0 +1,12 @@
+(functional_notation
+ (atom)
+ (open_ct) @indent
+ (close) @outdent)
+
+(list_notation
+ (open_list) @indent
+ (close_list) @outdent)
+
+(curly_bracketed_notation
+ (open_curly) @indent
+ (close_curly) @outdent)
diff --git a/runtime/queries/prolog/injections.scm b/runtime/queries/prolog/injections.scm
new file mode 100644
index 000000000000..2f0e58eb6431
--- /dev/null
+++ b/runtime/queries/prolog/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index fd621c943bd7..aa9fe9db0262 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -175,7 +175,7 @@
| ponylang | β | β | β | |
| powershell | β | | | |
| prisma | β | β | | `prisma-language-server` |
-| prolog | | | | `swipl` |
+| prolog | β | | β | `swipl` |
| protobuf | β | β | β | `buf`, `pb`, `protols` |
| prql | β | | | |
| purescript | β | β | | `purescript-language-server` |
diff --git a/languages.toml b/languages.toml
index a0f59717c3c0..594498f02bcd 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1500,6 +1500,10 @@ comment-token = "%"
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [ "swipl" ]
+[[grammar]]
+name = "prolog"
+source = { git = "https://codeberg.org/foxy/tree-sitter-prolog", subpath = "grammars/prolog", rev = "d8d415f6a1cf80ca138524bcc395810b176d40fa" }
[[language]]
name = "tsq"
scope = "source.tsq"
diff --git a/runtime/queries/prolog/folds.scm b/runtime/queries/prolog/folds.scm
index 000000000000..70a401511957
+++ b/runtime/queries/prolog/folds.scm
@@ -0,0 +1,6 @@
+ (directive_term)
+ (arg_list)
+ (list_notation)
+] @fold
diff --git a/runtime/queries/prolog/highlights.scm b/runtime/queries/prolog/highlights.scm
index 000000000000..e496a88a2b85
+++ b/runtime/queries/prolog/highlights.scm
@@ -0,0 +1,43 @@
+(comment) @comment
+((atom) @constant.builtin.boolean
+ (#any-of? @constant.builtin.boolean "true" "false"))
+ function: (atom) @function)
+(integer) @constant.numeric.integer
+(float_number) @constant.numeric.float
+(directive_head) @operator
+ (open)
+ (open_ct)
+ "|"
+ (close_list)
+ (open_curly)
+] @punctuation.bracket
+ (arg_list_separator)
+ (comma)
+ (end)
+ (list_notation_separator)
+] @punctuation.delimiter
+ operator: (semicolon) @punctuation.delimiter)
+(double_quoted_list_notation) @string
+(variable_term) @variable
diff --git a/runtime/queries/prolog/indents.scm b/runtime/queries/prolog/indents.scm
index 000000000000..335d06bbb5e5
+++ b/runtime/queries/prolog/indents.scm
@@ -0,0 +1,12 @@
+ (atom)
+ (close) @outdent)
+(list_notation
+ (open_list) @indent
+ (close_list) @outdent)
+(curly_bracketed_notation
+ (open_curly) @indent
+ (close_curly) @outdent)
diff --git a/runtime/queries/prolog/injections.scm b/runtime/queries/prolog/injections.scm
index 000000000000..2f0e58eb6431
+++ b/runtime/queries/prolog/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment")) | [
"+ (clause_term)",
"+(atom) @constant",
"+ operator: _ @operator)",
"+ (close)",
"+ (open_list)",
"+ (close_curly)",
"+ (open_ct) @indent"
] | [
36,
48,
63,
68,
69,
73,
97
] | {
"additions": 68,
"author": "mkorje",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/11611",
"issue_id": 11611,
"merged_at": "2025-04-06T16:43:53Z",
"omission_probability": 0.1,
"pr_number": 11611,
"repo": "helix-editor/helix",
"title": "Add Prolog tree-sitter grammar",
"total_changes": 69
} |
263 | diff --git a/helix-loader/src/config.rs b/helix-loader/src/config.rs
index d092d20f73a8..1f414de67f99 100644
--- a/helix-loader/src/config.rs
+++ b/helix-loader/src/config.rs
@@ -23,22 +23,6 @@ pub fn user_lang_config() -> Result<toml::Value, toml::de::Error> {
.collect::<Result<Vec<_>, _>>()?
.into_iter()
.fold(default_lang_config(), |a, b| {
- // combines for example
- // b:
- // [[language]]
- // name = "toml"
- // language-server = { command = "taplo", args = ["lsp", "stdio"] }
- //
- // a:
- // [[language]]
- // language-server = { command = "/usr/bin/taplo" }
- //
- // into:
- // [[language]]
- // name = "toml"
- // language-server = { command = "/usr/bin/taplo" }
- //
- // thus it overrides the third depth-level of b with values of a if they exist, but otherwise merges their values
crate::merge_toml_values(a, b, 3)
});
diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs
index ae9ffe550a15..54980dd7d058 100644
--- a/helix-loader/src/lib.rs
+++ b/helix-loader/src/lib.rs
@@ -154,17 +154,36 @@ pub fn default_log_file() -> PathBuf {
/// Merge two TOML documents, merging values from `right` onto `left`
///
-/// When an array exists in both `left` and `right`, `right`'s array is
-/// used. When a table exists in both `left` and `right`, the merged table
-/// consists of all keys in `left`'s table unioned with all keys in `right`
-/// with the values of `right` being merged recursively onto values of
-/// `left`.
+/// `merge_depth` sets the nesting depth up to which values are merged instead
+/// of overridden.
///
-/// `merge_toplevel_arrays` controls whether a top-level array in the TOML
-/// document is merged instead of overridden. This is useful for TOML
-/// documents that use a top-level array of values like the `languages.toml`,
-/// where one usually wants to override or add to the array instead of
-/// replacing it altogether.
+/// When a table exists in both `left` and `right`, the merged table consists of
+/// all keys in `left`'s table unioned with all keys in `right` with the values
+/// of `right` being merged recursively onto values of `left`.
+///
+/// `crate::merge_toml_values(a, b, 3)` combines, for example:
+///
+/// b:
+/// ```toml
+/// [[language]]
+/// name = "toml"
+/// language-server = { command = "taplo", args = ["lsp", "stdio"] }
+/// ```
+/// a:
+/// ```toml
+/// [[language]]
+/// language-server = { command = "/usr/bin/taplo" }
+/// ```
+///
+/// into:
+/// ```toml
+/// [[language]]
+/// name = "toml"
+/// language-server = { command = "/usr/bin/taplo" }
+/// ```
+///
+/// thus it overrides the third depth-level of b with values of a if they exist,
+/// but otherwise merges their values
pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usize) -> toml::Value {
use toml::Value;
@@ -174,11 +193,6 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
match (left, right) {
(Value::Array(mut left_items), Value::Array(right_items)) => {
- // The top-level arrays should be merged but nested arrays should
- // act as overrides. For the `languages.toml` config, this means
- // that you can specify a sub-set of languages in an overriding
- // `languages.toml` but that nested arrays like Language Server
- // arguments are replaced instead of merged.
if merge_depth > 0 {
left_items.reserve(right_items.len());
for rvalue in right_items {
| diff --git a/helix-loader/src/config.rs b/helix-loader/src/config.rs
index d092d20f73a8..1f414de67f99 100644
--- a/helix-loader/src/config.rs
+++ b/helix-loader/src/config.rs
@@ -23,22 +23,6 @@ pub fn user_lang_config() -> Result<toml::Value, toml::de::Error> {
.collect::<Result<Vec<_>, _>>()?
.into_iter()
.fold(default_lang_config(), |a, b| {
- // combines for example
- // b:
- // language-server = { command = "taplo", args = ["lsp", "stdio"] }
- // a:
- // into:
- // thus it overrides the third depth-level of b with values of a if they exist, but otherwise merges their values
crate::merge_toml_values(a, b, 3)
});
diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs
index ae9ffe550a15..54980dd7d058 100644
--- a/helix-loader/src/lib.rs
+++ b/helix-loader/src/lib.rs
@@ -154,17 +154,36 @@ pub fn default_log_file() -> PathBuf {
/// Merge two TOML documents, merging values from `right` onto `left`
-/// When an array exists in both `left` and `right`, `right`'s array is
-/// used. When a table exists in both `left` and `right`, the merged table
-/// consists of all keys in `left`'s table unioned with all keys in `right`
-/// with the values of `right` being merged recursively onto values of
+/// `merge_depth` sets the nesting depth up to which values are merged instead
+/// of overridden.
-/// `merge_toplevel_arrays` controls whether a top-level array in the TOML
-/// documents that use a top-level array of values like the `languages.toml`,
-/// where one usually wants to override or add to the array instead of
-/// replacing it altogether.
+/// When a table exists in both `left` and `right`, the merged table consists of
+/// of `right` being merged recursively onto values of `left`.
+/// `crate::merge_toml_values(a, b, 3)` combines, for example:
+/// b:
+/// language-server = { command = "taplo", args = ["lsp", "stdio"] }
+/// a:
+/// into:
+/// thus it overrides the third depth-level of b with values of a if they exist,
+/// but otherwise merges their values
pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usize) -> toml::Value {
use toml::Value;
@@ -174,11 +193,6 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
match (left, right) {
(Value::Array(mut left_items), Value::Array(right_items)) => {
- // act as overrides. For the `languages.toml` config, this means
- // that you can specify a sub-set of languages in an overriding
- // `languages.toml` but that nested arrays like Language Server
- // arguments are replaced instead of merged.
if merge_depth > 0 {
left_items.reserve(right_items.len());
for rvalue in right_items { | [
"-/// `left`.",
"-/// document is merged instead of overridden. This is useful for TOML",
"+/// all keys in `left`'s table unioned with all keys in `right` with the values",
"- // The top-level arrays should be merged but nested arrays should"
] | [
39,
44,
49,
82
] | {
"additions": 29,
"author": "Carrotstrip",
"deletions": 31,
"html_url": "https://github.com/helix-editor/helix/pull/13253",
"issue_id": 13253,
"merged_at": "2025-04-06T18:00:18Z",
"omission_probability": 0.1,
"pr_number": 13253,
"repo": "helix-editor/helix",
"title": "Fix out of date comments on merge_toml_values",
"total_changes": 60
} |
264 | diff --git a/runtime/themes/catppuccin_mocha.toml b/runtime/themes/catppuccin_mocha.toml
index 8cb17f64d78e..5e542dc8f55f 100644
--- a/runtime/themes/catppuccin_mocha.toml
+++ b/runtime/themes/catppuccin_mocha.toml
@@ -43,21 +43,22 @@
"special" = "blue" # fuzzy highlight
-"markup.heading.marker" = { fg = "peach", modifiers = ["bold"] }
-"markup.heading.1" = "lavender"
-"markup.heading.2" = "mauve"
-"markup.heading.3" = "green"
-"markup.heading.4" = "yellow"
-"markup.heading.5" = "pink"
-"markup.heading.6" = "teal"
-"markup.list" = "mauve"
+"markup.heading.1" = "red"
+"markup.heading.2" = "peach"
+"markup.heading.3" = "yellow"
+"markup.heading.4" = "green"
+"markup.heading.5" = "sapphire"
+"markup.heading.6" = "lavender"
+"markup.list" = "teal"
"markup.list.unchecked" = "overlay2"
"markup.list.checked" = "green"
-"markup.bold" = { modifiers = ["bold"] }
-"markup.italic" = { modifiers = ["italic"] }
+"markup.bold" = { fg = "red", modifiers = ["bold"] }
+"markup.italic" = { fg = "red", modifiers = ["italic"] }
"markup.link.url" = { fg = "blue", modifiers = ["italic", "underlined"] }
-"markup.link.text" = "blue"
-"markup.raw" = "flamingo"
+"markup.link.text" = "lavender"
+"markup.link.label" = "sapphire"
+"markup.raw" = "green"
+"markup.quote" = "pink"
"diff.plus" = "green"
"diff.minus" = "red"
@@ -72,9 +73,9 @@
"ui.statusline" = { fg = "subtext1", bg = "mantle" }
"ui.statusline.inactive" = { fg = "surface2", bg = "mantle" }
-"ui.statusline.normal" = { fg = "base", bg = "lavender", modifiers = ["bold"] }
-"ui.statusline.insert" = { fg = "base", bg = "green", modifiers = ["bold"] }
-"ui.statusline.select" = { fg = "base", bg = "flamingo", modifiers = ["bold"] }
+"ui.statusline.normal" = { fg = "base", bg = "rosewater", modifiers = ["bold"] }
+"ui.statusline.insert" = { fg = "base", bg = "green", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "base", bg = "lavender", modifiers = ["bold"] }
"ui.popup" = { fg = "text", bg = "surface0" }
"ui.window" = { fg = "crust" }
@@ -101,13 +102,13 @@
"ui.cursor.primary" = { fg = "base", bg = "rosewater" }
"ui.cursor.match" = { fg = "peach", modifiers = ["bold"] }
-"ui.cursor.primary.normal" = { fg = "base", bg = "lavender" }
+"ui.cursor.primary.normal" = { fg = "base", bg = "rosewater" }
"ui.cursor.primary.insert" = { fg = "base", bg = "green" }
-"ui.cursor.primary.select" = { fg = "base", bg = "flamingo" }
+"ui.cursor.primary.select" = { fg = "base", bg = "lavender" }
"ui.cursor.normal" = { fg = "base", bg = "secondary_cursor_normal" }
"ui.cursor.insert" = { fg = "base", bg = "secondary_cursor_insert" }
-"ui.cursor.select" = { fg = "base", bg = "secondary_cursor" }
+"ui.cursor.select" = { fg = "base", bg = "secondary_cursor_select" }
"ui.cursorline.primary" = { bg = "cursorline" }
@@ -116,11 +117,11 @@
"ui.menu" = { fg = "overlay2", bg = "surface0" }
"ui.menu.selected" = { fg = "text", bg = "surface1", modifiers = ["bold"] }
-"diagnostic.unnecessary" = { modifiers = ["dim"] }
"diagnostic.error" = { underline = { color = "red", style = "curl" } }
"diagnostic.warning" = { underline = { color = "yellow", style = "curl" } }
"diagnostic.info" = { underline = { color = "sky", style = "curl" } }
"diagnostic.hint" = { underline = { color = "teal", style = "curl" } }
+"diagnostic.unnecessary" = { modifiers = ["dim"] }
error = "red"
warning = "yellow"
@@ -157,5 +158,6 @@ crust = "#11111b"
cursorline = "#2a2b3c"
secondary_cursor = "#b5a6a8"
-secondary_cursor_normal = "#878ec0"
+secondary_cursor_select = "#878ec0"
+secondary_cursor_normal = "#b5a6a8"
secondary_cursor_insert = "#7ea87f"
| diff --git a/runtime/themes/catppuccin_mocha.toml b/runtime/themes/catppuccin_mocha.toml
index 8cb17f64d78e..5e542dc8f55f 100644
--- a/runtime/themes/catppuccin_mocha.toml
+++ b/runtime/themes/catppuccin_mocha.toml
@@ -43,21 +43,22 @@
"special" = "blue" # fuzzy highlight
-"markup.heading.marker" = { fg = "peach", modifiers = ["bold"] }
-"markup.heading.1" = "lavender"
-"markup.heading.2" = "mauve"
-"markup.heading.3" = "green"
-"markup.heading.4" = "yellow"
-"markup.heading.5" = "pink"
-"markup.heading.6" = "teal"
-"markup.list" = "mauve"
+"markup.heading.1" = "red"
+"markup.heading.2" = "peach"
+"markup.heading.3" = "yellow"
+"markup.heading.4" = "green"
+"markup.heading.5" = "sapphire"
+"markup.heading.6" = "lavender"
+"markup.list" = "teal"
"markup.list.unchecked" = "overlay2"
"markup.list.checked" = "green"
-"markup.bold" = { modifiers = ["bold"] }
-"markup.italic" = { modifiers = ["italic"] }
+"markup.bold" = { fg = "red", modifiers = ["bold"] }
"markup.link.url" = { fg = "blue", modifiers = ["italic", "underlined"] }
-"markup.link.text" = "blue"
-"markup.raw" = "flamingo"
+"markup.link.text" = "lavender"
+"markup.link.label" = "sapphire"
+"markup.raw" = "green"
+"markup.quote" = "pink"
"diff.plus" = "green"
"diff.minus" = "red"
@@ -72,9 +73,9 @@
"ui.statusline" = { fg = "subtext1", bg = "mantle" }
"ui.statusline.inactive" = { fg = "surface2", bg = "mantle" }
-"ui.statusline.normal" = { fg = "base", bg = "lavender", modifiers = ["bold"] }
-"ui.statusline.insert" = { fg = "base", bg = "green", modifiers = ["bold"] }
-"ui.statusline.select" = { fg = "base", bg = "flamingo", modifiers = ["bold"] }
+"ui.statusline.normal" = { fg = "base", bg = "rosewater", modifiers = ["bold"] }
+"ui.statusline.insert" = { fg = "base", bg = "green", modifiers = ["bold"] }
"ui.popup" = { fg = "text", bg = "surface0" }
"ui.window" = { fg = "crust" }
@@ -101,13 +102,13 @@
"ui.cursor.primary" = { fg = "base", bg = "rosewater" }
"ui.cursor.match" = { fg = "peach", modifiers = ["bold"] }
-"ui.cursor.primary.normal" = { fg = "base", bg = "lavender" }
"ui.cursor.primary.insert" = { fg = "base", bg = "green" }
-"ui.cursor.primary.select" = { fg = "base", bg = "flamingo" }
+"ui.cursor.primary.select" = { fg = "base", bg = "lavender" }
"ui.cursor.normal" = { fg = "base", bg = "secondary_cursor_normal" }
"ui.cursor.insert" = { fg = "base", bg = "secondary_cursor_insert" }
-"ui.cursor.select" = { fg = "base", bg = "secondary_cursor" }
+"ui.cursor.select" = { fg = "base", bg = "secondary_cursor_select" }
"ui.cursorline.primary" = { bg = "cursorline" }
@@ -116,11 +117,11 @@
"ui.menu" = { fg = "overlay2", bg = "surface0" }
"ui.menu.selected" = { fg = "text", bg = "surface1", modifiers = ["bold"] }
-"diagnostic.unnecessary" = { modifiers = ["dim"] }
"diagnostic.error" = { underline = { color = "red", style = "curl" } }
"diagnostic.warning" = { underline = { color = "yellow", style = "curl" } }
"diagnostic.info" = { underline = { color = "sky", style = "curl" } }
"diagnostic.hint" = { underline = { color = "teal", style = "curl" } }
+"diagnostic.unnecessary" = { modifiers = ["dim"] }
error = "red"
warning = "yellow"
@@ -157,5 +158,6 @@ crust = "#11111b"
cursorline = "#2a2b3c"
secondary_cursor = "#b5a6a8"
-secondary_cursor_normal = "#878ec0"
+secondary_cursor_select = "#878ec0"
+secondary_cursor_normal = "#b5a6a8"
secondary_cursor_insert = "#7ea87f" | [
"+\"markup.italic\" = { fg = \"red\", modifiers = [\"italic\"] }",
"+\"ui.statusline.select\" = { fg = \"base\", bg = \"lavender\", modifiers = [\"bold\"] }",
"+\"ui.cursor.primary.normal\" = { fg = \"base\", bg = \"rosewater\" }"
] | [
28,
48,
57
] | {
"additions": 22,
"author": "nik-rev",
"deletions": 20,
"html_url": "https://github.com/helix-editor/helix/pull/13262",
"issue_id": 13262,
"merged_at": "2025-04-06T17:06:21Z",
"omission_probability": 0.1,
"pr_number": 13262,
"repo": "helix-editor/helix",
"title": "feat: sync catppuccin theme changes",
"total_changes": 42
} |
265 | diff --git a/runtime/themes/peachpuff.toml b/runtime/themes/peachpuff.toml
new file mode 100644
index 000000000000..c38aee181bbe
--- /dev/null
+++ b/runtime/themes/peachpuff.toml
@@ -0,0 +1,65 @@
+# Author : geonove <[email protected]>
+# License : Vim License
+
+"ui.menu" = { fg = "light-gray", bg = "gray" }
+"ui.menu.selected" = { modifiers = ["reversed"] }
+"ui.linenr" = "yellow"
+"ui.popup" = { bg = "black" }
+"ui.window" = { bg = "black" }
+"ui.linenr.selected" = "light-yellow"
+"ui.selection" = { fg = "gray", modifiers = ["reversed"] }
+"ui.text.focus" = { fg = "black", bg = "white" }
+"comment" = "light-green"
+"comment.line" = "light-green"
+"comment.block" = "red"
+"comment.block.documentation" = "red"
+"ui.statusline" = { fg = "black", bg = "light-cyan" }
+"ui.statusline.inactive" = { fg = "gray", bg = "black" }
+"ui.help" = { fg = "white", bg = "black" }
+"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
+"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
+"ui.virtual.whitespace" = "light-gray"
+"ui.virtual.jump-label" = { fg = "blue", modifiers = ["bold", "underlined"] }
+"ui.virtual.ruler" = { bg = "black" }
+"variable" = "white"
+"constant.numeric" = "red"
+"constant" = "white"
+"constant.builtin" = "red"
+"attribute" = "yellow"
+"type" = "green"
+"type.builtin" = "cyan"
+"ui.cursor.match" = { fg = "light-gray", modifiers = ["reversed"] }
+"string" = "red"
+"variable.other.member" = "white"
+"constant.character.escape" = "light-cyan"
+#"function.builtin" = "cyan"
+#"function.method" = "cyan"
+#"function.method.private" = "cyan"
+"function" = "cyan"
+"constructor" = "cyan"
+"special" = "light-blue"
+"keyword" = "yellow"
+"keyword.control.import" = "magenta"
+"label" = "white"
+"namespace" = "white"
+
+"markup.heading" = "light-magenta"
+"markup.list" = "light-red"
+"markup.bold" = { fg = "light-yellow", modifiers = ["bold"] }
+"markup.italic" = { fg = "light-magenta", modifiers = ["italic"] }
+"markup.strikethrough" = { modifiers = ["crossed_out"] }
+"markup.link.url" = { fg = "yellow", modifiers = ["underlined"] }
+"markup.link.text" = "light-red"
+"markup.quote" = "light-cyan"
+"markup.raw" = "light-green"
+
+"diff.plus" = "light-green"
+"diff.delta" = "yellow"
+"diff.minus" = "light-red"
+
+"diagnostic" = { modifiers = ["underlined"] }
+"info" = "light-blue"
+"hint" = "gray"
+"debug" = "gray"
+"warning" = "yellow"
+"error" = "light-red"
| diff --git a/runtime/themes/peachpuff.toml b/runtime/themes/peachpuff.toml
new file mode 100644
index 000000000000..c38aee181bbe
--- /dev/null
+++ b/runtime/themes/peachpuff.toml
@@ -0,0 +1,65 @@
+# Author : geonove <[email protected]>
+# License : Vim License
+"ui.menu" = { fg = "light-gray", bg = "gray" }
+"ui.menu.selected" = { modifiers = ["reversed"] }
+"ui.linenr" = "yellow"
+"ui.window" = { bg = "black" }
+"ui.linenr.selected" = "light-yellow"
+"ui.selection" = { fg = "gray", modifiers = ["reversed"] }
+"ui.text.focus" = { fg = "black", bg = "white" }
+"comment" = "light-green"
+"comment.line" = "light-green"
+"comment.block" = "red"
+"ui.statusline" = { fg = "black", bg = "light-cyan" }
+"ui.statusline.inactive" = { fg = "gray", bg = "black" }
+"ui.help" = { fg = "white", bg = "black" }
+"ui.cursor" = { fg = "light-gray", modifiers = ["reversed"] }
+"ui.cursor.primary" = { fg = "light-gray", modifiers = ["reversed"] }
+"ui.virtual.whitespace" = "light-gray"
+"ui.virtual.jump-label" = { fg = "blue", modifiers = ["bold", "underlined"] }
+"ui.virtual.ruler" = { bg = "black" }
+"variable" = "white"
+"constant.numeric" = "red"
+"constant" = "white"
+"constant.builtin" = "red"
+"attribute" = "yellow"
+"type" = "green"
+"ui.cursor.match" = { fg = "light-gray", modifiers = ["reversed"] }
+"string" = "red"
+"variable.other.member" = "white"
+"constant.character.escape" = "light-cyan"
+#"function.builtin" = "cyan"
+#"function.method" = "cyan"
+#"function.method.private" = "cyan"
+"function" = "cyan"
+"constructor" = "cyan"
+"special" = "light-blue"
+"keyword.control.import" = "magenta"
+"label" = "white"
+"namespace" = "white"
+"markup.heading" = "light-magenta"
+"markup.list" = "light-red"
+"markup.bold" = { fg = "light-yellow", modifiers = ["bold"] }
+"markup.strikethrough" = { modifiers = ["crossed_out"] }
+"markup.link.url" = { fg = "yellow", modifiers = ["underlined"] }
+"markup.link.text" = "light-red"
+"markup.quote" = "light-cyan"
+"markup.raw" = "light-green"
+"diff.plus" = "light-green"
+"diff.delta" = "yellow"
+"diagnostic" = { modifiers = ["underlined"] }
+"info" = "light-blue"
+"hint" = "gray"
+"debug" = "gray"
+"warning" = "yellow"
+"error" = "light-red" | [
"+\"ui.popup\" = { bg = \"black\" }",
"+\"comment.block.documentation\" = \"red\"",
"+\"type.builtin\" = \"cyan\"",
"+\"keyword\" = \"yellow\"",
"+\"markup.italic\" = { fg = \"light-magenta\", modifiers = [\"italic\"] }",
"+\"diff.minus\" = \"light-red\""
] | [
12,
20,
35,
46,
54,
63
] | {
"additions": 65,
"author": "geonove",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13225",
"issue_id": 13225,
"merged_at": "2025-03-29T19:44:55Z",
"omission_probability": 0.1,
"pr_number": 13225,
"repo": "helix-editor/helix",
"title": "Add peachpuff theme",
"total_changes": 65
} |
266 | diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index ba41cbc5aa3c..1a2557de2923 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -733,14 +733,17 @@ impl Registry {
#[derive(Debug)]
pub enum ProgressStatus {
Created,
- Started(lsp::WorkDoneProgress),
+ Started {
+ title: String,
+ progress: lsp::WorkDoneProgress,
+ },
}
impl ProgressStatus {
pub fn progress(&self) -> Option<&lsp::WorkDoneProgress> {
match &self {
ProgressStatus::Created => None,
- ProgressStatus::Started(progress) => Some(progress),
+ ProgressStatus::Started { title: _, progress } => Some(progress),
}
}
}
@@ -777,6 +780,13 @@ impl LspProgressMap {
self.0.get(&id).and_then(|values| values.get(token))
}
+ pub fn title(&self, id: LanguageServerId, token: &lsp::ProgressToken) -> Option<&String> {
+ self.progress(id, token).and_then(|p| match p {
+ ProgressStatus::Created => None,
+ ProgressStatus::Started { title, .. } => Some(title),
+ })
+ }
+
/// Checks if progress `token` for server with `id` is created.
pub fn is_created(&mut self, id: LanguageServerId, token: &lsp::ProgressToken) -> bool {
self.0
@@ -801,17 +811,39 @@ impl LspProgressMap {
self.0.get_mut(&id).and_then(|vals| vals.remove(token))
}
- /// Updates the progress of `token` for server with `id` to `status`, returns the value replaced or `None`.
+ /// Updates the progress of `token` for server with `id` to begin state `status`
+ pub fn begin(
+ &mut self,
+ id: LanguageServerId,
+ token: lsp::ProgressToken,
+ status: lsp::WorkDoneProgressBegin,
+ ) {
+ self.0.entry(id).or_default().insert(
+ token,
+ ProgressStatus::Started {
+ title: status.title.clone(),
+ progress: lsp::WorkDoneProgress::Begin(status),
+ },
+ );
+ }
+
+ /// Updates the progress of `token` for server with `id` to report state `status`.
pub fn update(
&mut self,
id: LanguageServerId,
token: lsp::ProgressToken,
- status: lsp::WorkDoneProgress,
- ) -> Option<ProgressStatus> {
+ status: lsp::WorkDoneProgressReport,
+ ) {
self.0
.entry(id)
.or_default()
- .insert(token, ProgressStatus::Started(status))
+ .entry(token)
+ .and_modify(|e| match e {
+ ProgressStatus::Created => (),
+ ProgressStatus::Started { progress, .. } => {
+ *progress = lsp::WorkDoneProgress::Report(status)
+ }
+ });
}
}
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 3bc32439565d..16a26cb26996 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -756,10 +756,11 @@ impl Application {
.compositor
.find::<ui::EditorView>()
.expect("expected at least one EditorView");
- let lsp::ProgressParams { token, value } = params;
-
- let lsp::ProgressParamsValue::WorkDone(work) = value;
- let parts = match &work {
+ let lsp::ProgressParams {
+ token,
+ value: lsp::ProgressParamsValue::WorkDone(work),
+ } = params;
+ let (title, message, percentage) = match &work {
lsp::WorkDoneProgress::Begin(lsp::WorkDoneProgressBegin {
title,
message,
@@ -787,47 +788,43 @@ impl Application {
}
};
- let token_d: &dyn std::fmt::Display = match &token {
- lsp::NumberOrString::Number(n) => n,
- lsp::NumberOrString::String(s) => s,
- };
-
- let status = match parts {
- (Some(title), Some(message), Some(percentage)) => {
- format!("[{}] {}% {} - {}", token_d, percentage, title, message)
- }
- (Some(title), None, Some(percentage)) => {
- format!("[{}] {}% {}", token_d, percentage, title)
- }
- (Some(title), Some(message), None) => {
- format!("[{}] {} - {}", token_d, title, message)
- }
- (None, Some(message), Some(percentage)) => {
- format!("[{}] {}% {}", token_d, percentage, message)
- }
- (Some(title), None, None) => {
- format!("[{}] {}", token_d, title)
+ if self.editor.config().lsp.display_progress_messages {
+ let title =
+ title.or_else(|| self.lsp_progress.title(server_id, &token));
+ if title.is_some() || percentage.is_some() || message.is_some() {
+ use std::fmt::Write as _;
+ let mut status = format!("{}: ", language_server!().name());
+ if let Some(percentage) = percentage {
+ write!(status, "{percentage:>2}% ").unwrap();
+ }
+ if let Some(title) = title {
+ status.push_str(title);
+ }
+ if title.is_some() && message.is_some() {
+ status.push_str(" β
");
+ }
+ if let Some(message) = message {
+ status.push_str(message);
+ }
+ self.editor.set_status(status);
}
- (None, Some(message), None) => {
- format!("[{}] {}", token_d, message)
+ }
+
+ match work {
+ lsp::WorkDoneProgress::Begin(begin_status) => {
+ self.lsp_progress
+ .begin(server_id, token.clone(), begin_status);
}
- (None, None, Some(percentage)) => {
- format!("[{}] {}%", token_d, percentage)
+ lsp::WorkDoneProgress::Report(report_status) => {
+ self.lsp_progress
+ .update(server_id, token.clone(), report_status);
}
- (None, None, None) => format!("[{}]", token_d),
- };
-
- if let lsp::WorkDoneProgress::End(_) = work {
- self.lsp_progress.end_progress(server_id, &token);
- if !self.lsp_progress.is_progressing(server_id) {
- editor_view.spinners_mut().get_or_create(server_id).stop();
+ lsp::WorkDoneProgress::End(_) => {
+ self.lsp_progress.end_progress(server_id, &token);
+ if !self.lsp_progress.is_progressing(server_id) {
+ editor_view.spinners_mut().get_or_create(server_id).stop();
+ };
}
- } else {
- self.lsp_progress.update(server_id, token, work);
- }
-
- if self.config.load().editor.lsp.display_progress_messages {
- self.editor.set_status(status);
}
}
Notification::ProgressMessage(_params) => {
| diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index ba41cbc5aa3c..1a2557de2923 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -733,14 +733,17 @@ impl Registry {
#[derive(Debug)]
pub enum ProgressStatus {
Created,
- Started(lsp::WorkDoneProgress),
+ Started {
+ title: String,
+ progress: lsp::WorkDoneProgress,
+ },
impl ProgressStatus {
pub fn progress(&self) -> Option<&lsp::WorkDoneProgress> {
match &self {
ProgressStatus::Created => None,
- ProgressStatus::Started(progress) => Some(progress),
+ ProgressStatus::Started { title: _, progress } => Some(progress),
}
@@ -777,6 +780,13 @@ impl LspProgressMap {
self.0.get(&id).and_then(|values| values.get(token))
+ pub fn title(&self, id: LanguageServerId, token: &lsp::ProgressToken) -> Option<&String> {
+ self.progress(id, token).and_then(|p| match p {
+ ProgressStatus::Created => None,
+ ProgressStatus::Started { title, .. } => Some(title),
+ })
/// Checks if progress `token` for server with `id` is created.
pub fn is_created(&mut self, id: LanguageServerId, token: &lsp::ProgressToken) -> bool {
@@ -801,17 +811,39 @@ impl LspProgressMap {
self.0.get_mut(&id).and_then(|vals| vals.remove(token))
+ /// Updates the progress of `token` for server with `id` to begin state `status`
+ &mut self,
+ status: lsp::WorkDoneProgressBegin,
+ self.0.entry(id).or_default().insert(
+ token,
+ ProgressStatus::Started {
+ title: status.title.clone(),
+ progress: lsp::WorkDoneProgress::Begin(status),
+ },
+ /// Updates the progress of `token` for server with `id` to report state `status`.
pub fn update(
&mut self,
id: LanguageServerId,
token: lsp::ProgressToken,
- status: lsp::WorkDoneProgress,
- ) -> Option<ProgressStatus> {
+ status: lsp::WorkDoneProgressReport,
.entry(id)
.or_default()
- .insert(token, ProgressStatus::Started(status))
+ .entry(token)
+ .and_modify(|e| match e {
+ ProgressStatus::Created => (),
+ ProgressStatus::Started { progress, .. } => {
+ *progress = lsp::WorkDoneProgress::Report(status)
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 3bc32439565d..16a26cb26996 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -756,10 +756,11 @@ impl Application {
.compositor
.find::<ui::EditorView>()
.expect("expected at least one EditorView");
- let lsp::ProgressParams { token, value } = params;
- let lsp::ProgressParamsValue::WorkDone(work) = value;
- let parts = match &work {
+ let lsp::ProgressParams {
+ token,
+ value: lsp::ProgressParamsValue::WorkDone(work),
+ } = params;
+ let (title, message, percentage) = match &work {
lsp::WorkDoneProgress::Begin(lsp::WorkDoneProgressBegin {
title,
message,
@@ -787,47 +788,43 @@ impl Application {
};
- lsp::NumberOrString::Number(n) => n,
- lsp::NumberOrString::String(s) => s,
- let status = match parts {
- (Some(title), Some(message), Some(percentage)) => {
- format!("[{}] {}% {} - {}", token_d, percentage, title, message)
- (Some(title), None, Some(percentage)) => {
- format!("[{}] {}% {}", token_d, percentage, title)
- (Some(title), Some(message), None) => {
- format!("[{}] {} - {}", token_d, title, message)
- (None, Some(message), Some(percentage)) => {
- format!("[{}] {}% {}", token_d, percentage, message)
- (Some(title), None, None) => {
- format!("[{}] {}", token_d, title)
+ title.or_else(|| self.lsp_progress.title(server_id, &token));
+ if title.is_some() || percentage.is_some() || message.is_some() {
+ use std::fmt::Write as _;
+ let mut status = format!("{}: ", language_server!().name());
+ if let Some(percentage) = percentage {
+ write!(status, "{percentage:>2}% ").unwrap();
+ if let Some(title) = title {
+ status.push_str(title);
+ if title.is_some() && message.is_some() {
+ status.push_str(" β
");
+ if let Some(message) = message {
+ self.editor.set_status(status);
- (None, Some(message), None) => {
- format!("[{}] {}", token_d, message)
+ }
+ match work {
+ lsp::WorkDoneProgress::Begin(begin_status) => {
+ .begin(server_id, token.clone(), begin_status);
- format!("[{}] {}%", token_d, percentage)
+ lsp::WorkDoneProgress::Report(report_status) => {
- (None, None, None) => format!("[{}]", token_d),
- self.lsp_progress.end_progress(server_id, &token);
- if !self.lsp_progress.is_progressing(server_id) {
- editor_view.spinners_mut().get_or_create(server_id).stop();
+ lsp::WorkDoneProgress::End(_) => {
+ self.lsp_progress.end_progress(server_id, &token);
+ if !self.lsp_progress.is_progressing(server_id) {
+ editor_view.spinners_mut().get_or_create(server_id).stop();
+ };
- } else {
- self.lsp_progress.update(server_id, token, work);
- }
- if self.config.load().editor.lsp.display_progress_messages {
- self.editor.set_status(status);
}
}
Notification::ProgressMessage(_params) => { | [
"- /// Updates the progress of `token` for server with `id` to `status`, returns the value replaced or `None`.",
"+ pub fn begin(",
"+ id: LanguageServerId,",
"+ token: lsp::ProgressToken,",
"+ );",
"+ }",
"+ });",
"- let token_d: &dyn std::fmt::Display = match &token {",
"+ if self.editor.config().lsp.display_progress_messages {",
"+ let title =",
"+ status.push_str(message);",
"- (None, None, Some(percentage)) => {",
"+ .update(server_id, token.clone(), report_status);",
"- if let lsp::WorkDoneProgress::End(_) = work {"
] | [
42,
44,
46,
47,
56,
77,
78,
106,
126,
127,
142,
155,
159,
164
] | {
"additions": 76,
"author": "keirlawson",
"deletions": 47,
"html_url": "https://github.com/helix-editor/helix/pull/13180",
"issue_id": 13180,
"merged_at": "2025-03-27T17:00:24Z",
"omission_probability": 0.1,
"pr_number": 13180,
"repo": "helix-editor/helix",
"title": "Track progress title an display in place of internal token",
"total_changes": 123
} |
267 | diff --git a/runtime/themes/earl_grey.toml b/runtime/themes/earl_grey.toml
new file mode 100644
index 000000000000..d4d8f9f556f0
--- /dev/null
+++ b/runtime/themes/earl_grey.toml
@@ -0,0 +1,64 @@
+# Author : Steven Vancoillie <[email protected]>
+#
+# Migraine-friendly, minimal color scheme focused only on structural elements
+# like types, functions, and keywords.
+
+"comment" = { modifiers = ["dim"] }
+"diagnostic.error" = { underline = { color = "blush", style = "curl" } }
+"diagnostic.hint" = { underline = { color = "sky", style = "curl" } }
+"diagnostic.info" = { underline = { color = "grey", style = "curl" } }
+"diagnostic.warning" = { underline = { color = "maple", style = "curl" } }
+"diff.delta" = "silver"
+"diff.minus" = "blush"
+"diff.plus" = "jade"
+"error" = "blush"
+"function" = { modifiers = ["bold"] }
+"hint" = "sky"
+"info" = "grey"
+"keyword" = "earl"
+"type" = "maple"
+"ui.background" = { bg = "chaotica" }
+"ui.background.separator" = { fg = "snow" }
+"ui.cursor" = { fg = "black", bg = "earl" }
+"ui.cursorline.primary" = { bg = "deepspace" }
+"ui.help" = { bg = "deepspace", fg = "snow" }
+"ui.highlight" = { bg = "space" }
+"ui.linenr" = { fg = "grey" }
+"ui.linenr.selected" = { fg = "earl" }
+"ui.menu" = { fg = "snow", bg = "deepspace" }
+"ui.menu.scroll" = { fg = "grey", bg = "deepspace" }
+"ui.menu.selected" = { fg = "snow", bg = "lacquer" }
+"ui.popup" = { bg = "deepspace" }
+"ui.selection" = { bg = "lacquer" }
+"ui.statusline" = { fg = "earl", bg = "deepspace" }
+"ui.statusline.inactive" = { fg = "snow", bg = "deepspace", modifiers = ["dim"] }
+"ui.statusline.insert" = { fg = "chaotica", bg = "earl", modifiers = ["bold"] }
+"ui.statusline.normal" = { fg = "chaotica", bg = "sky", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "chaotica", bg = "myrtle", modifiers = ["bold"] }
+"ui.text" = { fg = "silver" }
+"ui.text.focus" = { fg = "snow" }
+"ui.virtual" = { fg = "space" }
+"ui.virtual.indent-guide" = { fg = "space" }
+"ui.virtual.inlay-hint" = { fg = "lacquer" }
+"ui.virtual.jump-label" = { fg = "myrtle" }
+"ui.virtual.ruler" = { bg = "space" }
+"ui.window" = { fg = "space" }
+"warning" = "maple"
+
+[palette]
+black = "#000000"
+chaotica = "#101010"
+deepspace = "#1b1b1b"
+space = "#2a2a2d"
+lacquer = "#3e3e3e"
+darkgrey = "#505050"
+grey = "#808080"
+silver = "#a6a6a6"
+snow = "#f0f0f0"
+white = "#ffffff"
+blush = "#e78284"
+jade = "#90b99f"
+earl = "#b59efc"
+sky = "#99bbe0"
+myrtle = "#e29eca"
+maple = "#e5c890"
| diff --git a/runtime/themes/earl_grey.toml b/runtime/themes/earl_grey.toml
new file mode 100644
index 000000000000..d4d8f9f556f0
--- /dev/null
+++ b/runtime/themes/earl_grey.toml
@@ -0,0 +1,64 @@
+# Author : Steven Vancoillie <[email protected]>
+#
+# Migraine-friendly, minimal color scheme focused only on structural elements
+# like types, functions, and keywords.
+"comment" = { modifiers = ["dim"] }
+"diagnostic.error" = { underline = { color = "blush", style = "curl" } }
+"diagnostic.hint" = { underline = { color = "sky", style = "curl" } }
+"diagnostic.info" = { underline = { color = "grey", style = "curl" } }
+"diagnostic.warning" = { underline = { color = "maple", style = "curl" } }
+"diff.delta" = "silver"
+"diff.minus" = "blush"
+"diff.plus" = "jade"
+"error" = "blush"
+"function" = { modifiers = ["bold"] }
+"hint" = "sky"
+"keyword" = "earl"
+"type" = "maple"
+"ui.background" = { bg = "chaotica" }
+"ui.background.separator" = { fg = "snow" }
+"ui.cursor" = { fg = "black", bg = "earl" }
+"ui.cursorline.primary" = { bg = "deepspace" }
+"ui.help" = { bg = "deepspace", fg = "snow" }
+"ui.highlight" = { bg = "space" }
+"ui.linenr" = { fg = "grey" }
+"ui.linenr.selected" = { fg = "earl" }
+"ui.menu" = { fg = "snow", bg = "deepspace" }
+"ui.menu.scroll" = { fg = "grey", bg = "deepspace" }
+"ui.menu.selected" = { fg = "snow", bg = "lacquer" }
+"ui.popup" = { bg = "deepspace" }
+"ui.selection" = { bg = "lacquer" }
+"ui.statusline" = { fg = "earl", bg = "deepspace" }
+"ui.statusline.inactive" = { fg = "snow", bg = "deepspace", modifiers = ["dim"] }
+"ui.statusline.insert" = { fg = "chaotica", bg = "earl", modifiers = ["bold"] }
+"ui.statusline.normal" = { fg = "chaotica", bg = "sky", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "chaotica", bg = "myrtle", modifiers = ["bold"] }
+"ui.text" = { fg = "silver" }
+"ui.text.focus" = { fg = "snow" }
+"ui.virtual" = { fg = "space" }
+"ui.virtual.indent-guide" = { fg = "space" }
+"ui.virtual.inlay-hint" = { fg = "lacquer" }
+"ui.virtual.jump-label" = { fg = "myrtle" }
+"ui.window" = { fg = "space" }
+[palette]
+black = "#000000"
+chaotica = "#101010"
+deepspace = "#1b1b1b"
+space = "#2a2a2d"
+lacquer = "#3e3e3e"
+darkgrey = "#505050"
+grey = "#808080"
+silver = "#a6a6a6"
+snow = "#f0f0f0"
+white = "#ffffff"
+blush = "#e78284"
+jade = "#90b99f"
+earl = "#b59efc"
+sky = "#99bbe0"
+myrtle = "#e29eca"
+maple = "#e5c890" | [
"+\"info\" = \"grey\"",
"+\"ui.virtual.ruler\" = { bg = \"space\" }",
"+\"warning\" = \"maple\""
] | [
22,
49,
51
] | {
"additions": 64,
"author": "steabert",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13203",
"issue_id": 13203,
"merged_at": "2025-03-27T13:37:32Z",
"omission_probability": 0.1,
"pr_number": 13203,
"repo": "helix-editor/helix",
"title": "Add earl_grey theme",
"total_changes": 64
} |
268 | diff --git a/Cargo.lock b/Cargo.lock
index b0e34b3f5271..cabb98a70b0e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -136,9 +136,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "cc"
-version = "1.2.16"
+version = "1.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
+checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
dependencies = [
"shlex",
]
@@ -1449,7 +1449,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
- "rustix 1.0.2",
+ "rustix 1.0.3",
"tempfile",
"unicode-segmentation",
"which",
@@ -1556,7 +1556,7 @@ dependencies = [
"log",
"once_cell",
"parking_lot",
- "rustix 1.0.2",
+ "rustix 1.0.3",
"serde",
"serde_json",
"slotmap",
@@ -1911,9 +1911,9 @@ dependencies = [
[[package]]
name = "log"
-version = "0.4.26"
+version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
+checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "maybe-async"
@@ -2259,9 +2259,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "1.0.2"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825"
+checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
dependencies = [
"bitflags",
"errno",
@@ -2485,14 +2485,14 @@ dependencies = [
[[package]]
name = "tempfile"
-version = "3.19.0"
+version = "3.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600"
+checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
dependencies = [
"fastrand",
"getrandom 0.3.1",
"once_cell",
- "rustix 1.0.2",
+ "rustix 1.0.3",
"windows-sys 0.59.0",
]
diff --git a/Cargo.toml b/Cargo.toml
index 4b9e8fea67f6..667a83967726 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.19.0"
+tempfile = "3.19.1"
bitflags = "2.9"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
| diff --git a/Cargo.lock b/Cargo.lock
index b0e34b3f5271..cabb98a70b0e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -136,9 +136,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
name = "cc"
-version = "1.2.16"
+version = "1.2.17"
-checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c"
+checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
"shlex",
@@ -1449,7 +1449,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
"tempfile",
"unicode-segmentation",
"which",
@@ -1556,7 +1556,7 @@ dependencies = [
"log",
"parking_lot",
"serde",
"serde_json",
"slotmap",
@@ -1911,9 +1911,9 @@ dependencies = [
name = "log"
-version = "0.4.26"
+version = "0.4.27"
-checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
+checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
name = "maybe-async"
@@ -2259,9 +2259,9 @@ dependencies = [
name = "rustix"
-version = "1.0.2"
+version = "1.0.3"
-checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825"
+checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
"bitflags",
"errno",
@@ -2485,14 +2485,14 @@ dependencies = [
name = "tempfile"
-version = "3.19.0"
+version = "3.19.1"
-checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600"
+checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
"fastrand",
"getrandom 0.3.1",
"windows-sys 0.59.0",
diff --git a/Cargo.toml b/Cargo.toml
index 4b9e8fea67f6..667a83967726 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.19.0"
+tempfile = "3.19.1"
bitflags = "2.9"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] } | [] | [] | {
"additions": 12,
"author": "dependabot[bot]",
"deletions": 12,
"html_url": "https://github.com/helix-editor/helix/pull/13190",
"issue_id": 13190,
"merged_at": "2025-03-25T12:40:40Z",
"omission_probability": 0.1,
"pr_number": 13190,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group with 4 updates",
"total_changes": 24
} |
269 | diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md
index e6be2ebc01b7..38393a9aee3d 100644
--- a/book/src/SUMMARY.md
+++ b/book/src/SUMMARY.md
@@ -14,7 +14,9 @@
- [Keymap](./keymap.md)
- [Commands](./commands.md)
- [Language support](./lang-support.md)
-- [Migrating from Vim](./from-vim.md)
+- [Ecosystem](./ecosystem.md)
+ - [Migrating from Vim](./from-vim.md)
+ - [Helix mode in other software](./other-software.md)
- [Configuration](./configuration.md)
- [Editor](./editor.md)
- [Themes](./themes.md)
diff --git a/book/src/ecosystem.md b/book/src/ecosystem.md
new file mode 100644
index 000000000000..91d902806c4c
--- /dev/null
+++ b/book/src/ecosystem.md
@@ -0,0 +1,3 @@
+# Ecosystem
+
+This section has information related to the wider Helix ecosystem.
diff --git a/book/src/other-software.md b/book/src/other-software.md
new file mode 100644
index 000000000000..8d6414c53496
--- /dev/null
+++ b/book/src/other-software.md
@@ -0,0 +1,32 @@
+# Helix mode in other software
+
+Helix' keymap and interaction model ([Using Helix](#usage.md)) is easier to adopt if it can be used consistently in many editing contexts. Yet, certain use cases cannot easily be addressed directly in Helix. Similar to vim, this leads to the creation of "Helix mode" in various other software products, allowing Helix-style editing for a greater variety of use cases.
+
+"Helix mode" is frequently still in early stages or missing entirely. For such cases, we also link to relevant bugs or discussions.
+
+## Other editors
+
+| Editor | Plugin or feature providing Helix editing | Comments
+| --- | --- | --- |
+| [Vim](https://www.vim.org/) | [helix.vim](https://github.com/chtenb/helix.vim) config |
+| [IntelliJ IDEA](https://www.jetbrains.com/idea/) / [Android Studio](https://developer.android.com/studio)| [IdeaVim](https://plugins.jetbrains.com/plugin/164-ideavim) plugin + [helix.idea.vim](https://github.com/chtenb/helix.vim) config | Minimum recommended version is IdeaVim 2.19.0.
+| [Visual Studio Code](https://code.visualstudio.com/) | [Dance](https://marketplace.visualstudio.com/items?itemName=gregoire.dance) extension, or its [Helix fork](https://marketplace.visualstudio.com/items?itemName=kend.dancehelixkey) | The Helix fork has diverged. You can also use the original Dance and tweak its keybindings directly (try [this config](https://github.com/71/dance/issues/299#issuecomment-1655509531)).
+| [Visual Studio Code](https://code.visualstudio.com/) | [Helix for VS Code](https://marketplace.visualstudio.com/items?itemName=jasew.vscode-helix-emulation) extension|
+| [Zed](https://zed.dev/) | native via keybindings ([Bug](https://github.com/zed-industries/zed/issues/4642)) |
+| [CodeMirror](https://codemirror.net/) | [codemirror-helix](https://gitlab.com/_rvidal/codemirror-helix) |
+
+
+## Shells
+
+| Shell | Plugin or feature providing Helix editing
+| --- | ---
+| Fish | [Feature Request](https://github.com/fish-shell/fish-shell/issues/7748)
+| Fish | [fish-helix](https://github.com/sshilovsky/fish-helix/tree/main)
+| Zsh | [helix-zsh](https://github.com/john-h-k/helix-zsh)
+| Nushell | [Feature Request](https://github.com/nushell/reedline/issues/639)
+
+## Other software
+
+| Software | Plugin or feature providing Helix editing. | Comments
+| --- | --- | --- |
+| [Obsidian](https://obsidian.md/) | [Obsidian-Helix](https://github.com/Sinono3/obsidian-helix) | Uses `codemirror-helix` listed above.
| diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md
index e6be2ebc01b7..38393a9aee3d 100644
--- a/book/src/SUMMARY.md
+++ b/book/src/SUMMARY.md
@@ -14,7 +14,9 @@
- [Keymap](./keymap.md)
- [Commands](./commands.md)
- [Language support](./lang-support.md)
-- [Migrating from Vim](./from-vim.md)
+- [Ecosystem](./ecosystem.md)
+ - [Migrating from Vim](./from-vim.md)
+ - [Helix mode in other software](./other-software.md)
- [Configuration](./configuration.md)
- [Editor](./editor.md)
- [Themes](./themes.md)
diff --git a/book/src/ecosystem.md b/book/src/ecosystem.md
index 000000000000..91d902806c4c
+++ b/book/src/ecosystem.md
@@ -0,0 +1,3 @@
+# Ecosystem
+This section has information related to the wider Helix ecosystem.
diff --git a/book/src/other-software.md b/book/src/other-software.md
index 000000000000..8d6414c53496
+++ b/book/src/other-software.md
@@ -0,0 +1,32 @@
+# Helix mode in other software
+Helix' keymap and interaction model ([Using Helix](#usage.md)) is easier to adopt if it can be used consistently in many editing contexts. Yet, certain use cases cannot easily be addressed directly in Helix. Similar to vim, this leads to the creation of "Helix mode" in various other software products, allowing Helix-style editing for a greater variety of use cases.
+"Helix mode" is frequently still in early stages or missing entirely. For such cases, we also link to relevant bugs or discussions.
+| Editor | Plugin or feature providing Helix editing | Comments
+| [Vim](https://www.vim.org/) | [helix.vim](https://github.com/chtenb/helix.vim) config |
+| [IntelliJ IDEA](https://www.jetbrains.com/idea/) / [Android Studio](https://developer.android.com/studio)| [IdeaVim](https://plugins.jetbrains.com/plugin/164-ideavim) plugin + [helix.idea.vim](https://github.com/chtenb/helix.vim) config | Minimum recommended version is IdeaVim 2.19.0.
+| [Visual Studio Code](https://code.visualstudio.com/) | [Dance](https://marketplace.visualstudio.com/items?itemName=gregoire.dance) extension, or its [Helix fork](https://marketplace.visualstudio.com/items?itemName=kend.dancehelixkey) | The Helix fork has diverged. You can also use the original Dance and tweak its keybindings directly (try [this config](https://github.com/71/dance/issues/299#issuecomment-1655509531)).
+| [Visual Studio Code](https://code.visualstudio.com/) | [Helix for VS Code](https://marketplace.visualstudio.com/items?itemName=jasew.vscode-helix-emulation) extension|
+| [Zed](https://zed.dev/) | native via keybindings ([Bug](https://github.com/zed-industries/zed/issues/4642)) |
+| [CodeMirror](https://codemirror.net/) | [codemirror-helix](https://gitlab.com/_rvidal/codemirror-helix) |
+| Shell | Plugin or feature providing Helix editing
+| --- | ---
+| Fish | [fish-helix](https://github.com/sshilovsky/fish-helix/tree/main)
+| Zsh | [helix-zsh](https://github.com/john-h-k/helix-zsh)
+| Nushell | [Feature Request](https://github.com/nushell/reedline/issues/639)
+## Other software
+| Software | Plugin or feature providing Helix editing. | Comments
+| [Obsidian](https://obsidian.md/) | [Obsidian-Helix](https://github.com/Sinono3/obsidian-helix) | Uses `codemirror-helix` listed above. | [
"+## Other editors",
"+## Shells",
"+| Fish | [Feature Request](https://github.com/fish-shell/fish-shell/issues/7748) "
] | [
36,
48,
52
] | {
"additions": 38,
"author": "sdoerner",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/12258",
"issue_id": 12258,
"merged_at": "2025-03-24T13:21:37Z",
"omission_probability": 0.1,
"pr_number": 12258,
"repo": "helix-editor/helix",
"title": "Book: Add a section with links to \"Helix mode\" in non-Helix software.",
"total_changes": 39
} |
270 | diff --git a/runtime/themes/focus_nova.toml b/runtime/themes/focus_nova.toml
new file mode 100644
index 000000000000..5f1a496aaf4d
--- /dev/null
+++ b/runtime/themes/focus_nova.toml
@@ -0,0 +1,158 @@
+# Author: Ahmir Postell <[email protected]>
+
+"annotation" = { fg = "fg1" }
+
+"attribute" = { fg = "aqua1", modifiers = ["italic"] }
+
+"comment" = { fg = "gray", modifiers = ["italic"] }
+
+"constant" = { fg = "purple1" }
+"constant.character" = { fg = "aqua1" }
+"constant.character.escape" = { fg = "orange1" }
+"constant.macro" = { fg = "aqua1" }
+"constructor" = { fg = "purple1" }
+
+"definition" = { underline = { color = "aqua1" } }
+
+"diagnostic" = { underline = { color = "orange1", style = "curl" } }
+"diagnostic.deprecated" = { modifiers = ["crossed_out"] }
+"diagnostic.error" = { fg = "red1", underline = { color = "red1", style = "curl" } }
+"diagnostic.warning" = { fg = "yellow1", underline = { color = "yellow1", style = "curl" } }
+"diagnostic.hint" = { underline = { color = "blue1", style = "curl" } }
+"diagnostic.info" = { underline = { color = "aqua1", style = "curl" } }
+# "diagnostic.unnecessary" = { modifiers = ["dim"] } # do not remove this for future resolving
+
+"error" = { fg = "red1" }
+"hint" = { fg = "blue1" }
+"info" = { fg = "aqua1" }
+"warning" = { fg = "yellow1" }
+
+"diff.plus" = { fg = "green1", bg = "bg2" }
+"diff.minus" = { fg = "red1", bg = "bg2" }
+"diff.delta" = { fg = "yellow1", bg = "bg2" }
+
+"function" = { fg = "green1" }
+"function.builtin" = { fg = "yellow1" }
+"function.macro" = { fg = "blue1" }
+
+"keyword" = { fg = "red1" }
+"keyword.control.import" = { fg = "aqua1" }
+
+"label" = { fg = "red1" }
+
+"markup.bold" = { fg = "blue1", modifiers = ["bold"] }
+"markup.heading" = { fg = "purple1", modifiers = ["bold"] }
+"markup.italic" = { fg = "yellow1", modifiers = ["italic"] }
+"markup.link.label" = { fg = "blue1", modifiers = ["italic"] }
+"markup.link.text" = "purple0"
+"markup.link.url" = "aqua1"
+"markup.list" = "aqua1"
+"markup.quote" = { fg = "yellow1", modifiers = ["italic"] }
+"markup.raw" = { fg = "fg1" }
+"markup.strikethrough" = { modifiers = ["crossed_out"] }
+
+"module" = { fg = "aqua1" }
+
+"namespace" = { fg = "fg1" }
+
+"operator" = { fg = "purple1" }
+
+"punctuation" = { fg = "orange1" }
+
+"special" = { fg = "purple0" }
+
+"string" = { fg = "green1" }
+"string.regexp" = { fg = "orange1" }
+"string.special" = { fg = "orange1" }
+"string.symbol" = { fg = "yellow1" }
+
+"tag" = { fg = "aqua1" }
+
+"type" = { fg = "yellow1" }
+"type.enum.variant" = { modifiers = ["italic"] }
+
+"ui.background" = { bg = "bg0" }
+"ui.bufferline" = { fg = "fg1", bg = "bg1" }
+"ui.bufferline.active" = { fg = "bg0", bg = "yellow0" }
+"ui.bufferline.background" = { bg = "bg2" }
+
+"ui.cursor" = { fg = "bg1", bg = "bg2" }
+"ui.cursor.insert" = { fg = "bg1", bg = "blue0" }
+"ui.cursor.normal" = { fg = "bg1", bg = "gray" }
+"ui.cursor.select" = { fg = "bg1", bg = "orange0" }
+"ui.cursor.match" = { fg = "fg1", bg = "bg2", modifiers = ["bold"] }
+
+"ui.cursor.primary" = { bg = "fg3", fg = "bg1" }
+"ui.cursor.primary.insert" = { fg = "bg1", bg = "blue1" }
+"ui.cursor.primary.normal" = { fg = "bg1", bg = "fg3" }
+"ui.cursor.primary.select" = { fg = "bg1", bg = "orange1" }
+
+"ui.cursorline" = { bg = "bg0_s" }
+"ui.cursorline.primary" = { bg = "bg1" }
+
+"ui.help" = { bg = "bg1", fg = "fg1" }
+"ui.linenr" = { fg = "bg3" }
+"ui.linenr.selected" = { fg = "yellow1" }
+"ui.menu" = { fg = "fg1", bg = "bg2" }
+"ui.menu.selected" = { fg = "bg1", bg = "blue1", modifiers = ["bold"] }
+"ui.popup" = { bg = "bg1" }
+"ui.picker.header.column" = { underline.style = "line" }
+"ui.picker.header.column.active" = { modifiers = ["bold"], underline.style = "line" }
+"ui.selection" = { bg = "bg3" }
+"ui.selection.primary" = { bg = "bg4" }
+
+"ui.statusline" = { fg = "fg1", bg = "bg2" }
+"ui.statusline.inactive" = { fg = "fg4", bg = "bg2" }
+"ui.statusline.insert" = { fg = "bg1", bg = "blue1", modifiers = ["bold", "italic"] }
+"ui.statusline.normal" = { fg = "bg1", bg = "fg3", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "bg1", bg = "orange1", modifiers = ["bold"] }
+
+"ui.text" = { fg = "fg1" }
+"ui.text.directory" = { fg = "blue1" }
+"ui.virtual.inlay-hint" = { fg = "gray" }
+"ui.virtual.jump-label" = { fg = "purple0", modifiers = ["bold"] }
+"ui.virtual.ruler" = { bg = "bg1" }
+"ui.virtual.whitespace" = "bg2"
+"ui.virtual.wrap" = { fg = "bg2" }
+"ui.window" = { bg = "bg1" }
+
+"variable" = { fg = "fg1" }
+"variable.builtin" = { fg = "orange1", modifiers = ["italic"] }
+"variable.other.member" = { fg = "blue1" }
+"variable.parameter" = { fg = "blue1", modifiers = ["italic", "bold"] }
+
+[palette]
+bg0 = "#1e1e2e" # main workspace background
+bg0_s = "#1c1c2a" # slightly darker for smooth layering
+bg1 = "#2e2e3e" # active panel
+bg2 = "#3b3b4d" # status bar / line numbers
+bg3 = "#4b4b5e" # popup/menu bg
+bg4 = "#5a5a72" # gutters/secondary borders
+
+fg0 = "#f4f4f5" # high-contrast text
+fg1 = "#dcdcdc" # main foreground
+fg2 = "#c0c0c0" # soft text
+fg3 = "#a8a8a8" # lighter text
+fg4 = "#909090" # faint hints
+
+gray = "#7a7a89" # modern neutral gray, no brown tint
+
+red0 = "#f7768e" # rose red
+red1 = "#ff6e7f" # coral pop
+green0 = "#9ece6a" # tea green
+green1 = "#c0fca0" # brighter success green (tweaked)
+
+yellow0 = "#e0af68" # burnt honey gold
+yellow1 = "#f9e2af" # pastel gold
+
+blue0 = "#7aa2f7" # cobalt sky blue
+blue1 = "#89b4fa" # light sky blue
+
+purple0 = "#bb9af7" # lavender violet
+purple1 = "#cba6f7" # soft purple haze
+
+aqua0 = "#7dcfff" # icy aqua
+aqua1 = "#94e2d5" # mint aqua
+
+orange0 = "#fab387" # peachy orange
+orange1 = "#fca86f" # vibrant tangerine
| diff --git a/runtime/themes/focus_nova.toml b/runtime/themes/focus_nova.toml
new file mode 100644
index 000000000000..5f1a496aaf4d
--- /dev/null
+++ b/runtime/themes/focus_nova.toml
@@ -0,0 +1,158 @@
+# Author: Ahmir Postell <[email protected]>
+"annotation" = { fg = "fg1" }
+"attribute" = { fg = "aqua1", modifiers = ["italic"] }
+"comment" = { fg = "gray", modifiers = ["italic"] }
+"constant" = { fg = "purple1" }
+"constant.character" = { fg = "aqua1" }
+"constant.character.escape" = { fg = "orange1" }
+"constant.macro" = { fg = "aqua1" }
+"definition" = { underline = { color = "aqua1" } }
+"diagnostic" = { underline = { color = "orange1", style = "curl" } }
+"diagnostic.deprecated" = { modifiers = ["crossed_out"] }
+"diagnostic.error" = { fg = "red1", underline = { color = "red1", style = "curl" } }
+"diagnostic.warning" = { fg = "yellow1", underline = { color = "yellow1", style = "curl" } }
+"diagnostic.hint" = { underline = { color = "blue1", style = "curl" } }
+"diagnostic.info" = { underline = { color = "aqua1", style = "curl" } }
+# "diagnostic.unnecessary" = { modifiers = ["dim"] } # do not remove this for future resolving
+"error" = { fg = "red1" }
+"hint" = { fg = "blue1" }
+"info" = { fg = "aqua1" }
+"warning" = { fg = "yellow1" }
+"diff.plus" = { fg = "green1", bg = "bg2" }
+"diff.minus" = { fg = "red1", bg = "bg2" }
+"diff.delta" = { fg = "yellow1", bg = "bg2" }
+"function" = { fg = "green1" }
+"function.builtin" = { fg = "yellow1" }
+"function.macro" = { fg = "blue1" }
+"keyword" = { fg = "red1" }
+"keyword.control.import" = { fg = "aqua1" }
+"label" = { fg = "red1" }
+"markup.bold" = { fg = "blue1", modifiers = ["bold"] }
+"markup.heading" = { fg = "purple1", modifiers = ["bold"] }
+"markup.italic" = { fg = "yellow1", modifiers = ["italic"] }
+"markup.link.label" = { fg = "blue1", modifiers = ["italic"] }
+"markup.link.text" = "purple0"
+"markup.list" = "aqua1"
+"markup.quote" = { fg = "yellow1", modifiers = ["italic"] }
+"markup.raw" = { fg = "fg1" }
+"markup.strikethrough" = { modifiers = ["crossed_out"] }
+"module" = { fg = "aqua1" }
+"namespace" = { fg = "fg1" }
+"operator" = { fg = "purple1" }
+"string" = { fg = "green1" }
+"string.regexp" = { fg = "orange1" }
+"string.special" = { fg = "orange1" }
+"string.symbol" = { fg = "yellow1" }
+"tag" = { fg = "aqua1" }
+"type" = { fg = "yellow1" }
+"type.enum.variant" = { modifiers = ["italic"] }
+"ui.background" = { bg = "bg0" }
+"ui.bufferline" = { fg = "fg1", bg = "bg1" }
+"ui.bufferline.active" = { fg = "bg0", bg = "yellow0" }
+"ui.bufferline.background" = { bg = "bg2" }
+"ui.cursor.insert" = { fg = "bg1", bg = "blue0" }
+"ui.cursor.normal" = { fg = "bg1", bg = "gray" }
+"ui.cursor.select" = { fg = "bg1", bg = "orange0" }
+"ui.cursor.match" = { fg = "fg1", bg = "bg2", modifiers = ["bold"] }
+"ui.cursor.primary" = { bg = "fg3", fg = "bg1" }
+"ui.cursor.primary.insert" = { fg = "bg1", bg = "blue1" }
+"ui.cursor.primary.normal" = { fg = "bg1", bg = "fg3" }
+"ui.cursor.primary.select" = { fg = "bg1", bg = "orange1" }
+"ui.cursorline" = { bg = "bg0_s" }
+"ui.help" = { bg = "bg1", fg = "fg1" }
+"ui.linenr" = { fg = "bg3" }
+"ui.linenr.selected" = { fg = "yellow1" }
+"ui.menu" = { fg = "fg1", bg = "bg2" }
+"ui.menu.selected" = { fg = "bg1", bg = "blue1", modifiers = ["bold"] }
+"ui.popup" = { bg = "bg1" }
+"ui.picker.header.column" = { underline.style = "line" }
+"ui.picker.header.column.active" = { modifiers = ["bold"], underline.style = "line" }
+"ui.selection" = { bg = "bg3" }
+"ui.selection.primary" = { bg = "bg4" }
+"ui.statusline" = { fg = "fg1", bg = "bg2" }
+"ui.statusline.inactive" = { fg = "fg4", bg = "bg2" }
+"ui.statusline.insert" = { fg = "bg1", bg = "blue1", modifiers = ["bold", "italic"] }
+"ui.statusline.normal" = { fg = "bg1", bg = "fg3", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "bg1", bg = "orange1", modifiers = ["bold"] }
+"ui.text" = { fg = "fg1" }
+"ui.text.directory" = { fg = "blue1" }
+"ui.virtual.inlay-hint" = { fg = "gray" }
+"ui.virtual.jump-label" = { fg = "purple0", modifiers = ["bold"] }
+"ui.virtual.ruler" = { bg = "bg1" }
+"ui.virtual.whitespace" = "bg2"
+"ui.virtual.wrap" = { fg = "bg2" }
+"ui.window" = { bg = "bg1" }
+"variable" = { fg = "fg1" }
+"variable.builtin" = { fg = "orange1", modifiers = ["italic"] }
+"variable.other.member" = { fg = "blue1" }
+"variable.parameter" = { fg = "blue1", modifiers = ["italic", "bold"] }
+bg0 = "#1e1e2e" # main workspace background
+bg0_s = "#1c1c2a" # slightly darker for smooth layering
+bg1 = "#2e2e3e" # active panel
+bg2 = "#3b3b4d" # status bar / line numbers
+bg3 = "#4b4b5e" # popup/menu bg
+bg4 = "#5a5a72" # gutters/secondary borders
+fg0 = "#f4f4f5" # high-contrast text
+fg1 = "#dcdcdc" # main foreground
+fg2 = "#c0c0c0" # soft text
+fg3 = "#a8a8a8" # lighter text
+gray = "#7a7a89" # modern neutral gray, no brown tint
+red0 = "#f7768e" # rose red
+green0 = "#9ece6a" # tea green
+green1 = "#c0fca0" # brighter success green (tweaked)
+yellow0 = "#e0af68" # burnt honey gold
+yellow1 = "#f9e2af" # pastel gold
+blue0 = "#7aa2f7" # cobalt sky blue
+blue1 = "#89b4fa" # light sky blue
+purple0 = "#bb9af7" # lavender violet
+aqua0 = "#7dcfff" # icy aqua
+aqua1 = "#94e2d5" # mint aqua
+orange0 = "#fab387" # peachy orange
+orange1 = "#fca86f" # vibrant tangerine | [
"+\"constructor\" = { fg = \"purple1\" }",
"+\"markup.link.url\" = \"aqua1\"",
"+\"punctuation\" = { fg = \"orange1\" }",
"+\"special\" = { fg = \"purple0\" }",
"+\"ui.cursor\" = { fg = \"bg1\", bg = \"bg2\" }",
"+\"ui.cursorline.primary\" = { bg = \"bg1\" }",
"+[palette]",
"+fg4 = \"#909090\" # faint hints",
"+red1 = \"#ff6e7f\" # coral pop",
"+purple1 = \"#cba6f7\" # soft purple haze"
] | [
18,
53,
65,
67,
84,
96,
129,
141,
146,
157
] | {
"additions": 158,
"author": "TheAhmir",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13144",
"issue_id": 13144,
"merged_at": "2025-03-22T21:24:16Z",
"omission_probability": 0.1,
"pr_number": 13144,
"repo": "helix-editor/helix",
"title": "Add focus_nova theme",
"total_changes": 158
} |
271 | diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs
index d63d05fa9360..6bb1f300c213 100644
--- a/helix-core/src/comment.rs
+++ b/helix-core/src/comment.rs
@@ -204,13 +204,9 @@ pub fn find_block_comments(
range: *range,
start_pos,
end_pos,
- start_margin: selection_slice
- .get_char(after_start)
- .map_or(false, |c| c == ' '),
+ start_margin: selection_slice.get_char(after_start) == Some(' '),
end_margin: after_start != before_end
- && selection_slice
- .get_char(before_end)
- .map_or(false, |c| c == ' '),
+ && (selection_slice.get_char(before_end) == Some(' ')),
start_token: start_token.to_string(),
end_token: end_token.to_string(),
});
diff --git a/helix-core/src/doc_formatter.rs b/helix-core/src/doc_formatter.rs
index 3cfc15708d68..cbc884d9444e 100644
--- a/helix-core/src/doc_formatter.rs
+++ b/helix-core/src/doc_formatter.rs
@@ -370,8 +370,8 @@ impl<'t> DocumentFormatter<'t> {
match col.cmp(&(self.text_fmt.viewport_width as usize)) {
// The EOF char and newline chars are always selectable in helix. That means
// that wrapping happens "too-early" if a word fits a line perfectly. This
- // is intentional so that all selectable graphemes are always visisble (and
- // therefore the cursor never dissapears). However if the user manually set a
+ // is intentional so that all selectable graphemes are always visible (and
+ // therefore the cursor never disappears). However if the user manually set a
// lower softwrap width then this is undesirable. Just increasing the viewport-
// width by one doesn't work because if a line is wrapped multiple times then
// some words may extend past the specified width.
@@ -380,9 +380,10 @@ impl<'t> DocumentFormatter<'t> {
// by a newline/eof character here.
Ordering::Equal
if self.text_fmt.soft_wrap_at_text_width
- && self.peek_grapheme(col, char_pos).map_or(false, |grapheme| {
- grapheme.is_newline() || grapheme.is_eof()
- }) => {}
+ && self
+ .peek_grapheme(col, char_pos)
+ .is_some_and(|grapheme| grapheme.is_newline() || grapheme.is_eof()) => {
+ }
Ordering::Equal if word_width > self.text_fmt.max_wrap as usize => return,
Ordering::Greater if word_width > self.text_fmt.max_wrap as usize => {
self.peeked_grapheme = self.word_buf.pop();
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index 108c18d05985..93eb6ce28e60 100644
--- a/helix-core/src/indent.rs
+++ b/helix-core/src/indent.rs
@@ -456,7 +456,7 @@ struct IndentQueryResult<'a> {
fn get_node_start_line(node: Node, new_line_byte_pos: Option<usize>) -> usize {
let mut node_line = node.start_position().row;
// Adjust for the new line that will be inserted
- if new_line_byte_pos.map_or(false, |pos| node.start_byte() >= pos) {
+ if new_line_byte_pos.is_some_and(|pos| node.start_byte() >= pos) {
node_line += 1;
}
node_line
@@ -464,7 +464,7 @@ fn get_node_start_line(node: Node, new_line_byte_pos: Option<usize>) -> usize {
fn get_node_end_line(node: Node, new_line_byte_pos: Option<usize>) -> usize {
let mut node_line = node.end_position().row;
// Adjust for the new line that will be inserted (with a strict inequality since end_byte is exclusive)
- if new_line_byte_pos.map_or(false, |pos| node.end_byte() > pos) {
+ if new_line_byte_pos.is_some_and(|pos| node.end_byte() > pos) {
node_line += 1;
}
node_line
diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs
index 99e911544b5a..7e4fc2b58fda 100644
--- a/helix-loader/src/grammar.rs
+++ b/helix-loader/src/grammar.rs
@@ -273,12 +273,12 @@ fn fetch_grammar(grammar: GrammarConfiguration) -> Result<FetchStatus> {
}
// ensure the remote matches the configured remote
- if get_remote_url(&grammar_dir).map_or(true, |s| s != remote) {
+ if get_remote_url(&grammar_dir).as_ref() != Some(&remote) {
set_remote(&grammar_dir, &remote)?;
}
// ensure the revision matches the configured revision
- if get_revision(&grammar_dir).map_or(true, |s| s != revision) {
+ if get_revision(&grammar_dir).as_ref() != Some(&revision) {
// Fetch the exact revision from the remote.
// Supported by server-side git since v2.5.0 (July 2015),
// enabled by default on major git hosts.
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index cc1c4ce8fe67..f0e42ee447d2 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -85,7 +85,7 @@ impl Client {
.and_then(|root| lsp::Url::from_file_path(root).ok());
if self.root_path == root.unwrap_or(workspace)
- || root_uri.as_ref().map_or(false, |root_uri| {
+ || root_uri.as_ref().is_some_and(|root_uri| {
self.workspace_folders
.lock()
.iter()
diff --git a/helix-stdx/src/rope.rs b/helix-stdx/src/rope.rs
index f7e31924abea..089c3678a604 100644
--- a/helix-stdx/src/rope.rs
+++ b/helix-stdx/src/rope.rs
@@ -43,7 +43,7 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
return false;
}
self.get_byte_slice(len - text.len()..)
- .map_or(false, |end| end == text)
+ .is_some_and(|end| end == text)
}
fn starts_with(self, text: &str) -> bool {
@@ -52,7 +52,7 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
return false;
}
self.get_byte_slice(..text.len())
- .map_or(false, |start| start == text)
+ .is_some_and(|start| start == text)
}
fn regex_input(self) -> RegexInput<RopeyCursor<'a>> {
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 3b90648742dd..5abd196c65ad 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1301,7 +1301,7 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
.line_to_byte(text.byte_to_line(pos) + 1)
.min(pos + 1000);
let search_range = text.slice(search_start..search_end);
- // we also allow paths that are next to the cursor (can be ambigous but
+ // we also allow paths that are next to the cursor (can be ambiguous but
// rarely so in practice) so that gf on quoted/braced path works (not sure about this
// but apparently that is how gf has worked historically in helix)
let path = find_paths(search_range, true)
@@ -2487,7 +2487,7 @@ fn global_search(cx: &mut Context) {
let doc = documents.iter().find(|&(doc_path, _)| {
doc_path
.as_ref()
- .map_or(false, |doc_path| doc_path == entry.path())
+ .is_some_and(|doc_path| doc_path == entry.path())
});
let result = if let Some((_, doc)) = doc {
@@ -2495,7 +2495,7 @@ fn global_search(cx: &mut Context) {
// search the buffer instead of the file because it's faster
// and captures new edits without requiring a save
if searcher.multi_line_with_matcher(&matcher) {
- // in this case a continous buffer is required
+ // in this case a continuous buffer is required
// convert the rope to a string
let text = doc.to_string();
searcher.search_slice(&matcher, text.as_bytes(), sink)
@@ -4036,7 +4036,7 @@ pub mod insert {
let on_auto_pair = doc
.auto_pairs(cx.editor)
.and_then(|pairs| pairs.get(prev))
- .map_or(false, |pair| pair.open == prev && pair.close == curr);
+ .is_some_and(|pair| pair.open == prev && pair.close == curr);
let local_offs = if let Some(token) = continue_comment_token {
new_text.push_str(doc.line_ending.as_str());
@@ -6456,7 +6456,7 @@ fn jump_to_word(cx: &mut Context, behaviour: Movement) {
let mut cursor_rev = Range::point(cursor);
if text.get_char(cursor).is_some_and(|c| !c.is_whitespace()) {
let cursor_word_end = movement::move_next_word_end(text, cursor_fwd, 1);
- // single grapheme words need a specical case
+ // single grapheme words need a special case
if cursor_word_end.anchor == cursor {
cursor_fwd = cursor_word_end;
}
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index fcc0333e8cd8..e52b2bf4187a 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -1288,7 +1288,7 @@ fn compute_inlay_hints_for_view(
if !doc.inlay_hints_oudated
&& doc
.inlay_hints(view_id)
- .map_or(false, |dih| dih.id == new_doc_inlay_hints_id)
+ .is_some_and(|dih| dih.id == new_doc_inlay_hints_id)
{
return None;
}
diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs
index cf4fbd9fa7ae..a371dd1cfab4 100644
--- a/helix-term/src/lib.rs
+++ b/helix-term/src/lib.rs
@@ -63,7 +63,7 @@ fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> b
.path()
.canonicalize()
.ok()
- .map_or(false, |path| !path.starts_with(root));
+ .is_some_and(|path| !path.starts_with(root));
}
true
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index adacfad330f4..c808073c36b7 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -53,9 +53,10 @@ impl menu::Item for CompletionItem {
let deprecated = match self {
CompletionItem::Lsp(LspCompletionItem { item, .. }) => {
item.deprecated.unwrap_or_default()
- || item.tags.as_ref().map_or(false, |tags| {
- tags.contains(&lsp::CompletionItemTag::DEPRECATED)
- })
+ || item
+ .tags
+ .as_ref()
+ .is_some_and(|tags| tags.contains(&lsp::CompletionItemTag::DEPRECATED))
}
CompletionItem::Other(_) => false,
};
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 6ee49fa57ddd..2313fb808245 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -363,7 +363,7 @@ pub mod completers {
git_ignore: bool,
) -> Vec<Completion> {
filename_impl(editor, input, git_ignore, |entry| {
- let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
+ let is_dir = entry.file_type().is_some_and(|entry| entry.is_dir());
if is_dir {
FileMatch::AcceptIncomplete
@@ -414,7 +414,7 @@ pub mod completers {
git_ignore: bool,
) -> Vec<Completion> {
filename_impl(editor, input, git_ignore, |entry| {
- let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
+ let is_dir = entry.file_type().is_some_and(|entry| entry.is_dir());
if is_dir {
FileMatch::Accept
diff --git a/helix-view/src/annotations/diagnostics.rs b/helix-view/src/annotations/diagnostics.rs
index 09085d3feb2d..7802ca637410 100644
--- a/helix-view/src/annotations/diagnostics.rs
+++ b/helix-view/src/annotations/diagnostics.rs
@@ -178,7 +178,7 @@ impl<'a> InlineDiagnosticAccumulator<'a> {
horizontal_off: usize,
) -> bool {
// TODO: doing the cursor tracking here works well but is somewhat
- // duplicate effort/tedious maybe centralize this somehwere?
+ // duplicate effort/tedious maybe centralize this somewhere?
// In the DocFormatter?
if grapheme.char_idx == self.cursor {
self.cursor_line = true;
@@ -248,9 +248,9 @@ impl<'a> InlineDiagnosticAccumulator<'a> {
}
pub fn has_multi(&self, width: u16) -> bool {
- self.stack.last().map_or(false, |&(_, anchor)| {
- anchor > self.config.max_diagnostic_start(width)
- })
+ self.stack
+ .last()
+ .is_some_and(|&(_, anchor)| anchor > self.config.max_diagnostic_start(width))
}
}
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index edbc96b013e3..95109c57f7f3 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -717,10 +717,7 @@ impl Document {
config: Arc<dyn DynAccess<Config>>,
) -> Result<Self, DocumentOpenError> {
// If the path is not a regular file (e.g.: /dev/random) it should not be opened.
- if path
- .metadata()
- .map_or(false, |metadata| !metadata.is_file())
- {
+ if path.metadata().is_ok_and(|metadata| !metadata.is_file()) {
return Err(DocumentOpenError::IrregularFile);
}
@@ -1999,8 +1996,8 @@ impl Document {
};
let ends_at_word =
- start != end && end != 0 && text.get_char(end - 1).map_or(false, char_is_word);
- let starts_at_word = start != end && text.get_char(start).map_or(false, char_is_word);
+ start != end && end != 0 && text.get_char(end - 1).is_some_and(char_is_word);
+ let starts_at_word = start != end && text.get_char(start).is_some_and(char_is_word);
Some(Diagnostic {
range: Range { start, end },
@@ -2033,7 +2030,7 @@ impl Document {
self.clear_diagnostics(language_server_id);
} else {
self.diagnostics.retain(|d| {
- if language_server_id.map_or(false, |id| id != d.provider) {
+ if language_server_id.is_some_and(|id| id != d.provider) {
return true;
}
diff --git a/helix-view/src/handlers/lsp.rs b/helix-view/src/handlers/lsp.rs
index 1fd2289db5d8..e76b4c6330a2 100644
--- a/helix-view/src/handlers/lsp.rs
+++ b/helix-view/src/handlers/lsp.rs
@@ -244,7 +244,7 @@ impl Editor {
ResourceOp::Create(op) => {
let uri = Uri::try_from(&op.uri)?;
let path = uri.as_path().expect("URIs are valid paths");
- let ignore_if_exists = op.options.as_ref().map_or(false, |options| {
+ let ignore_if_exists = op.options.as_ref().is_some_and(|options| {
!options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
});
if !ignore_if_exists || !path.exists() {
@@ -288,7 +288,7 @@ impl Editor {
let from = from_uri.as_path().expect("URIs are valid paths");
let to_uri = Uri::try_from(&op.new_uri)?;
let to = to_uri.as_path().expect("URIs are valid paths");
- let ignore_if_exists = op.options.as_ref().map_or(false, |options| {
+ let ignore_if_exists = op.options.as_ref().is_some_and(|options| {
!options.overwrite.unwrap_or(false) && options.ignore_if_exists.unwrap_or(false)
});
if !ignore_if_exists || !to.exists() {
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index fca47413c1e1..c3f6af882ae0 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -500,10 +500,7 @@ impl ThemePalette {
let modifiers = value.as_array().ok_or("Modifiers should be an array")?;
for modifier in modifiers {
- if modifier
- .as_str()
- .map_or(false, |modifier| modifier == "underlined")
- {
+ if modifier.as_str() == Some("underlined") {
*style = style.underline_style(UnderlineStyle::Line);
} else {
*style = style.add_modifier(Self::parse_modifier(modifier)?);
| diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs
index d63d05fa9360..6bb1f300c213 100644
--- a/helix-core/src/comment.rs
+++ b/helix-core/src/comment.rs
@@ -204,13 +204,9 @@ pub fn find_block_comments(
range: *range,
start_pos,
end_pos,
- start_margin: selection_slice
- .get_char(after_start)
- .map_or(false, |c| c == ' '),
+ start_margin: selection_slice.get_char(after_start) == Some(' '),
end_margin: after_start != before_end
- && selection_slice
- .get_char(before_end)
- .map_or(false, |c| c == ' '),
+ && (selection_slice.get_char(before_end) == Some(' ')),
start_token: start_token.to_string(),
end_token: end_token.to_string(),
diff --git a/helix-core/src/doc_formatter.rs b/helix-core/src/doc_formatter.rs
index 3cfc15708d68..cbc884d9444e 100644
--- a/helix-core/src/doc_formatter.rs
+++ b/helix-core/src/doc_formatter.rs
@@ -370,8 +370,8 @@ impl<'t> DocumentFormatter<'t> {
match col.cmp(&(self.text_fmt.viewport_width as usize)) {
// The EOF char and newline chars are always selectable in helix. That means
// that wrapping happens "too-early" if a word fits a line perfectly. This
- // is intentional so that all selectable graphemes are always visisble (and
- // therefore the cursor never dissapears). However if the user manually set a
+ // is intentional so that all selectable graphemes are always visible (and
+ // therefore the cursor never disappears). However if the user manually set a
// lower softwrap width then this is undesirable. Just increasing the viewport-
// width by one doesn't work because if a line is wrapped multiple times then
// some words may extend past the specified width.
@@ -380,9 +380,10 @@ impl<'t> DocumentFormatter<'t> {
// by a newline/eof character here.
Ordering::Equal
if self.text_fmt.soft_wrap_at_text_width
- && self.peek_grapheme(col, char_pos).map_or(false, |grapheme| {
- grapheme.is_newline() || grapheme.is_eof()
- }) => {}
+ && self
+ .peek_grapheme(col, char_pos)
+ .is_some_and(|grapheme| grapheme.is_newline() || grapheme.is_eof()) => {
+ }
Ordering::Equal if word_width > self.text_fmt.max_wrap as usize => return,
Ordering::Greater if word_width > self.text_fmt.max_wrap as usize => {
self.peeked_grapheme = self.word_buf.pop();
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index 108c18d05985..93eb6ce28e60 100644
--- a/helix-core/src/indent.rs
+++ b/helix-core/src/indent.rs
@@ -456,7 +456,7 @@ struct IndentQueryResult<'a> {
fn get_node_start_line(node: Node, new_line_byte_pos: Option<usize>) -> usize {
let mut node_line = node.start_position().row;
// Adjust for the new line that will be inserted
- if new_line_byte_pos.map_or(false, |pos| node.start_byte() >= pos) {
+ if new_line_byte_pos.is_some_and(|pos| node.start_byte() >= pos) {
@@ -464,7 +464,7 @@ fn get_node_start_line(node: Node, new_line_byte_pos: Option<usize>) -> usize {
fn get_node_end_line(node: Node, new_line_byte_pos: Option<usize>) -> usize {
let mut node_line = node.end_position().row;
// Adjust for the new line that will be inserted (with a strict inequality since end_byte is exclusive)
- if new_line_byte_pos.map_or(false, |pos| node.end_byte() > pos) {
+ if new_line_byte_pos.is_some_and(|pos| node.end_byte() > pos) {
diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs
index 99e911544b5a..7e4fc2b58fda 100644
--- a/helix-loader/src/grammar.rs
+++ b/helix-loader/src/grammar.rs
@@ -273,12 +273,12 @@ fn fetch_grammar(grammar: GrammarConfiguration) -> Result<FetchStatus> {
// ensure the remote matches the configured remote
+ if get_remote_url(&grammar_dir).as_ref() != Some(&remote) {
set_remote(&grammar_dir, &remote)?;
// ensure the revision matches the configured revision
+ if get_revision(&grammar_dir).as_ref() != Some(&revision) {
// Fetch the exact revision from the remote.
// Supported by server-side git since v2.5.0 (July 2015),
// enabled by default on major git hosts.
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index cc1c4ce8fe67..f0e42ee447d2 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -85,7 +85,7 @@ impl Client {
.and_then(|root| lsp::Url::from_file_path(root).ok());
if self.root_path == root.unwrap_or(workspace)
- || root_uri.as_ref().map_or(false, |root_uri| {
self.workspace_folders
.lock()
.iter()
diff --git a/helix-stdx/src/rope.rs b/helix-stdx/src/rope.rs
index f7e31924abea..089c3678a604 100644
--- a/helix-stdx/src/rope.rs
+++ b/helix-stdx/src/rope.rs
@@ -43,7 +43,7 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
self.get_byte_slice(len - text.len()..)
- .map_or(false, |end| end == text)
+ .is_some_and(|end| end == text)
fn starts_with(self, text: &str) -> bool {
@@ -52,7 +52,7 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
self.get_byte_slice(..text.len())
- .map_or(false, |start| start == text)
+ .is_some_and(|start| start == text)
fn regex_input(self) -> RegexInput<RopeyCursor<'a>> {
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 3b90648742dd..5abd196c65ad 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1301,7 +1301,7 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
.line_to_byte(text.byte_to_line(pos) + 1)
.min(pos + 1000);
let search_range = text.slice(search_start..search_end);
- // we also allow paths that are next to the cursor (can be ambigous but
+ // we also allow paths that are next to the cursor (can be ambiguous but
// rarely so in practice) so that gf on quoted/braced path works (not sure about this
// but apparently that is how gf has worked historically in helix)
let path = find_paths(search_range, true)
@@ -2487,7 +2487,7 @@ fn global_search(cx: &mut Context) {
let doc = documents.iter().find(|&(doc_path, _)| {
doc_path
.as_ref()
- .map_or(false, |doc_path| doc_path == entry.path())
});
let result = if let Some((_, doc)) = doc {
@@ -2495,7 +2495,7 @@ fn global_search(cx: &mut Context) {
// search the buffer instead of the file because it's faster
// and captures new edits without requiring a save
if searcher.multi_line_with_matcher(&matcher) {
- // in this case a continous buffer is required
+ // in this case a continuous buffer is required
// convert the rope to a string
let text = doc.to_string();
searcher.search_slice(&matcher, text.as_bytes(), sink)
@@ -4036,7 +4036,7 @@ pub mod insert {
let on_auto_pair = doc
.auto_pairs(cx.editor)
.and_then(|pairs| pairs.get(prev))
- .map_or(false, |pair| pair.open == prev && pair.close == curr);
+ .is_some_and(|pair| pair.open == prev && pair.close == curr);
let local_offs = if let Some(token) = continue_comment_token {
new_text.push_str(doc.line_ending.as_str());
@@ -6456,7 +6456,7 @@ fn jump_to_word(cx: &mut Context, behaviour: Movement) {
let mut cursor_rev = Range::point(cursor);
if text.get_char(cursor).is_some_and(|c| !c.is_whitespace()) {
let cursor_word_end = movement::move_next_word_end(text, cursor_fwd, 1);
- // single grapheme words need a specical case
+ // single grapheme words need a special case
if cursor_word_end.anchor == cursor {
cursor_fwd = cursor_word_end;
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index fcc0333e8cd8..e52b2bf4187a 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -1288,7 +1288,7 @@ fn compute_inlay_hints_for_view(
if !doc.inlay_hints_oudated
&& doc
.inlay_hints(view_id)
- .map_or(false, |dih| dih.id == new_doc_inlay_hints_id)
+ .is_some_and(|dih| dih.id == new_doc_inlay_hints_id)
{
return None;
diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs
index cf4fbd9fa7ae..a371dd1cfab4 100644
--- a/helix-term/src/lib.rs
+++ b/helix-term/src/lib.rs
@@ -63,7 +63,7 @@ fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> b
.path()
.canonicalize()
.ok()
- .map_or(false, |path| !path.starts_with(root));
+ .is_some_and(|path| !path.starts_with(root));
true
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index adacfad330f4..c808073c36b7 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -53,9 +53,10 @@ impl menu::Item for CompletionItem {
let deprecated = match self {
CompletionItem::Lsp(LspCompletionItem { item, .. }) => {
item.deprecated.unwrap_or_default()
- || item.tags.as_ref().map_or(false, |tags| {
- tags.contains(&lsp::CompletionItemTag::DEPRECATED)
- })
+ || item
+ .tags
+ .as_ref()
}
CompletionItem::Other(_) => false,
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 6ee49fa57ddd..2313fb808245 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -363,7 +363,7 @@ pub mod completers {
FileMatch::AcceptIncomplete
@@ -414,7 +414,7 @@ pub mod completers {
FileMatch::Accept
diff --git a/helix-view/src/annotations/diagnostics.rs b/helix-view/src/annotations/diagnostics.rs
index 09085d3feb2d..7802ca637410 100644
--- a/helix-view/src/annotations/diagnostics.rs
+++ b/helix-view/src/annotations/diagnostics.rs
@@ -178,7 +178,7 @@ impl<'a> InlineDiagnosticAccumulator<'a> {
horizontal_off: usize,
) -> bool {
// TODO: doing the cursor tracking here works well but is somewhat
- // duplicate effort/tedious maybe centralize this somehwere?
+ // duplicate effort/tedious maybe centralize this somewhere?
// In the DocFormatter?
if grapheme.char_idx == self.cursor {
self.cursor_line = true;
@@ -248,9 +248,9 @@ impl<'a> InlineDiagnosticAccumulator<'a> {
pub fn has_multi(&self, width: u16) -> bool {
- self.stack.last().map_or(false, |&(_, anchor)| {
- anchor > self.config.max_diagnostic_start(width)
- })
+ self.stack
+ .last()
+ .is_some_and(|&(_, anchor)| anchor > self.config.max_diagnostic_start(width))
}
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index edbc96b013e3..95109c57f7f3 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -717,10 +717,7 @@ impl Document {
config: Arc<dyn DynAccess<Config>>,
) -> Result<Self, DocumentOpenError> {
// If the path is not a regular file (e.g.: /dev/random) it should not be opened.
- if path
- .metadata()
- .map_or(false, |metadata| !metadata.is_file())
- {
return Err(DocumentOpenError::IrregularFile);
@@ -1999,8 +1996,8 @@ impl Document {
let ends_at_word =
- start != end && end != 0 && text.get_char(end - 1).map_or(false, char_is_word);
- let starts_at_word = start != end && text.get_char(start).map_or(false, char_is_word);
+ start != end && end != 0 && text.get_char(end - 1).is_some_and(char_is_word);
+ let starts_at_word = start != end && text.get_char(start).is_some_and(char_is_word);
Some(Diagnostic {
range: Range { start, end },
@@ -2033,7 +2030,7 @@ impl Document {
self.clear_diagnostics(language_server_id);
} else {
self.diagnostics.retain(|d| {
+ if language_server_id.is_some_and(|id| id != d.provider) {
return true;
}
diff --git a/helix-view/src/handlers/lsp.rs b/helix-view/src/handlers/lsp.rs
index 1fd2289db5d8..e76b4c6330a2 100644
--- a/helix-view/src/handlers/lsp.rs
+++ b/helix-view/src/handlers/lsp.rs
@@ -244,7 +244,7 @@ impl Editor {
ResourceOp::Create(op) => {
let uri = Uri::try_from(&op.uri)?;
let path = uri.as_path().expect("URIs are valid paths");
if !ignore_if_exists || !path.exists() {
@@ -288,7 +288,7 @@ impl Editor {
let from = from_uri.as_path().expect("URIs are valid paths");
let to_uri = Uri::try_from(&op.new_uri)?;
let to = to_uri.as_path().expect("URIs are valid paths");
if !ignore_if_exists || !to.exists() {
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index fca47413c1e1..c3f6af882ae0 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -500,10 +500,7 @@ impl ThemePalette {
let modifiers = value.as_array().ok_or("Modifiers should be an array")?;
for modifier in modifiers {
- .as_str()
- .map_or(false, |modifier| modifier == "underlined")
- {
+ if modifier.as_str() == Some("underlined") {
*style = style.underline_style(UnderlineStyle::Line);
} else {
*style = style.add_modifier(Self::parse_modifier(modifier)?); | [
"- if get_remote_url(&grammar_dir).map_or(true, |s| s != remote) {",
"- if get_revision(&grammar_dir).map_or(true, |s| s != revision) {",
"+ || root_uri.as_ref().is_some_and(|root_uri| {",
"+ .is_some_and(|doc_path| doc_path == entry.path())",
"+ .is_some_and(|tags| tags.contains(&lsp::CompletionItemTag::DEPRECATED))",
"+ if path.metadata().is_ok_and(|metadata| !metadata.is_file()) {",
"- if language_server_id.map_or(false, |id| id != d.provider) {",
"- if modifier"
] | [
79,
85,
99,
143,
214,
278,
297,
332
] | {
"additions": 39,
"author": "RoloEdits",
"deletions": 47,
"html_url": "https://github.com/helix-editor/helix/pull/12462",
"issue_id": 12462,
"merged_at": "2025-01-23T20:18:16Z",
"omission_probability": 0.1,
"pr_number": 12462,
"repo": "helix-editor/helix",
"title": "fix(lints): clippy 1.84",
"total_changes": 86
} |
272 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index fd621c943bd7..f6aee3fe3410 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -247,6 +247,7 @@
| wast | β | | | |
| wat | β | | | `wat_server` |
| webc | β | | | |
+| werk | β | | | |
| wgsl | β | | | `wgsl-analyzer` |
| wit | β | | β | |
| wren | β | β | β | |
diff --git a/languages.toml b/languages.toml
index bf7045e011cc..5a596a0f0dd4 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4241,3 +4241,13 @@ formatter = {command = "tlafmt", args = ["--stdin"]}
name = "tlaplus"
source = { git = "https://github.com/tlaplus-community/tree-sitter-tlaplus", rev = "4ba91b07b97741a67f61221d0d50e6d962e4987e"}
+[[language]]
+name = "werk"
+scope = "source.werk"
+file-types = [ "werk", { glob = "Werkfile" } ]
+comment-token = "#"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "werk"
+source = { git = "https://github.com/little-bonsai/tree-sitter-werk", rev = "92b0f7fe98465c4c435794a58e961306193d1c1e" }
diff --git a/runtime/queries/werk/highlights.scm b/runtime/queries/werk/highlights.scm
new file mode 100644
index 000000000000..2636be3cdc46
--- /dev/null
+++ b/runtime/queries/werk/highlights.scm
@@ -0,0 +1,62 @@
+(buildBlock . ("build") @keyword.function)
+(taskBlock . ("task") @keyword.function )
+(run . ("run") @keyword.function )
+(taskBlock name: (identifier) @function )
+
+(comment) @comment
+(string) @string
+(number) @constant.numeric
+(identifier) @identifier
+
+(include) @keyword.control.import
+(let) @keyword.storage
+(default) @keyword.storage
+(config) @keyword.storage
+
+(interpolation ["{" "}" "<" ">" ] @punctuation.special)
+["{" "}" "<" ">" "(" ")" "[" "]"] @punctuation.bracket
+["=>" "|"] @punctuation
+
+; Statements
+(build "build") @function
+(config "config") @function
+(copy "copy") @function
+(default "default") @function
+(delete "delete") @function
+(depfile "depfile") @function
+(envRemove "env-remove") @function
+(from "from") @function
+(info "info") @function
+(let "let") @function
+(setEnv "env") @function
+(shell "shell") @function
+(write "write") @function
+
+; Expressions
+(error "error" @function.builtin)
+(getEnv "env" @function.builtin)
+(glob "glob" @function.builtin)
+(include "include" @function.builtin)
+(info "info" @function.builtin)
+(read "read" @function.builtin)
+(warn "warn" @function.builtin)
+(which "which" @function.builtin)
+
+; Operations
+(op (string) @operator)
+("dedup" @operator)
+("first" @operator)
+("flatten" @operator)
+("last" @operator)
+("len" @operator)
+("lines" @operator)
+("tail" @operator)
+(assertEq "assert-eq" @operator)
+(discard "discard" @operator)
+(filter "filter" @operator)
+(filterMatch "filter-match" @operator)
+(join "join" @operator)
+(map "map" @operator)
+(match "match" @operator)
+(split "split" @operator)
+
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index fd621c943bd7..f6aee3fe3410 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -247,6 +247,7 @@
| wast | β | | | |
| wat | β | | | `wat_server` |
| webc | β | | | |
+| werk | β | | | |
| wgsl | β | | | `wgsl-analyzer` |
| wit | β | | β | |
| wren | β | β | β | |
diff --git a/languages.toml b/languages.toml
index bf7045e011cc..5a596a0f0dd4 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4241,3 +4241,13 @@ formatter = {command = "tlafmt", args = ["--stdin"]}
name = "tlaplus"
source = { git = "https://github.com/tlaplus-community/tree-sitter-tlaplus", rev = "4ba91b07b97741a67f61221d0d50e6d962e4987e"}
+[[language]]
+scope = "source.werk"
+file-types = [ "werk", { glob = "Werkfile" } ]
+indent = { tab-width = 2, unit = " " }
+[[grammar]]
+source = { git = "https://github.com/little-bonsai/tree-sitter-werk", rev = "92b0f7fe98465c4c435794a58e961306193d1c1e" }
diff --git a/runtime/queries/werk/highlights.scm b/runtime/queries/werk/highlights.scm
new file mode 100644
index 000000000000..2636be3cdc46
--- /dev/null
+++ b/runtime/queries/werk/highlights.scm
@@ -0,0 +1,62 @@
+(buildBlock . ("build") @keyword.function)
+(taskBlock . ("task") @keyword.function )
+(run . ("run") @keyword.function )
+(comment) @comment
+(string) @string
+(number) @constant.numeric
+(identifier) @identifier
+(include) @keyword.control.import
+(let) @keyword.storage
+(default) @keyword.storage
+(config) @keyword.storage
+(interpolation ["{" "}" "<" ">" ] @punctuation.special)
+["{" "}" "<" ">" "(" ")" "[" "]"] @punctuation.bracket
+["=>" "|"] @punctuation
+; Statements
+(build "build") @function
+(config "config") @function
+(copy "copy") @function
+(default "default") @function
+(delete "delete") @function
+(depfile "depfile") @function
+(envRemove "env-remove") @function
+(info "info") @function
+(let "let") @function
+(setEnv "env") @function
+; Expressions
+(error "error" @function.builtin)
+(getEnv "env" @function.builtin)
+(glob "glob" @function.builtin)
+(info "info" @function.builtin)
+(read "read" @function.builtin)
+(warn "warn" @function.builtin)
+(which "which" @function.builtin)
+; Operations
+(op (string) @operator)
+("dedup" @operator)
+("first" @operator)
+("flatten" @operator)
+("last" @operator)
+("len" @operator)
+("lines" @operator)
+("tail" @operator)
+(assertEq "assert-eq" @operator)
+(discard "discard" @operator)
+(filter "filter" @operator)
+(filterMatch "filter-match" @operator)
+(join "join" @operator)
+(map "map" @operator)
+(match "match" @operator)
+(split "split" @operator) | [
"+comment-token = \"#\"",
"+(taskBlock name: (identifier) @function )",
"+(from \"from\") @function",
"+(shell \"shell\") @function",
"+(write \"write\") @function",
"+(include \"include\" @function.builtin)"
] | [
24,
39,
63,
67,
68,
74
] | {
"additions": 73,
"author": "FreddieGilbraith",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/13136",
"issue_id": 13136,
"merged_at": "2025-03-20T13:04:53Z",
"omission_probability": 0.1,
"pr_number": 13136,
"repo": "helix-editor/helix",
"title": "add werk language and highlights",
"total_changes": 73
} |
273 | diff --git a/Cargo.lock b/Cargo.lock
index 5f8204c2cbe7..b0e34b3f5271 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -423,9 +423,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "form_urlencoded"
@@ -1856,9 +1856,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.170"
+version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
+checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "libloading"
@@ -2023,9 +2023,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.21.0"
+version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad"
+checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
[[package]]
name = "open"
@@ -2485,11 +2485,10 @@ dependencies = [
[[package]]
name = "tempfile"
-version = "3.18.0"
+version = "3.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567"
+checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600"
dependencies = [
- "cfg-if",
"fastrand",
"getrandom 0.3.1",
"once_cell",
@@ -2593,9 +2592,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.44.0"
+version = "1.44.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a"
+checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
dependencies = [
"backtrace",
"bytes",
diff --git a/Cargo.toml b/Cargo.toml
index 52a52070af24..4b9e8fea67f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.18.0"
+tempfile = "3.19.0"
bitflags = "2.9"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 7f7ffb6a1d44..9ea2d4589e46 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -93,7 +93,7 @@ grep-searcher = "0.1.14"
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
-libc = "0.2.170"
+libc = "0.2.171"
[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc"] }
| diff --git a/Cargo.lock b/Cargo.lock
index 5f8204c2cbe7..b0e34b3f5271 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -423,9 +423,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
name = "foldhash"
-version = "0.1.4"
+version = "0.1.5"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
name = "form_urlencoded"
@@ -1856,9 +1856,9 @@ dependencies = [
name = "libc"
-version = "0.2.170"
-checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
+checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
name = "libloading"
@@ -2023,9 +2023,9 @@ dependencies = [
name = "once_cell"
-version = "1.21.0"
+version = "1.21.1"
-checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad"
+checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
name = "open"
@@ -2485,11 +2485,10 @@ dependencies = [
name = "tempfile"
-version = "3.18.0"
+version = "3.19.0"
-checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567"
- "cfg-if",
"fastrand",
"getrandom 0.3.1",
"once_cell",
@@ -2593,9 +2592,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
name = "tokio"
-version = "1.44.0"
+version = "1.44.1"
-checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a"
+checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
"backtrace",
"bytes",
diff --git a/Cargo.toml b/Cargo.toml
index 52a52070af24..4b9e8fea67f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.18.0"
+tempfile = "3.19.0"
bitflags = "2.9"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 7f7ffb6a1d44..9ea2d4589e46 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -93,7 +93,7 @@ grep-searcher = "0.1.14"
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
-libc = "0.2.170"
+libc = "0.2.171"
[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc"] } | [
"-checksum = \"a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f\"",
"+version = \"0.2.171\"",
"+checksum = \"488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600\""
] | [
11,
21,
48
] | {
"additions": 12,
"author": "dependabot[bot]",
"deletions": 13,
"html_url": "https://github.com/helix-editor/helix/pull/13131",
"issue_id": 13131,
"merged_at": "2025-03-18T03:52:23Z",
"omission_probability": 0.1,
"pr_number": 13131,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group with 5 updates",
"total_changes": 25
} |
274 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 0d4bc7f8f627..07823b28eeef 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -138,6 +138,7 @@
| make | β | | β | |
| markdoc | β | | | `markdoc-ls` |
| markdown | β | | | `marksman`, `markdown-oxide` |
+| markdown-rustdoc | β | | | |
| markdown.inline | β | | | |
| matlab | β | β | β | |
| mermaid | β | | | |
diff --git a/languages.toml b/languages.toml
index 3e790d76e3eb..3652e17af45e 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1704,6 +1704,15 @@ block-comment-tokens = { start = "<!--", end = "-->" }
name = "markdown"
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-markdown", rev = "62516e8c78380e3b51d5b55727995d2c511436d8", subpath = "tree-sitter-markdown" }
+[[language]]
+name = "markdown-rustdoc"
+scope = "source.markdown-rustdoc"
+grammar = "markdown"
+injection-regex = "markdown-rustdoc"
+file-types = []
+indent = { tab-width = 2, unit = " " }
+block-comment-tokens = { start = "<!--", end = "-->" }
+
[[language]]
name = "markdown.inline"
scope = "source.markdown.inline"
diff --git a/runtime/queries/markdown-rustdoc/highlights.scm b/runtime/queries/markdown-rustdoc/highlights.scm
new file mode 100644
index 000000000000..a3a30e342921
--- /dev/null
+++ b/runtime/queries/markdown-rustdoc/highlights.scm
@@ -0,0 +1 @@
+; inherits: markdown
diff --git a/runtime/queries/markdown-rustdoc/injections.scm b/runtime/queries/markdown-rustdoc/injections.scm
new file mode 100644
index 000000000000..8beba4e237b6
--- /dev/null
+++ b/runtime/queries/markdown-rustdoc/injections.scm
@@ -0,0 +1,15 @@
+; inherits: markdown
+
+; In Rust, it is common to have documentation code blocks not specify the
+; language, and it is assumed to be Rust if it is not specified.
+
+(fenced_code_block
+ (code_fence_content) @injection.content
+ (#set! injection.language "rust")
+ (#set! injection.include-unnamed-children))
+
+(fenced_code_block
+ (info_string
+ (language) @injection.language)
+ (code_fence_content) @injection.content (#set! injection.include-unnamed-children))
+
diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm
index e4ae6ab352c1..42ca12b5b8ab 100644
--- a/runtime/queries/rust/injections.scm
+++ b/runtime/queries/rust/injections.scm
@@ -2,7 +2,7 @@
(#set! injection.language "comment"))
((doc_comment) @injection.content
- (#set! injection.language "markdown")
+ (#set! injection.language "markdown-rustdoc")
(#set! injection.combined))
((macro_invocation
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 0d4bc7f8f627..07823b28eeef 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -138,6 +138,7 @@
| make | β | | β | |
| markdoc | β | | | `markdoc-ls` |
| markdown | β | | | `marksman`, `markdown-oxide` |
+| markdown-rustdoc | β | | | |
| markdown.inline | β | | | |
| matlab | β | β | β | |
| mermaid | β | | | |
diff --git a/languages.toml b/languages.toml
index 3e790d76e3eb..3652e17af45e 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1704,6 +1704,15 @@ block-comment-tokens = { start = "<!--", end = "-->" }
name = "markdown"
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-markdown", rev = "62516e8c78380e3b51d5b55727995d2c511436d8", subpath = "tree-sitter-markdown" }
+[[language]]
+name = "markdown-rustdoc"
+scope = "source.markdown-rustdoc"
+grammar = "markdown"
+injection-regex = "markdown-rustdoc"
+file-types = []
+indent = { tab-width = 2, unit = " " }
+block-comment-tokens = { start = "<!--", end = "-->" }
[[language]]
name = "markdown.inline"
scope = "source.markdown.inline"
diff --git a/runtime/queries/markdown-rustdoc/highlights.scm b/runtime/queries/markdown-rustdoc/highlights.scm
index 000000000000..a3a30e342921
+++ b/runtime/queries/markdown-rustdoc/highlights.scm
@@ -0,0 +1 @@
diff --git a/runtime/queries/markdown-rustdoc/injections.scm b/runtime/queries/markdown-rustdoc/injections.scm
index 000000000000..8beba4e237b6
+++ b/runtime/queries/markdown-rustdoc/injections.scm
@@ -0,0 +1,15 @@
+; In Rust, it is common to have documentation code blocks not specify the
+; language, and it is assumed to be Rust if it is not specified.
+ (#set! injection.language "rust")
+ (#set! injection.include-unnamed-children))
+ (info_string
+ (code_fence_content) @injection.content (#set! injection.include-unnamed-children))
+
diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm
index e4ae6ab352c1..42ca12b5b8ab 100644
--- a/runtime/queries/rust/injections.scm
+++ b/runtime/queries/rust/injections.scm
@@ -2,7 +2,7 @@
(#set! injection.language "comment"))
((doc_comment) @injection.content
- (#set! injection.language "markdown")
+ (#set! injection.language "markdown-rustdoc")
(#set! injection.combined))
((macro_invocation | [
"+ (code_fence_content) @injection.content",
"+ (language) @injection.language)"
] | [
51,
57
] | {
"additions": 27,
"author": "nik-rev",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/13116",
"issue_id": 13116,
"merged_at": "2025-03-15T19:27:49Z",
"omission_probability": 0.1,
"pr_number": 13116,
"repo": "helix-editor/helix",
"title": "`tree-house`: Inject `rust` language into documentation comments when the language is not specified",
"total_changes": 28
} |
275 | diff --git a/runtime/queries/ruby/highlights.scm b/runtime/queries/ruby/highlights.scm
index 35babfe32f7f..cd6f1723ea36 100644
--- a/runtime/queries/ruby/highlights.scm
+++ b/runtime/queries/ruby/highlights.scm
@@ -39,19 +39,60 @@
"%i("
] @punctuation.bracket
+; Literals
+
+[
+ (string)
+ (bare_string)
+ (subshell)
+ (heredoc_body)
+ (heredoc_beginning)
+] @string
+
+[
+ (simple_symbol)
+ (delimited_symbol)
+ (bare_symbol)
+] @string.special.symbol
+
+(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
+
+(regex) @string.regexp
+(escape_sequence) @constant.character.escape
+
+[
+ (integer)
+ (float)
+] @constant.numeric.integer
+
+[
+ (nil)
+ (true)
+ (false)
+] @constant.builtin
+
+(interpolation
+ "#{" @punctuation.special
+ "}" @punctuation.special) @embedded
+
+(comment) @comment
+
; Identifiers
+((identifier) @function.method
+ (#is-not? local))
+
[
(identifier)
] @variable
-((identifier) @function.method
- (#is-not? local))
[
(class_variable)
(instance_variable)
] @variable.other.member
+(constant) @constructor
+
((identifier) @constant.builtin
(#match? @constant.builtin "^(__FILE__|__LINE__|__ENCODING__)$"))
@@ -61,8 +102,6 @@
((constant) @constant
(#match? @constant "^[A-Z\\d_]+$"))
-(constant) @constructor
-
(self) @variable.builtin
(super) @function.builtin
@@ -76,6 +115,23 @@
(block_parameter (identifier) @variable.parameter)
(block_parameters (identifier) @variable.parameter)
+; Function definitions
+
+(alias (identifier) @function.method)
+(setter (identifier) @function.method)
+(method name: [(identifier) (constant)] @function.method)
+(singleton_method name: [(identifier) (constant)] @function.method)
+
+; Function calls
+
+(call
+ method: [(identifier) (constant)] @function.method)
+
+((identifier) @function.builtin
+ (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
+
+"defined?" @function.builtin
+
; Keywords
[
@@ -133,58 +189,3 @@
((identifier) @keyword.control.exception
(#match? @keyword.control.exception "^(raise|fail)$"))
-
-; Function calls
-
-((identifier) @function.builtin
- (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
-
-"defined?" @function.builtin
-
-(call
- method: [(identifier) (constant)] @function.method)
-
-; Function definitions
-
-(alias (identifier) @function.method)
-(setter (identifier) @function.method)
-(method name: [(identifier) (constant)] @function.method)
-(singleton_method name: [(identifier) (constant)] @function.method)
-
-; Literals
-
-[
- (string)
- (bare_string)
- (subshell)
- (heredoc_body)
- (heredoc_beginning)
-] @string
-
-[
- (simple_symbol)
- (delimited_symbol)
- (bare_symbol)
-] @string.special.symbol
-
-(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
-
-(regex) @string.regexp
-(escape_sequence) @constant.character.escape
-
-[
- (integer)
- (float)
-] @constant.numeric.integer
-
-[
- (nil)
- (true)
- (false)
-] @constant.builtin
-
-(interpolation
- "#{" @punctuation.special
- "}" @punctuation.special) @embedded
-
-(comment) @comment
| diff --git a/runtime/queries/ruby/highlights.scm b/runtime/queries/ruby/highlights.scm
index 35babfe32f7f..cd6f1723ea36 100644
--- a/runtime/queries/ruby/highlights.scm
+++ b/runtime/queries/ruby/highlights.scm
@@ -39,19 +39,60 @@
"%i("
] @punctuation.bracket
+; Literals
+ (string)
+ (bare_string)
+ (heredoc_body)
+ (heredoc_beginning)
+] @string
+ (simple_symbol)
+ (delimited_symbol)
+ (bare_symbol)
+] @string.special.symbol
+(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
+(regex) @string.regexp
+(escape_sequence) @constant.character.escape
+ (integer)
+ (float)
+ (nil)
+ (true)
+ (false)
+] @constant.builtin
+(interpolation
+ "#{" @punctuation.special
+(comment) @comment
; Identifiers
+((identifier) @function.method
+ (#is-not? local))
(identifier)
] @variable
-((identifier) @function.method
- (#is-not? local))
(class_variable)
(instance_variable)
] @variable.other.member
+(constant) @constructor
((identifier) @constant.builtin
(#match? @constant.builtin "^(__FILE__|__LINE__|__ENCODING__)$"))
@@ -61,8 +102,6 @@
((constant) @constant
(#match? @constant "^[A-Z\\d_]+$"))
(self) @variable.builtin
(super) @function.builtin
@@ -76,6 +115,23 @@
(block_parameter (identifier) @variable.parameter)
(block_parameters (identifier) @variable.parameter)
+; Function definitions
+(alias (identifier) @function.method)
+(setter (identifier) @function.method)
+(method name: [(identifier) (constant)] @function.method)
+(singleton_method name: [(identifier) (constant)] @function.method)
+; Function calls
+(call
+ method: [(identifier) (constant)] @function.method)
+((identifier) @function.builtin
+ (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
+"defined?" @function.builtin
; Keywords
@@ -133,58 +189,3 @@
((identifier) @keyword.control.exception
(#match? @keyword.control.exception "^(raise|fail)$"))
-; Function calls
-((identifier) @function.builtin
- (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
-"defined?" @function.builtin
-(call
- method: [(identifier) (constant)] @function.method)
-; Function definitions
-(alias (identifier) @function.method)
-(setter (identifier) @function.method)
-(method name: [(identifier) (constant)] @function.method)
-(singleton_method name: [(identifier) (constant)] @function.method)
-; Literals
- (string)
- (bare_string)
- (heredoc_beginning)
-] @string
- (simple_symbol)
- (delimited_symbol)
- (bare_symbol)
-] @string.special.symbol
-(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
-(regex) @string.regexp
-(escape_sequence) @constant.character.escape
-] @constant.numeric.integer
- (nil)
- (true)
- (false)
-] @constant.builtin
-(interpolation
- "#{" @punctuation.special
- "}" @punctuation.special) @embedded
-(comment) @comment | [
"+ (subshell)",
"+] @constant.numeric.integer",
"+ \"}\" @punctuation.special) @embedded",
"-(constant) @constructor",
"- (subshell)",
"- (heredoc_body)",
"- (integer)",
"- (float)"
] | [
13,
32,
42,
71,
127,
128,
144,
145
] | {
"additions": 60,
"author": "SadMachinesP86",
"deletions": 59,
"html_url": "https://github.com/helix-editor/helix/pull/13055",
"issue_id": 13055,
"merged_at": "2025-03-13T13:48:14Z",
"omission_probability": 0.1,
"pr_number": 13055,
"repo": "helix-editor/helix",
"title": "Fix Ruby highlights",
"total_changes": 119
} |
276 | diff --git a/languages.toml b/languages.toml
index df69d6f33fcb..3e790d76e3eb 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2414,7 +2414,7 @@ indent = { tab-width = 2, unit = "\t" }
[[grammar]]
name = "openscad"
-source = { git = "https://github.com/bollian/tree-sitter-openscad", rev = "5c3ce93df0ac1da7197cf6ae125aade26d6b8972" }
+source = { git = "https://github.com/openscad/tree-sitter-openscad", rev = "acc196e969a169cadd8b7f8d9f81ff2d30e3e253" }
[[language]]
name = "prisma"
diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm
index 90d5ac59d8c9..a79dc41e69fd 100644
--- a/runtime/queries/openscad/highlights.scm
+++ b/runtime/queries/openscad/highlights.scm
@@ -1,40 +1,68 @@
-(number) @constant.numeric
-(string) @string
-(boolean) @constant.builtin.boolean
+; Includes
+(identifier) @variable
+
+"include" @keyword.control.import
+
(include_path) @string.special.path
-(identifier) @variable
+; Functions
+
+(function_item
+ (identifier) @function
+)
+(function_item
+ parameters: (parameters (parameter (assignment value: (_) @constant)))
+)
+(function_call name: (identifier) @function)
+(function_call
+ arguments: (arguments (assignment name: _ @variable.parameter))
+)
+; for the puroposes of distintion since modules are "coloured" impure functions, we will treat them as methods
+(module_item (identifier) @function.method)
+(module_item
+ parameters: (parameters (parameter (assignment value: (_) @constant)))
+)
+(module_call name: (identifier) @function.method)
+(module_call
+ arguments: (arguments (assignment name: _ @variable.parameter))
+)
-(parameters_declaration (identifier) @variable.parameter)
-(function_declaration name: (identifier) @function)
+; assertion statements/expression arguments behave similar to function calls
+(assert_expression
+ arguments: (arguments (assignment name: _ @variable.parameter))
+)
+(assert_statement
+ arguments: (arguments (assignment name: _ @variable.parameter))
+)
-(function_call function: (identifier) @function)
-(module_call name: (identifier) @function)
+(echo_expression
+ arguments: (arguments (assignment name: _ @variable.parameter))
+)
+(echo_expression "echo" @function.builtin)
+; Variables
+(parameter
+ [_ @variable.parameter (assignment name: _ @variable.parameter)]
+)
(special_variable) @variable.builtin
+(undef) @constant.builtin
+
+; Types/Properties/
+(dot_index_expression index: (_) @variable.other.member)
+; Keywords
[
+ "module"
"function"
"let"
"assign"
-] @keyword
-
-[
- "for"
- "each"
- "intersection_for"
-] @keyword.control.repeat
-
-[
- "if"
-] @keyword.control.conditional
-
-[
- "module"
"use"
- "include"
-] @keyword.control.import
+ "each"
+ (assert_statement "assert")
+ (assert_expression "assert")
+] @keyword
+; Operators
[
"||"
"&&"
@@ -50,15 +78,87 @@
"/"
"%"
"^"
- "?"
"!"
":"
+ "="
] @operator
+; Builtin modules
+(module_call
+ name: (identifier) @function.builtin
+ (#any-of? @function.builtin
+ "circle"
+ "color"
+ "cube"
+ "cylinder"
+ "difference"
+ "hull"
+ "intersection"
+ "linear_extrude"
+ "minkowski"
+ "mirror"
+ "multmatrix"
+ "offset"
+ "polygon"
+ "polyhedron"
+ "projection"
+ "resize"
+ "rotate"
+ "rotate_extrude"
+ "scale"
+ "sphere"
+ "square"
+ "surface"
+ "text"
+ "translate"
+ "union"
+ "echo"
+ )
+)
+(
+ (identifier) @identifier
+ (#eq? @identifier "PI")
+) @constant.builtin
+
+; Conditionals
+[
+ "if"
+ "else"
+] @keyword.control.conditional
+(ternary_expression
+ ["?" ":"] @keyword.control.conditional
+)
+
+; Repeats
+[
+ "for"
+ "intersection_for"
+] @keyword.control.repeat
+
+; Literals
+(integer) @constant.numeric.integer
+(float) @constant.numeric.float
+(string) @string
+(escape_sequence) @constant.character.escape
+(boolean) @constant.builtin.boolean
+
+; Misc
+(modifier
+ [
+ "*"
+ "!"
+ "#"
+ "%"
+ ] @keyword.storage.modifier
+)
+["{" "}"] @punctuation.bracket
+["(" ")"] @punctuation.bracket
+["[" "]"] @punctuation.bracket
[
";"
","
"."
] @punctuation.delimiter
-(comment) @comment
+; Comments
+[(line_comment) (block_comment)] @comment
| diff --git a/languages.toml b/languages.toml
index df69d6f33fcb..3e790d76e3eb 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2414,7 +2414,7 @@ indent = { tab-width = 2, unit = "\t" }
[[grammar]]
name = "openscad"
+source = { git = "https://github.com/openscad/tree-sitter-openscad", rev = "acc196e969a169cadd8b7f8d9f81ff2d30e3e253" }
[[language]]
name = "prisma"
diff --git a/runtime/queries/openscad/highlights.scm b/runtime/queries/openscad/highlights.scm
index 90d5ac59d8c9..a79dc41e69fd 100644
--- a/runtime/queries/openscad/highlights.scm
+++ b/runtime/queries/openscad/highlights.scm
@@ -1,40 +1,68 @@
-(number) @constant.numeric
-(string) @string
-(boolean) @constant.builtin.boolean
+; Includes
+(identifier) @variable
+"include" @keyword.control.import
(include_path) @string.special.path
-(identifier) @variable
+; Functions
+ (identifier) @function
+(function_call name: (identifier) @function)
+(function_call
+; for the puroposes of distintion since modules are "coloured" impure functions, we will treat them as methods
+(module_item
+(module_call name: (identifier) @function.method)
-(parameters_declaration (identifier) @variable.parameter)
+; assertion statements/expression arguments behave similar to function calls
+(assert_expression
-(function_call function: (identifier) @function)
-(module_call name: (identifier) @function)
+(echo_expression
+(echo_expression "echo" @function.builtin)
+; Variables
+(parameter
+ [_ @variable.parameter (assignment name: _ @variable.parameter)]
(special_variable) @variable.builtin
+(undef) @constant.builtin
+; Types/Properties/
+(dot_index_expression index: (_) @variable.other.member)
+; Keywords
"function"
"let"
"assign"
-] @keyword
- "for"
- "intersection_for"
-] @keyword.control.repeat
- "if"
-] @keyword.control.conditional
"use"
-] @keyword.control.import
+ "each"
+ (assert_statement "assert")
+ (assert_expression "assert")
+] @keyword
"||"
"&&"
@@ -50,15 +78,87 @@
"/"
"%"
"^"
- "?"
"!"
":"
+ "="
] @operator
+; Builtin modules
+ name: (identifier) @function.builtin
+ (#any-of? @function.builtin
+ "circle"
+ "cube"
+ "cylinder"
+ "difference"
+ "hull"
+ "intersection"
+ "linear_extrude"
+ "minkowski"
+ "mirror"
+ "offset"
+ "polygon"
+ "polyhedron"
+ "projection"
+ "resize"
+ "rotate"
+ "rotate_extrude"
+ "scale"
+ "sphere"
+ "square"
+ "text"
+ "translate"
+ "union"
+ "echo"
+ )
+(
+ (identifier) @identifier
+ (#eq? @identifier "PI")
+) @constant.builtin
+; Conditionals
+ "if"
+ "else"
+(ternary_expression
+ ["?" ":"] @keyword.control.conditional
+; Repeats
+ "for"
+ "intersection_for"
+] @keyword.control.repeat
+; Literals
+(integer) @constant.numeric.integer
+(float) @constant.numeric.float
+(string) @string
+(escape_sequence) @constant.character.escape
+(boolean) @constant.builtin.boolean
+(modifier
+ [
+ "*"
+ "!"
+ "#"
+ "%"
+ ] @keyword.storage.modifier
+["{" "}"] @punctuation.bracket
+["[" "]"] @punctuation.bracket
";"
","
"."
] @punctuation.delimiter
-(comment) @comment
+; Comments
+[(line_comment) (block_comment)] @comment | [
"-source = { git = \"https://github.com/bollian/tree-sitter-openscad\", rev = \"5c3ce93df0ac1da7197cf6ae125aade26d6b8972\" }",
"+(module_item (identifier) @function.method)",
"-(function_declaration name: (identifier) @function)",
"+(assert_statement",
"+ \"module\"",
"- \"each\"",
"- \"module\"",
"- \"include\"",
"+; Operators",
"+ \"color\"",
"+ \"multmatrix\"",
"+ \"surface\"",
"+] @keyword.control.conditional",
"+; Misc",
"+[\"(\" \")\"] @punctuation.bracket"
] | [
8,
42,
52,
57,
80,
88,
97,
99,
106,
125,
134,
145,
161,
179,
189
] | {
"additions": 127,
"author": "mkatychev",
"deletions": 27,
"html_url": "https://github.com/helix-editor/helix/pull/13033",
"issue_id": 13033,
"merged_at": "2025-03-12T21:10:38Z",
"omission_probability": 0.1,
"pr_number": 13033,
"repo": "helix-editor/helix",
"title": "chore: Point OpenSCAD grammar to official repo",
"total_changes": 154
} |
277 | diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 7f491309828c..cb270b86e3c3 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -441,7 +441,17 @@ impl Application {
e
})
.ok()
- .filter(|theme| (true_color || theme.is_16_color()))
+ .filter(|theme| {
+ let colors_ok = true_color || theme.is_16_color();
+ if !colors_ok {
+ log::warn!(
+ "loaded theme `{}` but cannot use it because true color \
+ support is not enabled",
+ theme.name()
+ );
+ }
+ colors_ok
+ })
})
.unwrap_or_else(|| editor.theme_loader.default_theme(true_color));
editor.set_theme(theme);
| diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 7f491309828c..cb270b86e3c3 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -441,7 +441,17 @@ impl Application {
e
})
.ok()
- .filter(|theme| (true_color || theme.is_16_color()))
+ .filter(|theme| {
+ let colors_ok = true_color || theme.is_16_color();
+ if !colors_ok {
+ log::warn!(
+ "loaded theme `{}` but cannot use it because true color \
+ support is not enabled",
+ theme.name()
+ }
+ colors_ok
})
.unwrap_or_else(|| editor.theme_loader.default_theme(true_color));
editor.set_theme(theme); | [
"+ );",
"+ })"
] | [
16,
19
] | {
"additions": 11,
"author": "iximeow",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/13058",
"issue_id": 13058,
"merged_at": "2025-03-12T20:52:08Z",
"omission_probability": 0.1,
"pr_number": 13058,
"repo": "helix-editor/helix",
"title": "warn when configured theme is unusable for color reasons",
"total_changes": 12
} |
278 | diff --git a/runtime/themes/sunset.toml b/runtime/themes/sunset.toml
index ec3aca8f5d46..d417bb402116 100644
--- a/runtime/themes/sunset.toml
+++ b/runtime/themes/sunset.toml
@@ -4,21 +4,20 @@
# Syntax highlighting
# ----------------------------------------------------------------
-attribute = "rose"
+attribute = "mud"
-type = "rose"
-"type.builtin" = { fg = "rose", modifiers = ["italic"] }
+type = "mud"
+"type.builtin" = { fg = "mud", modifiers = ["italic"] }
constructor = "wood"
constant = "fire"
"constant.builtin" = { fg = "fire", modifiers = ["italic"] }
"constant.character" = "wood"
-"constant.character.escape" = "pink"
"constant.numeric" = "wood"
string = "grass"
-"string.regexp" = "pink"
+"string.regexp" = "mud"
"string.special" = "rose"
"string.special.symbol" = "fire"
@@ -26,9 +25,9 @@ comment = { fg = "cmnt", modifiers = ["italic"] }
"comment.block.documentation" = "grass"
variable = "text"
-"variable.builtin" = { fg = "sky", modifiers = ["italic"] }
-# TODO: variable.parameter
-"variable.other.member" = "mud"
+"variable.builtin" = { fg = "sky", modifiers = ["italic"] }
+"variable.parameter" = "rose"
+"variable.other.member" = "pink"
label = "sky"
@@ -44,23 +43,23 @@ operator = "wine"
function = "peach"
"function.builtin" = { fg = "peach", modifiers = ["italic"] }
-"function.macro" = "pink"
+"function.macro" = "sky"
tag = "peach"
-namespace = { fg = "pink", modifiers = ["italic"] }
+namespace = { fg = "text", modifiers = ["italic"] }
-special = "sky"
+special = "wine"
# Editor interface
# ----------------------------------------------------------------
"markup.heading.marker" = "sun"
-"markup.heading.1" = "attn"
-"markup.heading.2" = "fire"
+"markup.heading.1" = "fire"
+"markup.heading.2" = "wine"
"markup.heading.3" = "rose"
"markup.heading.4" = "peach"
-"markup.heading.5" = "wine"
-"markup.heading.6" = "grass"
+"markup.heading.5" = "grass"
+"markup.heading.6" = "wood"
"markup.list" = "wood"
@@ -69,12 +68,12 @@ special = "sky"
"markup.strikethrough" = { modifiers = ["crossed_out"] }
"markup.link.url" = { fg = "sky", underline.style = "line" }
-"markup.link.label" = { fg = "sky", modifiers = ["italic"] }
+"markup.link.label" = "sky"
"markup.link.text" = "mud"
-"markup.quote" = "grass"
+"markup.quote" = "mud"
-"markup.raw" = "pink"
+"markup.raw" = "pink"
"diff.plus" = "grass"
"diff.minus" = "attn"
@@ -84,7 +83,10 @@ special = "sky"
# ----------------------------------------------------------------
"ui.background" = { fg = "text", bg = "base" }
-"ui.cursor" = { modifiers = ["reversed"] }
+"ui.cursor" = { fg = "base", bg = "cmnt" }
+"ui.cursor.primary.normal" = { fg = "base", bg = "text" }
+"ui.cursor.primary.insert" = { fg = "base", bg = "grass" }
+"ui.cursor.primary.select" = { fg = "base", bg = "sky" }
"ui.cursor.match" = { fg = "attn", modifiers = ["bold"] }
# TODO: ui.debug
@@ -94,34 +96,35 @@ special = "sky"
"ui.statusline" = { bg = "block" }
"ui.statusline.inactive" = { fg = "cmnt" }
-"ui.statusline.normal" = { fg = "block", bg = "sun", modifiers = ["bold"] }
+"ui.statusline.normal" = { fg = "block", bg = "text", modifiers = ["bold"] }
"ui.statusline.insert" = { fg = "block", bg = "grass", modifiers = ["bold"] }
-"ui.statusline.select" = { fg = "block", bg = "wine", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "block", bg = "sky", modifiers = ["bold"] }
"ui.bufferline" = { fg = "cmnt", bg = "block" }
-"ui.bufferline.active" = "sun"
+"ui.bufferline.active" = "fire"
"ui.popup" = { fg = "text", bg = "base" }
"ui.popup.info" = { fg = "text", bg = "block" }
+"ui.picker.header" = { underline.style = "line" }
+
"ui.window" = { fg = "block", modifiers = ["bold"] }
"ui.help" = { fg = "text", bg = "block" }
-"ui.text" = { fg = "text", bg = "base" }
-"ui.text.directory" = "sky"
+"ui.text" = "text"
"ui.text.focus" = "sun"
"ui.text.inactive" = { fg = "cmnt", modifiers = ["italic"] }
"ui.text.info" = { bg = "block" }
+"ui.text.directory" = "sky"
"ui.virtual" = { fg = "block" }
"ui.virtual.ruler" = { bg = "block" }
-"ui.virtual.indent-guide" = "sel"
"ui.virtual.jump-label" = { fg = "attn", modifiers = ["bold"] }
"ui.menu" = { fg = "text", bg = "base" }
"ui.menu.selected" = { bg = "sel" }
-"ui.menu.scroll" = "sel"
+"ui.menu.scroll" = "block"
"ui.selection" = { bg = "sel" }
@@ -129,8 +132,8 @@ special = "sky"
error = "attn"
warning = "fire"
-info = "pink"
-hint = "sky"
+info = "sky"
+hint = "mud"
diagnostic = { underline.style = "line" }
@@ -144,12 +147,12 @@ wood = "#997755"
# Greenish
grass = "#66CC33"
-mud = "#BBCC77"
+mud = "#AACC77"
sun = "#EEEE11"
# Bluish
-sky = "#77AAAA"
-wine = "#775599"
+sky = "#77AAAA"
+wine = "#775599"
# Ui
base = "#111111"
| diff --git a/runtime/themes/sunset.toml b/runtime/themes/sunset.toml
index ec3aca8f5d46..d417bb402116 100644
--- a/runtime/themes/sunset.toml
+++ b/runtime/themes/sunset.toml
@@ -4,21 +4,20 @@
# Syntax highlighting
-attribute = "rose"
+attribute = "mud"
-type = "rose"
+type = "mud"
+"type.builtin" = { fg = "mud", modifiers = ["italic"] }
constructor = "wood"
constant = "fire"
"constant.builtin" = { fg = "fire", modifiers = ["italic"] }
"constant.character" = "wood"
"constant.numeric" = "wood"
string = "grass"
-"string.regexp" = "pink"
+"string.regexp" = "mud"
"string.special" = "rose"
"string.special.symbol" = "fire"
@@ -26,9 +25,9 @@ comment = { fg = "cmnt", modifiers = ["italic"] }
"comment.block.documentation" = "grass"
variable = "text"
-"variable.builtin" = { fg = "sky", modifiers = ["italic"] }
-# TODO: variable.parameter
-"variable.other.member" = "mud"
+"variable.builtin" = { fg = "sky", modifiers = ["italic"] }
+"variable.parameter" = "rose"
+"variable.other.member" = "pink"
label = "sky"
@@ -44,23 +43,23 @@ operator = "wine"
function = "peach"
"function.builtin" = { fg = "peach", modifiers = ["italic"] }
-"function.macro" = "pink"
+"function.macro" = "sky"
tag = "peach"
-namespace = { fg = "pink", modifiers = ["italic"] }
+namespace = { fg = "text", modifiers = ["italic"] }
-special = "sky"
+special = "wine"
# Editor interface
"markup.heading.marker" = "sun"
-"markup.heading.1" = "attn"
-"markup.heading.2" = "fire"
+"markup.heading.1" = "fire"
"markup.heading.3" = "rose"
"markup.heading.4" = "peach"
-"markup.heading.5" = "wine"
-"markup.heading.6" = "grass"
+"markup.heading.5" = "grass"
+"markup.heading.6" = "wood"
"markup.list" = "wood"
@@ -69,12 +68,12 @@ special = "sky"
"markup.strikethrough" = { modifiers = ["crossed_out"] }
"markup.link.url" = { fg = "sky", underline.style = "line" }
"markup.link.text" = "mud"
-"markup.quote" = "grass"
+"markup.quote" = "mud"
-"markup.raw" = "pink"
+"markup.raw" = "pink"
"diff.plus" = "grass"
"diff.minus" = "attn"
@@ -84,7 +83,10 @@ special = "sky"
"ui.background" = { fg = "text", bg = "base" }
-"ui.cursor" = { modifiers = ["reversed"] }
+"ui.cursor.primary.normal" = { fg = "base", bg = "text" }
+"ui.cursor.primary.insert" = { fg = "base", bg = "grass" }
+"ui.cursor.primary.select" = { fg = "base", bg = "sky" }
"ui.cursor.match" = { fg = "attn", modifiers = ["bold"] }
# TODO: ui.debug
@@ -94,34 +96,35 @@ special = "sky"
"ui.statusline" = { bg = "block" }
"ui.statusline.inactive" = { fg = "cmnt" }
-"ui.statusline.normal" = { fg = "block", bg = "sun", modifiers = ["bold"] }
+"ui.statusline.normal" = { fg = "block", bg = "text", modifiers = ["bold"] }
"ui.statusline.insert" = { fg = "block", bg = "grass", modifiers = ["bold"] }
+"ui.statusline.select" = { fg = "block", bg = "sky", modifiers = ["bold"] }
"ui.bufferline" = { fg = "cmnt", bg = "block" }
-"ui.bufferline.active" = "sun"
+"ui.bufferline.active" = "fire"
"ui.popup" = { fg = "text", bg = "base" }
"ui.popup.info" = { fg = "text", bg = "block" }
+"ui.picker.header" = { underline.style = "line" }
+
"ui.window" = { fg = "block", modifiers = ["bold"] }
"ui.help" = { fg = "text", bg = "block" }
-"ui.text" = { fg = "text", bg = "base" }
-"ui.text.directory" = "sky"
+"ui.text" = "text"
"ui.text.focus" = "sun"
"ui.text.inactive" = { fg = "cmnt", modifiers = ["italic"] }
"ui.text.info" = { bg = "block" }
+"ui.text.directory" = "sky"
"ui.virtual" = { fg = "block" }
"ui.virtual.ruler" = { bg = "block" }
"ui.virtual.jump-label" = { fg = "attn", modifiers = ["bold"] }
"ui.menu" = { fg = "text", bg = "base" }
"ui.menu.selected" = { bg = "sel" }
-"ui.menu.scroll" = "sel"
+"ui.menu.scroll" = "block"
"ui.selection" = { bg = "sel" }
@@ -129,8 +132,8 @@ special = "sky"
error = "attn"
warning = "fire"
-info = "pink"
-hint = "sky"
+info = "sky"
+hint = "mud"
diagnostic = { underline.style = "line" }
@@ -144,12 +147,12 @@ wood = "#997755"
# Greenish
grass = "#66CC33"
-mud = "#BBCC77"
+mud = "#AACC77"
sun = "#EEEE11"
# Bluish
-sky = "#77AAAA"
-wine = "#775599"
+sky = "#77AAAA"
+wine = "#775599"
# Ui
base = "#111111" | [
"-\"type.builtin\" = { fg = \"rose\", modifiers = [\"italic\"] }",
"-\"constant.character.escape\" = \"pink\"",
"+\"markup.heading.2\" = \"wine\"",
"-\"markup.link.label\" = { fg = \"sky\", modifiers = [\"italic\"] }",
"+\"markup.link.label\" = \"sky\"",
"+\"ui.cursor\" = { fg = \"base\", bg = \"cmnt\" }",
"-\"ui.statusline.select\" = { fg = \"block\", bg = \"wine\", modifiers = [\"bold\"] }",
"-\"ui.virtual.indent-guide\" = \"sel\""
] | [
12,
21,
64,
78,
79,
95,
109,
135
] | {
"additions": 34,
"author": "pithecantrope",
"deletions": 31,
"html_url": "https://github.com/helix-editor/helix/pull/13086",
"issue_id": 13086,
"merged_at": "2025-03-12T14:39:56Z",
"omission_probability": 0.1,
"pr_number": 13086,
"repo": "helix-editor/helix",
"title": "Sunset theme: version 2.0",
"total_changes": 65
} |
279 | diff --git a/Cargo.lock b/Cargo.lock
index 2a11634eac0a..5f8204c2cbe7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1449,7 +1449,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
- "rustix 0.38.44",
+ "rustix 1.0.2",
"tempfile",
"unicode-segmentation",
"which",
@@ -1556,7 +1556,7 @@ dependencies = [
"log",
"once_cell",
"parking_lot",
- "rustix 0.38.44",
+ "rustix 1.0.2",
"serde",
"serde_json",
"slotmap",
diff --git a/helix-stdx/Cargo.toml b/helix-stdx/Cargo.toml
index 0ce6d2493fc6..a41dee83989d 100644
--- a/helix-stdx/Cargo.toml
+++ b/helix-stdx/Cargo.toml
@@ -26,7 +26,7 @@ unicode-segmentation.workspace = true
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Security", "Win32_Security_Authorization", "Win32_Storage_FileSystem", "Win32_System_Threading"] }
[target.'cfg(unix)'.dependencies]
-rustix = { version = "0.38", features = ["fs"] }
+rustix = { version = "1.0", features = ["fs"] }
[dev-dependencies]
tempfile.workspace = true
diff --git a/helix-stdx/src/faccess.rs b/helix-stdx/src/faccess.rs
index e4c3daf258ef..80b668b144a3 100644
--- a/helix-stdx/src/faccess.rs
+++ b/helix-stdx/src/faccess.rs
@@ -51,8 +51,8 @@ mod imp {
}
fn chown(p: &Path, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
- let uid = uid.map(|n| unsafe { rustix::fs::Uid::from_raw(n) });
- let gid = gid.map(|n| unsafe { rustix::fs::Gid::from_raw(n) });
+ let uid = uid.map(rustix::fs::Uid::from_raw);
+ let gid = gid.map(rustix::fs::Gid::from_raw);
rustix::fs::chown(p, uid, gid)?;
Ok(())
}
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index 34ceeb91c710..ab5dcd07d774 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -57,7 +57,7 @@ clipboard-win = { version = "5.4", features = ["std"] }
[target.'cfg(unix)'.dependencies]
libc = "0.2"
-rustix = { version = "0.38", features = ["fs"] }
+rustix = { version = "1.0", features = ["fs"] }
[dev-dependencies]
helix-tui = { path = "../helix-tui" }
| diff --git a/Cargo.lock b/Cargo.lock
index 2a11634eac0a..5f8204c2cbe7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1449,7 +1449,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
"tempfile",
"unicode-segmentation",
"which",
@@ -1556,7 +1556,7 @@ dependencies = [
"log",
"once_cell",
"parking_lot",
"serde",
"serde_json",
"slotmap",
diff --git a/helix-stdx/Cargo.toml b/helix-stdx/Cargo.toml
index 0ce6d2493fc6..a41dee83989d 100644
--- a/helix-stdx/Cargo.toml
+++ b/helix-stdx/Cargo.toml
@@ -26,7 +26,7 @@ unicode-segmentation.workspace = true
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Security", "Win32_Security_Authorization", "Win32_Storage_FileSystem", "Win32_System_Threading"] }
tempfile.workspace = true
diff --git a/helix-stdx/src/faccess.rs b/helix-stdx/src/faccess.rs
index e4c3daf258ef..80b668b144a3 100644
--- a/helix-stdx/src/faccess.rs
+++ b/helix-stdx/src/faccess.rs
@@ -51,8 +51,8 @@ mod imp {
fn chown(p: &Path, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
- let uid = uid.map(|n| unsafe { rustix::fs::Uid::from_raw(n) });
+ let uid = uid.map(rustix::fs::Uid::from_raw);
+ let gid = gid.map(rustix::fs::Gid::from_raw);
rustix::fs::chown(p, uid, gid)?;
Ok(())
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index 34ceeb91c710..ab5dcd07d774 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -57,7 +57,7 @@ clipboard-win = { version = "5.4", features = ["std"] }
libc = "0.2"
helix-tui = { path = "../helix-tui" } | [
"- let gid = gid.map(|n| unsafe { rustix::fs::Gid::from_raw(n) });"
] | [
44
] | {
"additions": 6,
"author": "dependabot[bot]",
"deletions": 6,
"html_url": "https://github.com/helix-editor/helix/pull/13071",
"issue_id": 13071,
"merged_at": "2025-03-11T14:34:08Z",
"omission_probability": 0.1,
"pr_number": 13071,
"repo": "helix-editor/helix",
"title": "build(deps): bump rustix from 0.38.44 to 1.0.2",
"total_changes": 12
} |
280 | diff --git a/Cargo.lock b/Cargo.lock
index e731eeafb90d..2a11634eac0a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -249,7 +249,7 @@ dependencies = [
"libc",
"mio",
"parking_lot",
- "rustix",
+ "rustix 0.38.44",
"signal-hook",
"signal-hook-mio",
"winapi",
@@ -852,7 +852,7 @@ dependencies = [
"itoa",
"libc",
"memmap2",
- "rustix",
+ "rustix 0.38.44",
"smallvec",
"thiserror 2.0.12",
]
@@ -1449,7 +1449,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
- "rustix",
+ "rustix 0.38.44",
"tempfile",
"unicode-segmentation",
"which",
@@ -1556,7 +1556,7 @@ dependencies = [
"log",
"once_cell",
"parking_lot",
- "rustix",
+ "rustix 0.38.44",
"serde",
"serde_json",
"slotmap",
@@ -1772,9 +1772,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "2.7.1"
+version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
+checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
@@ -1887,6 +1887,12 @@ version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+[[package]]
+name = "linux-raw-sys"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9"
+
[[package]]
name = "litemap"
version = "0.7.3"
@@ -2017,9 +2023,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.20.3"
+version = "1.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
+checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad"
[[package]]
name = "open"
@@ -2247,7 +2253,20 @@ dependencies = [
"bitflags",
"errno",
"libc",
- "linux-raw-sys",
+ "linux-raw-sys 0.4.14",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "rustix"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.9.2",
"windows-sys 0.59.0",
]
@@ -2274,18 +2293,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
-version = "1.0.218"
+version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.218"
+version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
@@ -2466,15 +2485,15 @@ dependencies = [
[[package]]
name = "tempfile"
-version = "3.17.1"
+version = "3.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230"
+checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567"
dependencies = [
"cfg-if",
"fastrand",
"getrandom 0.3.1",
"once_cell",
- "rustix",
+ "rustix 1.0.2",
"windows-sys 0.59.0",
]
@@ -2574,9 +2593,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.43.0"
+version = "1.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
+checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a"
dependencies = [
"backtrace",
"bytes",
@@ -2834,7 +2853,7 @@ checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
dependencies = [
"either",
"env_home",
- "rustix",
+ "rustix 0.38.44",
"winsafe",
]
diff --git a/Cargo.toml b/Cargo.toml
index 2e90a1ccd9f9..58e22e532478 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.17.1"
+tempfile = "3.18.0"
bitflags = "2.9"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index da17c4dbb10e..c5f983236cbf 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -33,7 +33,7 @@ unicode-width = "=0.1.12"
unicode-general-category = "1.0"
slotmap.workspace = true
tree-sitter.workspace = true
-once_cell = "1.20"
+once_cell = "1.21"
arc-swap = "1"
regex = "1"
bitflags.workspace = true
diff --git a/helix-event/Cargo.toml b/helix-event/Cargo.toml
index c6ab11c6b657..5d3eeabc9608 100644
--- a/helix-event/Cargo.toml
+++ b/helix-event/Cargo.toml
@@ -19,7 +19,7 @@ tokio = { version = "1", features = ["rt", "rt-multi-thread", "time", "sync", "p
# setup new events on initialization, hardware-lock-elision hugely benefits this case
# as it essentially makes the lock entirely free as long as there is no writes
parking_lot = { version = "0.12", features = ["hardware-lock-elision"] }
-once_cell = "1.20"
+once_cell = "1.21"
anyhow = "1"
log = "0.4"
diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml
index 81a4e220fe81..493d8b30ec0c 100644
--- a/helix-loader/Cargo.toml
+++ b/helix-loader/Cargo.toml
@@ -22,7 +22,7 @@ serde = { version = "1.0", features = ["derive"] }
toml = "0.8"
etcetera = "0.10"
tree-sitter.workspace = true
-once_cell = "1.20"
+once_cell = "1.21"
log = "0.4"
# TODO: these two should be on !wasm32 only
diff --git a/helix-lsp-types/Cargo.toml b/helix-lsp-types/Cargo.toml
index 89ff8505396a..b7033d154a32 100644
--- a/helix-lsp-types/Cargo.toml
+++ b/helix-lsp-types/Cargo.toml
@@ -22,7 +22,7 @@ license = "MIT"
[dependencies]
bitflags.workspace = true
-serde = { version = "1.0.218", features = ["derive"] }
+serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
url = {version = "2.5.4", features = ["serde"]}
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml
index 54b0e64fa897..61bf2a2f79ca 100644
--- a/helix-lsp/Cargo.toml
+++ b/helix-lsp/Cargo.toml
@@ -25,7 +25,7 @@ globset = "0.4.16"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
-tokio = { version = "1.43", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
+tokio = { version = "1.44", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
tokio-stream = "0.1.17"
parking_lot = "0.12.3"
arc-swap = "1"
diff --git a/helix-stdx/Cargo.toml b/helix-stdx/Cargo.toml
index 32bdcd4c8b9f..0ce6d2493fc6 100644
--- a/helix-stdx/Cargo.toml
+++ b/helix-stdx/Cargo.toml
@@ -18,7 +18,7 @@ ropey.workspace = true
which = "7.0"
regex-cursor = "0.1.5"
bitflags.workspace = true
-once_cell = "1.20"
+once_cell = "1.21"
regex-automata = "0.4.9"
unicode-segmentation.workspace = true
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 37cb35fab462..7f7ffb6a1d44 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -51,7 +51,7 @@ helix-vcs = { path = "../helix-vcs" }
helix-loader = { path = "../helix-loader" }
anyhow = "1"
-once_cell = "1.20"
+once_cell = "1.21"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
@@ -61,7 +61,7 @@ tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
arc-swap = { version = "1.7.1" }
termini = "1"
-indexmap = "2.7"
+indexmap = "2.8"
# Logging
fern = "0.7"
diff --git a/helix-tui/Cargo.toml b/helix-tui/Cargo.toml
index 92d852518588..2b5767a58b57 100644
--- a/helix-tui/Cargo.toml
+++ b/helix-tui/Cargo.toml
@@ -23,5 +23,5 @@ cassowary = "0.3"
unicode-segmentation.workspace = true
crossterm = { version = "0.28", optional = true }
termini = "1.0"
-once_cell = "1.20"
+once_cell = "1.21"
log = "~0.4"
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index da9f52a21eba..34ceeb91c710 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -31,7 +31,7 @@ crossterm = { version = "0.28", optional = true }
tempfile.workspace = true
# Conversion traits
-once_cell = "1.20"
+once_cell = "1.21"
url = "2.5.4"
arc-swap = { version = "1.7.1" }
| diff --git a/Cargo.lock b/Cargo.lock
index e731eeafb90d..2a11634eac0a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -249,7 +249,7 @@ dependencies = [
"mio",
"signal-hook",
"signal-hook-mio",
"winapi",
@@ -852,7 +852,7 @@ dependencies = [
"itoa",
"memmap2",
"smallvec",
"thiserror 2.0.12",
@@ -1449,7 +1449,7 @@ dependencies = [
"regex-automata",
"regex-cursor",
"ropey",
"tempfile",
"unicode-segmentation",
"which",
@@ -1556,7 +1556,7 @@ dependencies = [
"log",
"serde",
"serde_json",
"slotmap",
@@ -1772,9 +1772,9 @@ dependencies = [
name = "indexmap"
-version = "2.7.1"
+version = "2.8.0"
-checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
+checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058"
"equivalent",
"hashbrown 0.15.2",
@@ -1887,6 +1887,12 @@ version = "0.4.14"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+name = "linux-raw-sys"
+version = "0.9.2"
+checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9"
name = "litemap"
version = "0.7.3"
@@ -2017,9 +2023,9 @@ dependencies = [
name = "once_cell"
-version = "1.20.3"
+version = "1.21.0"
-checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
+checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad"
name = "open"
@@ -2247,7 +2253,20 @@ dependencies = [
"bitflags",
"errno",
- "linux-raw-sys",
+ "windows-sys 0.59.0",
+name = "rustix"
+version = "1.0.2"
+dependencies = [
+ "bitflags",
+ "errno",
@@ -2274,18 +2293,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
name = "serde"
-checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
+checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
"serde_derive",
name = "serde_derive"
-checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
+checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
"proc-macro2",
"quote",
@@ -2466,15 +2485,15 @@ dependencies = [
name = "tempfile"
-version = "3.17.1"
+version = "3.18.0"
-checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230"
+checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567"
"cfg-if",
"fastrand",
"getrandom 0.3.1",
+ "rustix 1.0.2",
@@ -2574,9 +2593,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
name = "tokio"
-version = "1.43.0"
+version = "1.44.0"
-checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
+checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a"
"backtrace",
"bytes",
@@ -2834,7 +2853,7 @@ checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
"either",
"env_home",
"winsafe",
diff --git a/Cargo.toml b/Cargo.toml
index 2e90a1ccd9f9..58e22e532478 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.17.1"
+tempfile = "3.18.0"
bitflags = "2.9"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index da17c4dbb10e..c5f983236cbf 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -33,7 +33,7 @@ unicode-width = "=0.1.12"
unicode-general-category = "1.0"
slotmap.workspace = true
regex = "1"
diff --git a/helix-event/Cargo.toml b/helix-event/Cargo.toml
index c6ab11c6b657..5d3eeabc9608 100644
--- a/helix-event/Cargo.toml
+++ b/helix-event/Cargo.toml
@@ -19,7 +19,7 @@ tokio = { version = "1", features = ["rt", "rt-multi-thread", "time", "sync", "p
# setup new events on initialization, hardware-lock-elision hugely benefits this case
# as it essentially makes the lock entirely free as long as there is no writes
parking_lot = { version = "0.12", features = ["hardware-lock-elision"] }
diff --git a/helix-loader/Cargo.toml b/helix-loader/Cargo.toml
index 81a4e220fe81..493d8b30ec0c 100644
--- a/helix-loader/Cargo.toml
+++ b/helix-loader/Cargo.toml
@@ -22,7 +22,7 @@ serde = { version = "1.0", features = ["derive"] }
toml = "0.8"
etcetera = "0.10"
# TODO: these two should be on !wasm32 only
diff --git a/helix-lsp-types/Cargo.toml b/helix-lsp-types/Cargo.toml
index 89ff8505396a..b7033d154a32 100644
--- a/helix-lsp-types/Cargo.toml
+++ b/helix-lsp-types/Cargo.toml
@@ -22,7 +22,7 @@ license = "MIT"
[dependencies]
+serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
url = {version = "2.5.4", features = ["serde"]}
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml
index 54b0e64fa897..61bf2a2f79ca 100644
--- a/helix-lsp/Cargo.toml
+++ b/helix-lsp/Cargo.toml
@@ -25,7 +25,7 @@ globset = "0.4.16"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
-tokio = { version = "1.43", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
+tokio = { version = "1.44", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
tokio-stream = "0.1.17"
parking_lot = "0.12.3"
diff --git a/helix-stdx/Cargo.toml b/helix-stdx/Cargo.toml
index 32bdcd4c8b9f..0ce6d2493fc6 100644
--- a/helix-stdx/Cargo.toml
+++ b/helix-stdx/Cargo.toml
@@ -18,7 +18,7 @@ ropey.workspace = true
which = "7.0"
regex-cursor = "0.1.5"
regex-automata = "0.4.9"
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 37cb35fab462..7f7ffb6a1d44 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -51,7 +51,7 @@ helix-vcs = { path = "../helix-vcs" }
helix-loader = { path = "../helix-loader" }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
@@ -61,7 +61,7 @@ tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
termini = "1"
-indexmap = "2.7"
+indexmap = "2.8"
# Logging
fern = "0.7"
diff --git a/helix-tui/Cargo.toml b/helix-tui/Cargo.toml
index 92d852518588..2b5767a58b57 100644
--- a/helix-tui/Cargo.toml
+++ b/helix-tui/Cargo.toml
@@ -23,5 +23,5 @@ cassowary = "0.3"
crossterm = { version = "0.28", optional = true }
termini = "1.0"
log = "~0.4"
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index da9f52a21eba..34ceeb91c710 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -31,7 +31,7 @@ crossterm = { version = "0.28", optional = true }
tempfile.workspace = true
# Conversion traits
url = "2.5.4" | [
"+ \"linux-raw-sys 0.4.14\",",
"+]",
"+checksum = \"f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825\"",
"+ \"libc\",",
"+ \"linux-raw-sys 0.9.2\",",
"-serde = { version = \"1.0.218\", features = [\"derive\"] }"
] | [
82,
84,
90,
94,
95,
222
] | {
"additions": 49,
"author": "dependabot[bot]",
"deletions": 30,
"html_url": "https://github.com/helix-editor/helix/pull/13070",
"issue_id": 13070,
"merged_at": "2025-03-11T13:29:38Z",
"omission_probability": 0.1,
"pr_number": 13070,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group with 5 updates",
"total_changes": 79
} |
281 | diff --git a/helix-core/src/command_line.rs b/helix-core/src/command_line.rs
index 4c762a711343..960b247dfbd2 100644
--- a/helix-core/src/command_line.rs
+++ b/helix-core/src/command_line.rs
@@ -223,7 +223,11 @@ impl fmt::Display for ParseArgsError<'_> {
write!(f, "flag '--{flag}' missing an argument")
}
Self::MissingExpansionDelimiter { expansion } => {
- write!(f, "missing a string delimiter after '%{expansion}'")
+ if expansion.is_empty() {
+ write!(f, "'%' was not properly escaped. Please use '%%'")
+ } else {
+ write!(f, "missing a string delimiter after '%{expansion}'")
+ }
}
Self::UnknownExpansion { kind } => {
write!(f, "unknown expansion '{kind}'")
diff --git a/helix-term/tests/test/command_line.rs b/helix-term/tests/test/command_line.rs
index d9a0166992a8..0e2270060006 100644
--- a/helix-term/tests/test/command_line.rs
+++ b/helix-term/tests/test/command_line.rs
@@ -90,3 +90,14 @@ async fn shell_expansion() -> anyhow::Result<()> {
Ok(())
}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn percent_escaping() -> anyhow::Result<()> {
+ test_statusline(
+ r#":sh echo hello 10%"#,
+ "'run-shell-command': '%' was not properly escaped. Please use '%%'",
+ Severity::Error,
+ )
+ .await?;
+ Ok(())
+}
| diff --git a/helix-core/src/command_line.rs b/helix-core/src/command_line.rs
index 4c762a711343..960b247dfbd2 100644
--- a/helix-core/src/command_line.rs
+++ b/helix-core/src/command_line.rs
@@ -223,7 +223,11 @@ impl fmt::Display for ParseArgsError<'_> {
write!(f, "flag '--{flag}' missing an argument")
Self::MissingExpansionDelimiter { expansion } => {
- write!(f, "missing a string delimiter after '%{expansion}'")
+ if expansion.is_empty() {
+ write!(f, "'%' was not properly escaped. Please use '%%'")
+ } else {
+ write!(f, "missing a string delimiter after '%{expansion}'")
+ }
Self::UnknownExpansion { kind } => {
write!(f, "unknown expansion '{kind}'")
diff --git a/helix-term/tests/test/command_line.rs b/helix-term/tests/test/command_line.rs
index d9a0166992a8..0e2270060006 100644
--- a/helix-term/tests/test/command_line.rs
+++ b/helix-term/tests/test/command_line.rs
@@ -90,3 +90,14 @@ async fn shell_expansion() -> anyhow::Result<()> {
Ok(())
}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn percent_escaping() -> anyhow::Result<()> {
+ test_statusline(
+ r#":sh echo hello 10%"#,
+ "'run-shell-command': '%' was not properly escaped. Please use '%%'",
+ Severity::Error,
+ )
+ .await?;
+ Ok(())
+} | [] | [] | {
"additions": 16,
"author": "abrassel",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/13018",
"issue_id": 13018,
"merged_at": "2025-03-04T16:03:11Z",
"omission_probability": 0.1,
"pr_number": 13018,
"repo": "helix-editor/helix",
"title": "Improve %% escaping error message",
"total_changes": 17
} |
282 | diff --git a/default.nix b/default.nix
index 5020c406dc2f..d640640082fe 100644
--- a/default.nix
+++ b/default.nix
@@ -5,6 +5,7 @@
runCommand,
installShellFiles,
git,
+ gitRev ? null,
...
}: let
fs = lib.fileset;
@@ -34,9 +35,6 @@
ln -s ${grammars} $out/grammars
'';
in
- # Currently rustPlatform.buildRustPackage doesn't have the finalAttrs pattern
- # hooked up. To get around this while having good customization, mkDerivation is
- # used instead.
rustPlatform.buildRustPackage (self: {
cargoLock = {
lockFile = ./Cargo.lock;
@@ -63,7 +61,7 @@ in
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
# So Helix knows what rev it is.
- HELIX_NIX_BUILD_REV = self.rev or self.dirtyRev or null;
+ HELIX_NIX_BUILD_REV = gitRev;
doCheck = false;
strictDeps = true;
diff --git a/flake.nix b/flake.nix
index 7d176cb01e48..0a92e23daae7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -16,7 +16,9 @@
flake-utils,
rust-overlay,
...
- }:
+ }: let
+ gitRev = self.rev or self.dirtyRev or null;
+ in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
@@ -31,13 +33,20 @@
};
in {
packages = rec {
- helix = pkgs.callPackage ./default.nix {};
+ helix = pkgs.callPackage ./default.nix {inherit gitRev;};
- # The default Helix build. Uses the latest stable Rust toolchain, and unstable
- # nixpkgs.
- #
- # This can be overridden though to add Cargo Features, flags, and different toolchains with
- # packages.${system}.default.override { ... };
+ /**
+ The default Helix build. Uses the latest stable Rust toolchain, and unstable
+ nixpkgs.
+
+ The build inputs can be overriden with the following:
+
+ packages.${system}.default.override { rustPlatform = newPlatform; };
+
+ Overriding a derivation attribute can be done as well:
+
+ packages.${system}.default.overrideAttrs { buildType = "debug"; };
+ */
default = helix;
};
@@ -71,7 +80,7 @@
})
// {
overlays.default = final: prev: {
- helix = final.callPackage ./default.nix {};
+ helix = final.callPackage ./default.nix {inherit gitRev;};
};
};
| diff --git a/default.nix b/default.nix
index 5020c406dc2f..d640640082fe 100644
--- a/default.nix
+++ b/default.nix
@@ -5,6 +5,7 @@
runCommand,
installShellFiles,
git,
+ gitRev ? null,
...
}: let
fs = lib.fileset;
@@ -34,9 +35,6 @@
ln -s ${grammars} $out/grammars
'';
in
- # Currently rustPlatform.buildRustPackage doesn't have the finalAttrs pattern
- # hooked up. To get around this while having good customization, mkDerivation is
- # used instead.
rustPlatform.buildRustPackage (self: {
cargoLock = {
lockFile = ./Cargo.lock;
@@ -63,7 +61,7 @@ in
HELIX_DISABLE_AUTO_GRAMMAR_BUILD = "1";
# So Helix knows what rev it is.
- HELIX_NIX_BUILD_REV = self.rev or self.dirtyRev or null;
+ HELIX_NIX_BUILD_REV = gitRev;
doCheck = false;
strictDeps = true;
diff --git a/flake.nix b/flake.nix
index 7d176cb01e48..0a92e23daae7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -16,7 +16,9 @@
flake-utils,
rust-overlay,
...
- }:
+ }: let
+ gitRev = self.rev or self.dirtyRev or null;
+ in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
@@ -31,13 +33,20 @@
in {
packages = rec {
- helix = pkgs.callPackage ./default.nix {};
+ helix = pkgs.callPackage ./default.nix {inherit gitRev;};
- # The default Helix build. Uses the latest stable Rust toolchain, and unstable
- # nixpkgs.
- #
- # This can be overridden though to add Cargo Features, flags, and different toolchains with
- # packages.${system}.default.override { ... };
+ /**
+ The default Helix build. Uses the latest stable Rust toolchain, and unstable
+ nixpkgs.
+ The build inputs can be overriden with the following:
+ packages.${system}.default.override { rustPlatform = newPlatform; };
+ Overriding a derivation attribute can be done as well:
+ */
default = helix;
@@ -71,7 +80,7 @@
})
// {
overlays.default = final: prev: {
- helix = final.callPackage ./default.nix {};
+ helix = final.callPackage ./default.nix {inherit gitRev;};
}; | [
"+ packages.${system}.default.overrideAttrs { buildType = \"debug\"; };"
] | [
68
] | {
"additions": 19,
"author": "RossSmyth",
"deletions": 12,
"html_url": "https://github.com/helix-editor/helix/pull/13024",
"issue_id": 13024,
"merged_at": "2025-03-04T19:12:48Z",
"omission_probability": 0.1,
"pr_number": 13024,
"repo": "helix-editor/helix",
"title": "Follow-up to #12831, fix the git hash",
"total_changes": 31
} |
283 | diff --git a/runtime/themes/kanagawa.toml b/runtime/themes/kanagawa.toml
index 8d5a80eefa58..be3f841fcf34 100644
--- a/runtime/themes/kanagawa.toml
+++ b/runtime/themes/kanagawa.toml
@@ -9,14 +9,14 @@
## User interface
"ui.selection" = { bg = "waveBlue2" }
"ui.selection.primary" = { bg = "waveBlue2" }
-"ui.background" = { fg = "fujiWhite", bg = "sumiInk1" }
+"ui.background" = { fg = "fujiWhite", bg = "sumiInk3" }
"ui.linenr" = { fg = "sumiInk6" }
"ui.linenr.selected" = { fg = "roninYellow", modifiers = ["bold"] }
"ui.gutter" = { fg = "sumiInk6", bg = "sumiInk4" }
"ui.virtual" = "sumiInk6"
-"ui.virtual.ruler" = { bg = "sumiInk2" }
+"ui.virtual.ruler" = { bg = "sumiInk4" }
"ui.virtual.inlay-hint" = "sumiInk6"
"ui.virtual.jump-label" = { fg = "peachRed", modifiers = ["bold"] }
@@ -25,8 +25,6 @@
"ui.statusline.normal" = { fg = "sumiInk0", bg = "crystalBlue", modifiers = ["bold"] }
"ui.statusline.insert" = { fg = "sumiInk0", bg = "autumnGreen", modifiers = ["bold"] }
"ui.statusline.select" = { fg = "sumiInk0", bg = "oniViolet", modifiers = ["bold"] }
-# Malformed ANSI: "". See 'https://github.com/helix-editor/helix/issues/5709'
-# "ui.statusline.separator" = { fg = "", bg = "" }
"ui.bufferline" = { fg = "fujiGray", bg = "sumiInk0" }
"ui.bufferline.active" = { fg = "oldWhite", bg = "sumiInk0" }
@@ -46,8 +44,8 @@
"ui.menu.selected" = { fg = "fujiWhite", bg = "waveBlue2", modifiers = ["bold"] }
"ui.menu.scroll" = { fg = "oldWhite", bg = "waveBlue1" }
-"ui.cursorline.primary" = { bg = "sumiInk3" }
-"ui.cursorcolumn.primary" = { bg = "sumiInk3" }
+"ui.cursorline.primary" = { bg = "sumiInk5" }
+"ui.cursorcolumn.primary" = { bg = "sumiInk5" }
"ui.debug.breakpoint" = "springBlue"
"ui.debug.active" = "winterRed"
@@ -101,56 +99,62 @@ hint = "waveAqua1"
"special" = "peachRed"
## Markup modifiers
+"markup.heading" = { fg = "springViolet2", modifiers = ["bold"] }
"markup.heading.marker" = "springViolet2"
-"markup.heading" = { fg = "crystalBlue", modifiers = ["bold"] }
-"markup.list" = "oniViolet"
+"markup.heading.1" = { fg = "carpYellow", modifiers = ["bold"] }
+"markup.heading.2" = { fg = "crystalBlue", modifiers = ["bold"] }
+"markup.heading.3" = { fg = "waveAqua2", modifiers = ["bold"] }
+"markup.list" = "sakuraPink"
"markup.bold" = { modifiers = ["bold"] }
"markup.italic" = { modifiers = ["italic"] }
"markup.strikethrough" = { modifiers = ["crossed_out"] }
"markup.link.text" = { fg = "springBlue" }
-"markup.link.url" = { fg = "sakuraPink" }
+"markup.link.url" = { fg = "lightBlue" }
"markup.link.label" = "surimiOrange"
-"markup.quote" = "springViolet1"
+"markup.quote" = "oniViolet2"
"markup.raw" = "springGreen"
[palette]
-seaFoam = "#C7CCD1" # custom lighter foreground
-fujiWhite = "#DCD7BA" # default foreground
-oldWhite = "#C8C093" # dark foreground, e.g. statuslines
-sumiInk0 = "#16161D" # dark background, e.g. statuslines, floating windows
-sumiInk1 = "#1F1F28" # default background
-sumiInk2 = "#2A2A37" # lighter background, e.g. colorcolumns, folds
-sumiInk3 = "#363646" # lighter background, e.g. cursorline
-sumiInk4 = "#2A2A37" # darker foreground, e.g. linenumbers, fold column
-sumiInk6 = "#54546D" # inlay hints
-waveBlue1 = "#223249" # popup background, visual selection background
-waveBlue2 = "#2D4F67" # popup selection background, search background
-winterGreen = "#2B3328" # diff add background
-winterYellow = "#49443C" # diff change background
-winterRed = "#43242B" # diff deleted background
-winterBlue = "#252535" # diff line background
-autumnGreen = "#76946A" # git add
-autumnRed = "#C34043" # git delete
-autumnYellow = "#DCA561" # git change
-samuraiRed = "#E82424" # diagnostic error
-roninYellow = "#FF9E3B" # diagnostic warning
-waveAqua1 = "#6A9589" # diagnostic info
-dragonBlue = "#658594" # diagnostic hint
-fujiGray = "#727169" # comments
-springViolet1 = "#938AA9" # light foreground
-oniViolet = "#957FB8" # statements and keywords
-oniViolet2 = "#B8B4D0" # parameters
-crystalBlue = "#7E9CD8" # functions and titles
-springViolet2 = "#9CABCA" # brackets and punctuation
-springBlue = "#7FB4CA" # specials and builtins
-lightBlue = "#A3D4D5" # not used!
-waveAqua2 = "#7AA89F" # types
-springGreen = "#98BB6C" # strings
-boatYellow1 = "#938056" # not used
-boatYellow2 = "#C0A36E" # operators, regex
-carpYellow = "#E6C384" # identifiers
-sakuraPink = "#D27E99" # numbers
-waveRed = "#E46876" # standout specials 1, e.g. builtin variables
-peachRed = "#FF5D62" # standout specials 2, e.g. exception handling, returns
-surimiOrange = "#FFA066" # constants, imports, booleans
-katanaGray = "#717C7C" # deprecated
+oldWhite = "#C8C093" # dark foreground, e.g. statuslines
+fujiWhite = "#DCD7BA" # default foreground
+fujiGray = "#727169" # comments
+sumiInk0 = "#16161D" # dark background, e.g. statuslines, floating windows
+sumiInk1 = "#181820" # unused
+sumiInk2 = "#1A1A22" # unused
+sumiInk3 = "#1F1F28" # default background
+sumiInk4 = "#2A2A37" # lighter background, e.g. colorcolumns, folds
+sumiInk5 = "#363646" # lighter background, e.g. cursorline
+sumiInk6 = "#54546D" # inlay hints
+waveBlue1 = "#223249" # popup background, visual selection background
+waveBlue2 = "#2D4F67" # popup selection background, search background
+winterGreen = "#2B3328" # diff add background
+winterYellow = "#49443C" # diff change background
+winterRed = "#43242B" # diff delete background
+winterBlue = "#252535" # diff line background
+autumnGreen = "#76946A" # git add
+autumnRed = "#C34043" # git delete
+autumnYellow = "#DCA561" # git change
+samuraiRed = "#E82424" # diagnostic error
+roninYellow = "#FF9E3B" # diagnostic warning
+waveAqua1 = "#6A9589" # diagnostic info
+dragonBlue = "#658594" # diagnostic hint
+oniViolet = "#957FB8" # statements and keywords
+oniViolet2 = "#B8B4D0" # parameters
+crystalBlue = "#7E9CD8" # functions and titles
+springViolet1 = "#938AA9" # unused
+springViolet2 = "#9CABCA" # brackets and punctuation
+springBlue = "#7FB4CA" # specials and builtins
+lightBlue = "#A3D4D5" # URLs
+waveAqua2 = "#7AA89F" # types
+waveAqua3 = "#68AD99" # unused
+waveAqua4 = "#7AA880" # unused
+waveAqua5 = "#6CAF95" # unused
+springGreen = "#98BB6C" # strings
+boatYellow1 = "#938056" # unused
+boatYellow2 = "#C0A36E" # operators, regex
+carpYellow = "#E6C384" # identifiers
+sakuraPink = "#D27E99" # numbers
+waveRed = "#E46876" # standout specials 1, e.g. builtin variables
+peachRed = "#FF5D62" # standout specials 2, e.g. exception handling, returns
+surimiOrange = "#FFA066" # constants, imports, booleans
+katanaGray = "#717C7C" # unused
| diff --git a/runtime/themes/kanagawa.toml b/runtime/themes/kanagawa.toml
index 8d5a80eefa58..be3f841fcf34 100644
--- a/runtime/themes/kanagawa.toml
+++ b/runtime/themes/kanagawa.toml
@@ -9,14 +9,14 @@
## User interface
"ui.selection" = { bg = "waveBlue2" }
"ui.selection.primary" = { bg = "waveBlue2" }
-"ui.background" = { fg = "fujiWhite", bg = "sumiInk1" }
+"ui.background" = { fg = "fujiWhite", bg = "sumiInk3" }
"ui.linenr" = { fg = "sumiInk6" }
"ui.linenr.selected" = { fg = "roninYellow", modifiers = ["bold"] }
"ui.gutter" = { fg = "sumiInk6", bg = "sumiInk4" }
"ui.virtual" = "sumiInk6"
-"ui.virtual.ruler" = { bg = "sumiInk2" }
+"ui.virtual.ruler" = { bg = "sumiInk4" }
"ui.virtual.inlay-hint" = "sumiInk6"
"ui.virtual.jump-label" = { fg = "peachRed", modifiers = ["bold"] }
@@ -25,8 +25,6 @@
"ui.statusline.normal" = { fg = "sumiInk0", bg = "crystalBlue", modifiers = ["bold"] }
"ui.statusline.insert" = { fg = "sumiInk0", bg = "autumnGreen", modifiers = ["bold"] }
"ui.statusline.select" = { fg = "sumiInk0", bg = "oniViolet", modifiers = ["bold"] }
-# Malformed ANSI: "". See 'https://github.com/helix-editor/helix/issues/5709'
-# "ui.statusline.separator" = { fg = "", bg = "" }
"ui.bufferline" = { fg = "fujiGray", bg = "sumiInk0" }
"ui.bufferline.active" = { fg = "oldWhite", bg = "sumiInk0" }
@@ -46,8 +44,8 @@
"ui.menu.selected" = { fg = "fujiWhite", bg = "waveBlue2", modifiers = ["bold"] }
"ui.menu.scroll" = { fg = "oldWhite", bg = "waveBlue1" }
"ui.debug.breakpoint" = "springBlue"
"ui.debug.active" = "winterRed"
@@ -101,56 +99,62 @@ hint = "waveAqua1"
"special" = "peachRed"
## Markup modifiers
+"markup.heading" = { fg = "springViolet2", modifiers = ["bold"] }
"markup.heading.marker" = "springViolet2"
-"markup.heading" = { fg = "crystalBlue", modifiers = ["bold"] }
+"markup.heading.1" = { fg = "carpYellow", modifiers = ["bold"] }
+"markup.heading.3" = { fg = "waveAqua2", modifiers = ["bold"] }
+"markup.list" = "sakuraPink"
"markup.bold" = { modifiers = ["bold"] }
"markup.italic" = { modifiers = ["italic"] }
"markup.strikethrough" = { modifiers = ["crossed_out"] }
"markup.link.text" = { fg = "springBlue" }
-"markup.link.url" = { fg = "sakuraPink" }
+"markup.link.url" = { fg = "lightBlue" }
"markup.link.label" = "surimiOrange"
-"markup.quote" = "springViolet1"
"markup.raw" = "springGreen"
[palette]
-fujiWhite = "#DCD7BA" # default foreground
-oldWhite = "#C8C093" # dark foreground, e.g. statuslines
-sumiInk0 = "#16161D" # dark background, e.g. statuslines, floating windows
-sumiInk1 = "#1F1F28" # default background
-sumiInk2 = "#2A2A37" # lighter background, e.g. colorcolumns, folds
-sumiInk3 = "#363646" # lighter background, e.g. cursorline
-sumiInk4 = "#2A2A37" # darker foreground, e.g. linenumbers, fold column
-sumiInk6 = "#54546D" # inlay hints
-waveBlue1 = "#223249" # popup background, visual selection background
-waveBlue2 = "#2D4F67" # popup selection background, search background
-winterYellow = "#49443C" # diff change background
-winterRed = "#43242B" # diff deleted background
-winterBlue = "#252535" # diff line background
-autumnGreen = "#76946A" # git add
-autumnRed = "#C34043" # git delete
-autumnYellow = "#DCA561" # git change
-samuraiRed = "#E82424" # diagnostic error
-roninYellow = "#FF9E3B" # diagnostic warning
-waveAqua1 = "#6A9589" # diagnostic info
-dragonBlue = "#658594" # diagnostic hint
-fujiGray = "#727169" # comments
-springViolet1 = "#938AA9" # light foreground
-oniViolet = "#957FB8" # statements and keywords
-oniViolet2 = "#B8B4D0" # parameters
-crystalBlue = "#7E9CD8" # functions and titles
-springViolet2 = "#9CABCA" # brackets and punctuation
-springBlue = "#7FB4CA" # specials and builtins
-lightBlue = "#A3D4D5" # not used!
-waveAqua2 = "#7AA89F" # types
-springGreen = "#98BB6C" # strings
-boatYellow1 = "#938056" # not used
-boatYellow2 = "#C0A36E" # operators, regex
-carpYellow = "#E6C384" # identifiers
-sakuraPink = "#D27E99" # numbers
-peachRed = "#FF5D62" # standout specials 2, e.g. exception handling, returns
-katanaGray = "#717C7C" # deprecated
+oldWhite = "#C8C093" # dark foreground, e.g. statuslines
+fujiWhite = "#DCD7BA" # default foreground
+fujiGray = "#727169" # comments
+sumiInk0 = "#16161D" # dark background, e.g. statuslines, floating windows
+sumiInk1 = "#181820" # unused
+sumiInk2 = "#1A1A22" # unused
+sumiInk3 = "#1F1F28" # default background
+sumiInk4 = "#2A2A37" # lighter background, e.g. colorcolumns, folds
+sumiInk5 = "#363646" # lighter background, e.g. cursorline
+sumiInk6 = "#54546D" # inlay hints
+waveBlue1 = "#223249" # popup background, visual selection background
+waveBlue2 = "#2D4F67" # popup selection background, search background
+winterGreen = "#2B3328" # diff add background
+winterYellow = "#49443C" # diff change background
+winterRed = "#43242B" # diff delete background
+autumnGreen = "#76946A" # git add
+autumnRed = "#C34043" # git delete
+samuraiRed = "#E82424" # diagnostic error
+roninYellow = "#FF9E3B" # diagnostic warning
+oniViolet = "#957FB8" # statements and keywords
+oniViolet2 = "#B8B4D0" # parameters
+crystalBlue = "#7E9CD8" # functions and titles
+springViolet1 = "#938AA9" # unused
+springViolet2 = "#9CABCA" # brackets and punctuation
+springBlue = "#7FB4CA" # specials and builtins
+lightBlue = "#A3D4D5" # URLs
+waveAqua2 = "#7AA89F" # types
+waveAqua3 = "#68AD99" # unused
+waveAqua4 = "#7AA880" # unused
+waveAqua5 = "#6CAF95" # unused
+springGreen = "#98BB6C" # strings
+boatYellow1 = "#938056" # unused
+carpYellow = "#E6C384" # identifiers
+sakuraPink = "#D27E99" # numbers
+waveRed = "#E46876" # standout specials 1, e.g. builtin variables
+peachRed = "#FF5D62" # standout specials 2, e.g. exception handling, returns
+surimiOrange = "#FFA066" # constants, imports, booleans
+katanaGray = "#717C7C" # unused | [
"-\"ui.cursorline.primary\" = { bg = \"sumiInk3\" }",
"-\"ui.cursorcolumn.primary\" = { bg = \"sumiInk3\" }",
"+\"ui.cursorline.primary\" = { bg = \"sumiInk5\" }",
"+\"ui.cursorcolumn.primary\" = { bg = \"sumiInk5\" }",
"-\"markup.list\" = \"oniViolet\"",
"+\"markup.heading.2\" = { fg = \"crystalBlue\", modifiers = [\"bold\"] }",
"+\"markup.quote\" = \"oniViolet2\"",
"-seaFoam = \"#C7CCD1\" # custom lighter foreground",
"-winterGreen = \"#2B3328\" # diff add background",
"-waveRed = \"#E46876\" # standout specials 1, e.g. builtin variables",
"-surimiOrange = \"#FFA066\" # constants, imports, booleans",
"+winterBlue = \"#252535\" # diff line background",
"+autumnYellow = \"#DCA561\" # git change",
"+waveAqua1 = \"#6A9589\" # diagnostic info",
"+dragonBlue = \"#658594\" # diagnostic hint",
"+boatYellow2 = \"#C0A36E\" # operators, regex"
] | [
34,
35,
36,
37,
48,
50,
61,
65,
76,
101,
103,
120,
123,
126,
127,
141
] | {
"additions": 54,
"author": "luetage",
"deletions": 50,
"html_url": "https://github.com/helix-editor/helix/pull/12895",
"issue_id": 12895,
"merged_at": "2025-03-02T17:06:59Z",
"omission_probability": 0.1,
"pr_number": 12895,
"repo": "helix-editor/helix",
"title": "Kanagawa: fix palette and attempt at a markdown compromise",
"total_changes": 104
} |
284 | diff --git a/runtime/themes/beans.toml b/runtime/themes/beans.toml
new file mode 100644
index 000000000000..bde2ed4dd146
--- /dev/null
+++ b/runtime/themes/beans.toml
@@ -0,0 +1,134 @@
+# Beans
+# A slightly modified Jellybeans with better support for multi-cursor and multiple selections
+#
+# Original repository: nanotech/jellybeans.vim
+# Contributors:
+# @cemalokten
+# @gnur
+
+
+"attribute" = "green"
+"type" = "light_blue"
+"type.enum.variant" = "purple"
+"constructor" = "yellow"
+"constant" = "dark_orange"
+
+"constant.builtin.boolean" = "yellow"
+"constant.character" = "yellow"
+"constant.character.escape" = "red_error"
+"constant.numeric" = "dark_orange"
+"string" = "dark_green"
+"string.regexp" = "light_purple"
+"string.special" = { fg = "yellow", modifiers = ["underlined"] }
+"comment" = "light_gray"
+
+"variable" = "light_yellow"
+"variable.builtin" = { fg = "dark_green", modifiers = ["underlined"] }
+"variable.parameter" = "yellow"
+"variable.other.member" = "light_purple"
+"label" = "yellow"
+"punctuation" = "mid_blue"
+"keyword" = "mid_blue"
+"keyword.control.exception" = "purple"
+"operator" = "light_purple"
+"function" = "yellow"
+"function.macro" = "green"
+"function.builtin" = "green"
+"function.special" = "green"
+"function.method" = "yellow"
+"tag" = "light_blue"
+"special" = "green"
+"namespace" = "light_purple"
+
+"markup.bold" = { fg = "white", modifiers = ["bold"] }
+"markup.italic" = { modifiers = ["italic"] }
+"markup.strikethrough" = { modifiers = ["crossed_out"] }
+"markup.heading" = { fg = "mid_blue", modifiers = ["bold"] }
+"markup.list" = "dark_green"
+"markup.list.numbered" = "mid_blue"
+"markup.list.unnumbered" = "mid_blue"
+"markup.link.url" = { fg = "dark_green", modifiers = ['italic', 'underlined'] }
+"markup.link.text" = "mid_blue"
+"markup.link.label" = "purple"
+"markup.quote" = "dark_green"
+"markup.raw" = "dark_green"
+"markup.raw.inline" = "mid_blue"
+"markup.raw.block" = "dark_green"
+
+"diff.plus" = "diff_plus"
+"diff.minus" = "red_accent"
+"diff.delta" = "blue_accent"
+
+# ui specific
+"ui.background" = { bg = "background" }
+"ui.cursor" = { bg = "purple", fg = "selectionfg" }
+"ui.cursor.primary" = { bg = "dark_blue", fg = "white" }
+"ui.cursor.normal" = { bg = "purple", fg = "selectionfg" }
+"ui.cursor.insert" = { bg = "light_yellow", fg = "background" }
+"ui.cursor.match" = { fg = "background", bg = "dark_orange" }
+"ui.cursorline" = { bg = "darker" }
+"ui.linenr" = "dark_gray"
+"ui.linenr.selected" = { fg = "light_yellow", bg = "darker" }
+"ui.statusline" = { fg = "light_yellow", bg = "darker" }
+"ui.statusline.inactive" = { fg = "dark", bg = "darker" }
+"ui.statusline.normal" = { fg = "light_yellow", bg = "darker" }
+"ui.statusline.insert" = { fg = "darker", bg = "purple" }
+"ui.statusline.select" = { fg = "selectionfg", bg = "selection" }
+"ui.popup" = { fg = "light_yellow", bg = "darkest" }
+"ui.window" = { fg = "dark", bg = "darkest" }
+"ui.help" = { fg = "light_yellow", bg = "darkest" }
+"ui.text" = "light_yellow"
+"ui.text.focus" = { fg = "white", bg = "dark_blue" }
+"ui.virtual" = "dark"
+"ui.virtual.ruler" = { bg = "darker" }
+"ui.virtual.jump-label" = { bg = "light_blue", fg = "darkest", modifiers = ["bold"] }
+"ui.menu" = { fg = "light_purple", bg = "darkest" }
+"ui.menu.selected" = { fg = "white", bg = "dark_blue" }
+"ui.selection.primary" = { bg = "light_purple", fg = "darkest" }
+"ui.selection" = { bg = "light_blue", fg = "darkest" }
+"hint" = "blue"
+"info" = "yellow_accent"
+"warning" = "orange_accent"
+"error" = "red_error"
+"diagnostic" = { modifiers = [] }
+"diagnostic.hint" = { underline = { color = "white", style = "line" } }
+"diagnostic.info" = { underline = { color = "blue_accent", style = "line" } }
+"diagnostic.warning" = { underline = { color = "yellow_accent", style = "line" } }
+"diagnostic.error" = { underline = { color = "red_error", style = "line" } }
+
+[palette]
+background = "#111111"
+darkest = "#1c1c1c"
+darker = "#292929"
+dark = "#898989"
+white = "#ffffff"
+dark_gray = "#535353"
+light_gray = "#6d6d6d"
+
+purple = "#833c9f"
+light_purple = "#be67e1"
+
+blue = "#048ac7"
+light_blue = "#48c6ff"
+mid_blue = "#8197bf"
+dark_blue = "#0ac1cd"
+blue_accent = "#63e7f0"
+
+green = "#ccff00"
+dark_green = "#cee318"
+
+red = "#cc7c8a"
+red_error = "#902020"
+red_accent = "#f44747"
+
+orange = "#ff9f00"
+dark_orange = "#ff005b"
+orange_accent = "#ee7f25"
+
+yellow = "#fad07a"
+light_yellow = "#ebebd8"
+yellow_accent = "#dea407"
+
+diff_plus = "#5a9f81"
+selection = "#37232d"
+selectionfg = "#e5e5e5"
| diff --git a/runtime/themes/beans.toml b/runtime/themes/beans.toml
new file mode 100644
index 000000000000..bde2ed4dd146
--- /dev/null
+++ b/runtime/themes/beans.toml
@@ -0,0 +1,134 @@
+# Beans
+# A slightly modified Jellybeans with better support for multi-cursor and multiple selections
+#
+# Original repository: nanotech/jellybeans.vim
+# Contributors:
+# @cemalokten
+# @gnur
+"attribute" = "green"
+"type" = "light_blue"
+"type.enum.variant" = "purple"
+"constructor" = "yellow"
+"constant" = "dark_orange"
+"constant.builtin.boolean" = "yellow"
+"constant.character.escape" = "red_error"
+"constant.numeric" = "dark_orange"
+"string" = "dark_green"
+"string.regexp" = "light_purple"
+"string.special" = { fg = "yellow", modifiers = ["underlined"] }
+"comment" = "light_gray"
+"variable" = "light_yellow"
+"variable.builtin" = { fg = "dark_green", modifiers = ["underlined"] }
+"variable.parameter" = "yellow"
+"label" = "yellow"
+"punctuation" = "mid_blue"
+"keyword" = "mid_blue"
+"keyword.control.exception" = "purple"
+"operator" = "light_purple"
+"function" = "yellow"
+"function.macro" = "green"
+"function.builtin" = "green"
+"function.special" = "green"
+"function.method" = "yellow"
+"tag" = "light_blue"
+"special" = "green"
+"namespace" = "light_purple"
+"markup.bold" = { fg = "white", modifiers = ["bold"] }
+"markup.strikethrough" = { modifiers = ["crossed_out"] }
+"markup.list" = "dark_green"
+"markup.list.numbered" = "mid_blue"
+"markup.list.unnumbered" = "mid_blue"
+"markup.link.url" = { fg = "dark_green", modifiers = ['italic', 'underlined'] }
+"markup.link.text" = "mid_blue"
+"markup.link.label" = "purple"
+"markup.quote" = "dark_green"
+"markup.raw" = "dark_green"
+"markup.raw.inline" = "mid_blue"
+"diff.plus" = "diff_plus"
+"diff.minus" = "red_accent"
+"diff.delta" = "blue_accent"
+# ui specific
+"ui.background" = { bg = "background" }
+"ui.cursor" = { bg = "purple", fg = "selectionfg" }
+"ui.cursor.primary" = { bg = "dark_blue", fg = "white" }
+"ui.cursor.normal" = { bg = "purple", fg = "selectionfg" }
+"ui.cursor.insert" = { bg = "light_yellow", fg = "background" }
+"ui.cursor.match" = { fg = "background", bg = "dark_orange" }
+"ui.cursorline" = { bg = "darker" }
+"ui.linenr" = "dark_gray"
+"ui.linenr.selected" = { fg = "light_yellow", bg = "darker" }
+"ui.statusline" = { fg = "light_yellow", bg = "darker" }
+"ui.statusline.inactive" = { fg = "dark", bg = "darker" }
+"ui.statusline.normal" = { fg = "light_yellow", bg = "darker" }
+"ui.statusline.insert" = { fg = "darker", bg = "purple" }
+"ui.statusline.select" = { fg = "selectionfg", bg = "selection" }
+"ui.popup" = { fg = "light_yellow", bg = "darkest" }
+"ui.window" = { fg = "dark", bg = "darkest" }
+"ui.help" = { fg = "light_yellow", bg = "darkest" }
+"ui.text.focus" = { fg = "white", bg = "dark_blue" }
+"ui.virtual" = "dark"
+"ui.virtual.ruler" = { bg = "darker" }
+"ui.virtual.jump-label" = { bg = "light_blue", fg = "darkest", modifiers = ["bold"] }
+"ui.menu" = { fg = "light_purple", bg = "darkest" }
+"ui.selection.primary" = { bg = "light_purple", fg = "darkest" }
+"ui.selection" = { bg = "light_blue", fg = "darkest" }
+"hint" = "blue"
+"info" = "yellow_accent"
+"warning" = "orange_accent"
+"error" = "red_error"
+"diagnostic" = { modifiers = [] }
+"diagnostic.hint" = { underline = { color = "white", style = "line" } }
+"diagnostic.info" = { underline = { color = "blue_accent", style = "line" } }
+"diagnostic.warning" = { underline = { color = "yellow_accent", style = "line" } }
+"diagnostic.error" = { underline = { color = "red_error", style = "line" } }
+[palette]
+background = "#111111"
+darker = "#292929"
+dark = "#898989"
+dark_gray = "#535353"
+light_gray = "#6d6d6d"
+purple = "#833c9f"
+light_purple = "#be67e1"
+blue = "#048ac7"
+light_blue = "#48c6ff"
+mid_blue = "#8197bf"
+dark_blue = "#0ac1cd"
+blue_accent = "#63e7f0"
+green = "#ccff00"
+dark_green = "#cee318"
+red = "#cc7c8a"
+red_error = "#902020"
+red_accent = "#f44747"
+orange = "#ff9f00"
+dark_orange = "#ff005b"
+orange_accent = "#ee7f25"
+yellow = "#fad07a"
+light_yellow = "#ebebd8"
+yellow_accent = "#dea407"
+diff_plus = "#5a9f81"
+selection = "#37232d"
+selectionfg = "#e5e5e5" | [
"+\"constant.character\" = \"yellow\"",
"+\"variable.other.member\" = \"light_purple\"",
"+\"markup.italic\" = { modifiers = [\"italic\"] }",
"+\"markup.heading\" = { fg = \"mid_blue\", modifiers = [\"bold\"] }",
"+\"markup.raw.block\" = \"dark_green\"",
"+\"ui.text\" = \"light_yellow\"",
"+\"ui.menu.selected\" = { fg = \"white\", bg = \"dark_blue\" }",
"+darkest = \"#1c1c1c\"",
"+white = \"#ffffff\""
] | [
22,
33,
49,
51,
61,
85,
91,
106,
109
] | {
"additions": 134,
"author": "gnur",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/12963",
"issue_id": 12963,
"merged_at": "2025-03-04T16:03:46Z",
"omission_probability": 0.1,
"pr_number": 12963,
"repo": "helix-editor/helix",
"title": "Add beans theme",
"total_changes": 134
} |
285 | diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 3986ad479b39..a6ce91a67712 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -1079,7 +1079,15 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
.first_history_completion(ctx.editor)
.filter(|_| self.prompt.line().is_empty())
{
- self.prompt.set_line(completion.to_string(), ctx.editor);
+ // The percent character is used by the query language and needs to be
+ // escaped with a backslash.
+ let completion = if completion.contains('%') {
+ completion.replace('%', "\\%")
+ } else {
+ completion.into_owned()
+ };
+ self.prompt.set_line(completion, ctx.editor);
+
// Inserting from the history register is a paste.
self.handle_prompt_change(true);
} else {
| diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 3986ad479b39..a6ce91a67712 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -1079,7 +1079,15 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
.first_history_completion(ctx.editor)
.filter(|_| self.prompt.line().is_empty())
{
- self.prompt.set_line(completion.to_string(), ctx.editor);
+ // The percent character is used by the query language and needs to be
+ // escaped with a backslash.
+ completion.replace('%', "\\%")
+ } else {
+ completion.into_owned()
+ self.prompt.set_line(completion, ctx.editor);
+
// Inserting from the history register is a paste.
self.handle_prompt_change(true);
} else { | [
"+ let completion = if completion.contains('%') {",
"+ };"
] | [
11,
15
] | {
"additions": 9,
"author": "jrvidal",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/12886",
"issue_id": 12886,
"merged_at": "2025-02-26T23:22:41Z",
"omission_probability": 0.1,
"pr_number": 12886,
"repo": "helix-editor/helix",
"title": "fix: escape percent character when yanking to search register",
"total_changes": 10
} |
286 | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 19a22601e3d1..52274985567e 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -64,6 +64,7 @@ use crate::{
use crate::job::{self, Jobs};
use std::{
+ char::{ToLowercase, ToUppercase},
cmp::Ordering,
collections::{HashMap, HashSet},
error::Error,
@@ -1724,17 +1725,48 @@ where
exit_select_mode(cx);
}
+enum CaseSwitcher {
+ Upper(ToUppercase),
+ Lower(ToLowercase),
+ Keep(Option<char>),
+}
+
+impl Iterator for CaseSwitcher {
+ type Item = char;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ match self {
+ CaseSwitcher::Upper(upper) => upper.next(),
+ CaseSwitcher::Lower(lower) => lower.next(),
+ CaseSwitcher::Keep(ch) => ch.take(),
+ }
+ }
+
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ match self {
+ CaseSwitcher::Upper(upper) => upper.size_hint(),
+ CaseSwitcher::Lower(lower) => lower.size_hint(),
+ CaseSwitcher::Keep(ch) => {
+ let n = if ch.is_some() { 1 } else { 0 };
+ (n, Some(n))
+ }
+ }
+ }
+}
+
+impl ExactSizeIterator for CaseSwitcher {}
+
fn switch_case(cx: &mut Context) {
switch_case_impl(cx, |string| {
string
.chars()
.flat_map(|ch| {
if ch.is_lowercase() {
- ch.to_uppercase().collect()
+ CaseSwitcher::Upper(ch.to_uppercase())
} else if ch.is_uppercase() {
- ch.to_lowercase().collect()
+ CaseSwitcher::Lower(ch.to_lowercase())
} else {
- vec![ch]
+ CaseSwitcher::Keep(Some(ch))
}
})
.collect()
| diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 19a22601e3d1..52274985567e 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -64,6 +64,7 @@ use crate::{
use crate::job::{self, Jobs};
use std::{
+ char::{ToLowercase, ToUppercase},
cmp::Ordering,
collections::{HashMap, HashSet},
error::Error,
@@ -1724,17 +1725,48 @@ where
exit_select_mode(cx);
}
+enum CaseSwitcher {
+ Lower(ToLowercase),
+ Keep(Option<char>),
+impl Iterator for CaseSwitcher {
+ type Item = char;
+ fn next(&mut self) -> Option<Self::Item> {
+ CaseSwitcher::Upper(upper) => upper.next(),
+ CaseSwitcher::Lower(lower) => lower.next(),
+ CaseSwitcher::Keep(ch) => ch.take(),
+ fn size_hint(&self) -> (usize, Option<usize>) {
+ CaseSwitcher::Upper(upper) => upper.size_hint(),
+ CaseSwitcher::Lower(lower) => lower.size_hint(),
+ CaseSwitcher::Keep(ch) => {
+ let n = if ch.is_some() { 1 } else { 0 };
+ }
+impl ExactSizeIterator for CaseSwitcher {}
fn switch_case(cx: &mut Context) {
switch_case_impl(cx, |string| {
string
.chars()
.flat_map(|ch| {
if ch.is_lowercase() {
- ch.to_uppercase().collect()
+ CaseSwitcher::Upper(ch.to_uppercase())
} else if ch.is_uppercase() {
- ch.to_lowercase().collect()
+ CaseSwitcher::Lower(ch.to_lowercase())
} else {
+ CaseSwitcher::Keep(Some(ch))
}
})
.collect() | [
"+ Upper(ToUppercase),",
"+ (n, Some(n))",
"- vec![ch]"
] | [
17,
39,
59
] | {
"additions": 35,
"author": "m4rch3n1ng",
"deletions": 3,
"html_url": "https://github.com/helix-editor/helix/pull/12786",
"issue_id": 12786,
"merged_at": "2025-02-27T01:03:29Z",
"omission_probability": 0.1,
"pr_number": 12786,
"repo": "helix-editor/helix",
"title": "remove unnecessary allocations in switch_case",
"total_changes": 38
} |
287 | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 19a22601e3d1..0874dab8bbbf 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -11,7 +11,10 @@ use helix_stdx::{
};
use helix_vcs::{FileChange, Hunk};
pub use lsp::*;
-use tui::text::Span;
+use tui::{
+ text::{Span, Spans},
+ widgets::Cell,
+};
pub use typed::*;
use helix_core::{
@@ -2404,18 +2407,42 @@ fn global_search(cx: &mut Context) {
struct GlobalSearchConfig {
smart_case: bool,
file_picker_config: helix_view::editor::FilePickerConfig,
+ directory_style: Style,
+ number_style: Style,
+ colon_style: Style,
}
let config = cx.editor.config();
let config = GlobalSearchConfig {
smart_case: config.search.smart_case,
file_picker_config: config.file_picker.clone(),
+ directory_style: cx.editor.theme.get("ui.text.directory"),
+ number_style: cx.editor.theme.get("constant.numeric.integer"),
+ colon_style: cx.editor.theme.get("punctuation"),
};
let columns = [
- PickerColumn::new("path", |item: &FileResult, _| {
+ PickerColumn::new("path", |item: &FileResult, config: &GlobalSearchConfig| {
let path = helix_stdx::path::get_relative_path(&item.path);
- format!("{}:{}", path.to_string_lossy(), item.line_num + 1).into()
+
+ let directories = path
+ .parent()
+ .filter(|p| !p.as_os_str().is_empty())
+ .map(|p| format!("{}{}", p.display(), std::path::MAIN_SEPARATOR))
+ .unwrap_or_default();
+
+ let filename = item
+ .path
+ .file_name()
+ .expect("global search paths are normalized (can't end in `..`)")
+ .to_string_lossy();
+
+ Cell::from(Spans::from(vec![
+ Span::styled(directories, config.directory_style),
+ Span::raw(filename),
+ Span::styled(":", config.colon_style),
+ Span::styled((item.line_num + 1).to_string(), config.number_style),
+ ]))
}),
PickerColumn::hidden("contents"),
];
| diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 19a22601e3d1..0874dab8bbbf 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -11,7 +11,10 @@ use helix_stdx::{
};
use helix_vcs::{FileChange, Hunk};
pub use lsp::*;
-use tui::text::Span;
+use tui::{
+ text::{Span, Spans},
+};
pub use typed::*;
use helix_core::{
@@ -2404,18 +2407,42 @@ fn global_search(cx: &mut Context) {
struct GlobalSearchConfig {
smart_case: bool,
file_picker_config: helix_view::editor::FilePickerConfig,
+ directory_style: Style,
+ colon_style: Style,
}
let config = cx.editor.config();
let config = GlobalSearchConfig {
smart_case: config.search.smart_case,
file_picker_config: config.file_picker.clone(),
+ directory_style: cx.editor.theme.get("ui.text.directory"),
+ colon_style: cx.editor.theme.get("punctuation"),
};
let columns = [
- PickerColumn::new("path", |item: &FileResult, _| {
+ PickerColumn::new("path", |item: &FileResult, config: &GlobalSearchConfig| {
let path = helix_stdx::path::get_relative_path(&item.path);
- format!("{}:{}", path.to_string_lossy(), item.line_num + 1).into()
+ let directories = path
+ .parent()
+ .map(|p| format!("{}{}", p.display(), std::path::MAIN_SEPARATOR))
+ .unwrap_or_default();
+ let filename = item
+ .path
+ .file_name()
+ .expect("global search paths are normalized (can't end in `..`)")
+ .to_string_lossy();
+ Cell::from(Spans::from(vec![
+ Span::styled(directories, config.directory_style),
+ Span::raw(filename),
+ Span::styled(":", config.colon_style),
+ Span::styled((item.line_num + 1).to_string(), config.number_style),
+ ]))
}),
PickerColumn::hidden("contents"),
]; | [
"+ widgets::Cell,",
"+ number_style: Style,",
"+ number_style: cx.editor.theme.get(\"constant.numeric.integer\"),",
"+ .filter(|p| !p.as_os_str().is_empty())"
] | [
11,
21,
30,
42
] | {
"additions": 30,
"author": "nik-rev",
"deletions": 3,
"html_url": "https://github.com/helix-editor/helix/pull/12855",
"issue_id": 12855,
"merged_at": "2025-02-27T00:09:58Z",
"omission_probability": 0.1,
"pr_number": 12855,
"repo": "helix-editor/helix",
"title": "feat: Improve look of Global Search Picker",
"total_changes": 33
} |
288 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 833196b6b54c..54cb4741fe03 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -134,6 +134,7 @@
| log | β | | | |
| lpf | β | | | |
| lua | β | β | β | `lua-language-server` |
+| mail | β | β | | |
| make | β | | β | |
| markdoc | β | | | `markdoc-ls` |
| markdown | β | | | `marksman`, `markdown-oxide` |
diff --git a/languages.toml b/languages.toml
index 321f1864b7ba..6f391e14e426 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1670,6 +1670,16 @@ injection-regex = "tablegen"
name = "tablegen"
source = { git = "https://github.com/Flakebi/tree-sitter-tablegen", rev = "3e9c4822ab5cdcccf4f8aa9dcd42117f736d51d9" }
+[[language]]
+name = "mail"
+scope = "text.mail"
+file-types = ["eml"]
+injection-regex = "mail|eml|email"
+
+[[grammar]]
+name = "mail"
+source = { git = "https://github.com/ficcdaf/tree-sitter-mail", rev = "8e60f38efbae1cc5f22833ae13c5500dd0f3b12f" }
+
[[language]]
name = "markdown"
scope = "source.md"
diff --git a/runtime/queries/mail/highlights.scm b/runtime/queries/mail/highlights.scm
new file mode 100644
index 000000000000..ed06b568f0a1
--- /dev/null
+++ b/runtime/queries/mail/highlights.scm
@@ -0,0 +1,28 @@
+; header fields
+[
+ (header_field_email)
+ (header_field_subject)
+ (header_field)
+] @keyword
+
+; delimited punctuation
+(header_separator) @punctuation.delimiter
+(email_delimiter) @punctuation.delimiter
+
+; email subject contents
+(header_subject
+ (subject) @markup.bold)
+; extra metadata headers
+(header_other
+ (header_unstructured) @comment)
+
+; Addressee Name (Firstname, Lastname, etc.)
+(atom) @variable
+
+; Email Address
+(email) @string
+
+; Quoted Reply
+(quote_marker) @punctuation.special
+(quote_contents) @markup.quote
+
diff --git a/runtime/queries/mail/textobjects.scm b/runtime/queries/mail/textobjects.scm
new file mode 100644
index 000000000000..07191dc69ec7
--- /dev/null
+++ b/runtime/queries/mail/textobjects.scm
@@ -0,0 +1,13 @@
+(atom_block
+ (atom) @entry.inside) @entry.around
+
+(email_address) @entry.around
+(header_other
+ (header_unstructured) @entry.around)
+
+(quoted_block)+ @comment.around
+
+(body_block)+ @function.around
+
+(header_subject
+ (subject) @function.around)
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 833196b6b54c..54cb4741fe03 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -134,6 +134,7 @@
| log | β | | | |
| lpf | β | | | |
| lua | β | β | β | `lua-language-server` |
+| mail | β | β | | |
| make | β | | β | |
| markdoc | β | | | `markdoc-ls` |
| markdown | β | | | `marksman`, `markdown-oxide` |
diff --git a/languages.toml b/languages.toml
index 321f1864b7ba..6f391e14e426 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1670,6 +1670,16 @@ injection-regex = "tablegen"
name = "tablegen"
source = { git = "https://github.com/Flakebi/tree-sitter-tablegen", rev = "3e9c4822ab5cdcccf4f8aa9dcd42117f736d51d9" }
+scope = "text.mail"
+file-types = ["eml"]
+injection-regex = "mail|eml|email"
+[[grammar]]
+source = { git = "https://github.com/ficcdaf/tree-sitter-mail", rev = "8e60f38efbae1cc5f22833ae13c5500dd0f3b12f" }
[[language]]
name = "markdown"
scope = "source.md"
diff --git a/runtime/queries/mail/highlights.scm b/runtime/queries/mail/highlights.scm
index 000000000000..ed06b568f0a1
+++ b/runtime/queries/mail/highlights.scm
@@ -0,0 +1,28 @@
+; header fields
+ (header_field_email)
+ (header_field_subject)
+ (header_field)
+] @keyword
+; delimited punctuation
+(header_separator) @punctuation.delimiter
+(email_delimiter) @punctuation.delimiter
+; email subject contents
+ (subject) @markup.bold)
+; extra metadata headers
+ (header_unstructured) @comment)
+; Addressee Name (Firstname, Lastname, etc.)
+(atom) @variable
+; Email Address
+(email) @string
+(quote_marker) @punctuation.special
+(quote_contents) @markup.quote
diff --git a/runtime/queries/mail/textobjects.scm b/runtime/queries/mail/textobjects.scm
index 000000000000..07191dc69ec7
+++ b/runtime/queries/mail/textobjects.scm
@@ -0,0 +1,13 @@
+ (atom) @entry.inside) @entry.around
+(email_address) @entry.around
+ (header_unstructured) @entry.around)
+(quoted_block)+ @comment.around
+(body_block)+ @function.around
+ (subject) @function.around) | [
"+[[language]]",
"+[",
"+; Quoted Reply",
"+(atom_block"
] | [
20,
40,
63,
73
] | {
"additions": 52,
"author": "ficcdaf",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/12945",
"issue_id": 12945,
"merged_at": "2025-02-26T23:33:36Z",
"omission_probability": 0.1,
"pr_number": 12945,
"repo": "helix-editor/helix",
"title": "feat: language support for mail files",
"total_changes": 52
} |
289 | diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 130428d4d7b7..1ef4d4bd9762 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -407,6 +407,13 @@ pub fn symbol_picker(cx: &mut Context) {
ui::PickerColumn::new("name", |item: &SymbolInformationItem, _| {
item.symbol.name.as_str().into()
}),
+ ui::PickerColumn::new("container", |item: &SymbolInformationItem, _| {
+ item.symbol
+ .container_name
+ .as_deref()
+ .unwrap_or_default()
+ .into()
+ }),
];
let picker = Picker::new(
@@ -508,6 +515,13 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
item.symbol.name.as_str().into()
})
.without_filtering(),
+ ui::PickerColumn::new("container", |item: &SymbolInformationItem, _| {
+ item.symbol
+ .container_name
+ .as_deref()
+ .unwrap_or_default()
+ .into()
+ }),
ui::PickerColumn::new("path", |item: &SymbolInformationItem, _| {
if let Some(path) = item.location.uri.as_path() {
path::get_relative_path(path)
| diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 130428d4d7b7..1ef4d4bd9762 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -407,6 +407,13 @@ pub fn symbol_picker(cx: &mut Context) {
ui::PickerColumn::new("name", |item: &SymbolInformationItem, _| {
item.symbol.name.as_str().into()
}),
+ ui::PickerColumn::new("container", |item: &SymbolInformationItem, _| {
+ item.symbol
+ .container_name
+ .as_deref()
+ .unwrap_or_default()
+ .into()
+ }),
];
let picker = Picker::new(
@@ -508,6 +515,13 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
item.symbol.name.as_str().into()
})
.without_filtering(),
+ ui::PickerColumn::new("container", |item: &SymbolInformationItem, _| {
+ item.symbol
+ .container_name
+ .as_deref()
+ .unwrap_or_default()
+ .into()
+ }),
ui::PickerColumn::new("path", |item: &SymbolInformationItem, _| {
if let Some(path) = item.location.uri.as_path() {
path::get_relative_path(path) | [] | [] | {
"additions": 14,
"author": "winged",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/12930",
"issue_id": 12930,
"merged_at": "2025-02-26T23:28:34Z",
"omission_probability": 0.1,
"pr_number": 12930,
"repo": "helix-editor/helix",
"title": "feat(lsp): add container name as a column in the symbol pickers",
"total_changes": 14
} |
290 | diff --git a/Cargo.lock b/Cargo.lock
index d20f1e4dba20..68ad112498a7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,9 +68,9 @@ dependencies = [
[[package]]
name = "anyhow"
-version = "1.0.95"
+version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
+checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
[[package]]
name = "arc-swap"
@@ -136,9 +136,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "cc"
-version = "1.2.14"
+version = "1.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
+checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af"
dependencies = [
"shlex",
]
@@ -1856,9 +1856,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.169"
+version = "0.2.170"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
+checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
[[package]]
name = "libloading"
@@ -1905,9 +1905,9 @@ dependencies = [
[[package]]
name = "log"
-version = "0.4.25"
+version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
+checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[package]]
name = "maybe-async"
@@ -2274,18 +2274,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
-version = "1.0.217"
+version = "1.0.218"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
+checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.217"
+version = "1.0.218"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
+checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
dependencies = [
"proc-macro2",
"quote",
@@ -2294,9 +2294,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.138"
+version = "1.0.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
+checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
dependencies = [
"itoa",
"memchr",
diff --git a/helix-lsp-types/Cargo.toml b/helix-lsp-types/Cargo.toml
index 3672d99c6492..118bcc07ed56 100644
--- a/helix-lsp-types/Cargo.toml
+++ b/helix-lsp-types/Cargo.toml
@@ -22,8 +22,8 @@ license = "MIT"
[dependencies]
bitflags.workspace = true
-serde = { version = "1.0.217", features = ["derive"] }
-serde_json = "1.0.138"
+serde = { version = "1.0.218", features = ["derive"] }
+serde_json = "1.0.139"
url = {version = "2.5.4", features = ["serde"]}
[features]
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 43066354d18d..bbad37f07c18 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -93,7 +93,7 @@ grep-searcher = "0.1.14"
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
-libc = "0.2.169"
+libc = "0.2.170"
[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc"] }
| diff --git a/Cargo.lock b/Cargo.lock
index d20f1e4dba20..68ad112498a7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,9 +68,9 @@ dependencies = [
name = "anyhow"
-version = "1.0.95"
+version = "1.0.96"
-checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
+checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
name = "arc-swap"
@@ -136,9 +136,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
name = "cc"
-version = "1.2.14"
+version = "1.2.15"
-checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
+checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af"
"shlex",
@@ -1856,9 +1856,9 @@ dependencies = [
name = "libc"
-version = "0.2.169"
+version = "0.2.170"
-checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
+checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
name = "libloading"
@@ -1905,9 +1905,9 @@ dependencies = [
name = "log"
-version = "0.4.25"
+version = "0.4.26"
-checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
+checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
name = "maybe-async"
@@ -2274,18 +2274,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
name = "serde"
-checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
+checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
"serde_derive",
name = "serde_derive"
-checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
+checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
"proc-macro2",
"quote",
@@ -2294,9 +2294,9 @@ dependencies = [
name = "serde_json"
-version = "1.0.138"
+version = "1.0.139"
-checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
+checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6"
"itoa",
"memchr",
diff --git a/helix-lsp-types/Cargo.toml b/helix-lsp-types/Cargo.toml
index 3672d99c6492..118bcc07ed56 100644
--- a/helix-lsp-types/Cargo.toml
+++ b/helix-lsp-types/Cargo.toml
@@ -22,8 +22,8 @@ license = "MIT"
[dependencies]
bitflags.workspace = true
-serde = { version = "1.0.217", features = ["derive"] }
+serde = { version = "1.0.218", features = ["derive"] }
+serde_json = "1.0.139"
url = {version = "2.5.4", features = ["serde"]}
[features]
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 43066354d18d..bbad37f07c18 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -93,7 +93,7 @@ grep-searcher = "0.1.14"
[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
-libc = "0.2.169"
+libc = "0.2.170"
[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc"] } | [
"-serde_json = \"1.0.138\""
] | [
96
] | {
"additions": 17,
"author": "dependabot[bot]",
"deletions": 17,
"html_url": "https://github.com/helix-editor/helix/pull/12956",
"issue_id": 12956,
"merged_at": "2025-02-25T00:05:25Z",
"omission_probability": 0.1,
"pr_number": 12956,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group with 6 updates",
"total_changes": 34
} |
291 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 0e6c60729980..833196b6b54c 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -121,7 +121,7 @@
| just | β | β | β | |
| kdl | β | β | β | |
| koka | β | | β | `koka` |
-| kotlin | β | | | `kotlin-language-server` |
+| kotlin | β | β | β | `kotlin-language-server` |
| koto | β | β | β | `koto-ls` |
| latex | β | β | | `texlab` |
| ld | β | | β | |
diff --git a/languages.toml b/languages.toml
index 01c0181ffcae..321f1864b7ba 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1940,7 +1940,7 @@ language-servers = [ "kotlin-language-server" ]
[[grammar]]
name = "kotlin"
-source = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569" }
+source = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "c4ddea359a7ff4d92360b2efcd6cfce5dc25afe6" }
[[language]]
name = "hcl"
diff --git a/runtime/queries/kotlin/highlights.scm b/runtime/queries/kotlin/highlights.scm
index 11fae331718f..68b08c3d13fa 100644
--- a/runtime/queries/kotlin/highlights.scm
+++ b/runtime/queries/kotlin/highlights.scm
@@ -68,19 +68,10 @@
"->"
] @operator
-(multi_line_string_literal
+(string_literal
"$" @punctuation
(interpolated_identifier) @none)
-(multi_line_string_literal
- "${" @punctuation
- (interpolated_expression) @none
- "}" @punctuation.)
-
-; NOTE: `interpolated_identifier`s can be highlighted in any way
-(line_string_literal
- "$" @punctuation
- (interpolated_identifier) @none)
-(line_string_literal
+(string_literal
"${" @punctuation
(interpolated_expression) @none
"}" @punctuation)
@@ -108,6 +99,7 @@
"class"
"object"
"interface"
+ "companion"
; "typeof" ; NOTE: It is reserved for future use
] @keyword
@@ -156,17 +148,14 @@
;;; Literals
; NOTE: Escapes not allowed in multi-line strings
-(line_string_literal (character_escape_seq) @constant.character.escape)
+(character_literal (character_escape_seq) @constant.character.escape)
-[
- (line_string_literal)
- (multi_line_string_literal)
-] @string
+(string_literal) @string
(character_literal) @constant.character
[
- "null" ; should be highlighted the same as booleans
+ (null_literal) ; should be highlighted the same as booleans
(boolean_literal)
] @constant.builtin.boolean
@@ -180,7 +169,8 @@
] @constant.numeric.integer
[
- (comment)
+ (line_comment)
+ (multiline_comment)
(shebang_line)
] @comment
diff --git a/runtime/queries/kotlin/indents.scm b/runtime/queries/kotlin/indents.scm
new file mode 100644
index 000000000000..6fe73aec3cce
--- /dev/null
+++ b/runtime/queries/kotlin/indents.scm
@@ -0,0 +1,44 @@
+[
+ (class_body)
+ (enum_class_body)
+ (lambda_literal)
+
+ ; _block is hidden in the grammar, so list all public wrappers explicitly.
+ (function_body)
+ (anonymous_initializer)
+ (control_structure_body)
+ (secondary_constructor)
+ (try_expression)
+ (catch_block)
+ (finally_block)
+
+ (property_declaration)
+ (assignment)
+
+ (when_expression)
+ (call_expression)
+ (if_expression)
+
+ ; Binary expressions
+ (multiplicative_expression)
+ (additive_expression)
+ (range_expression)
+ (infix_expression)
+ (elvis_expression)
+ (check_expression)
+ (comparison_expression)
+ (equality_expression)
+ (comparison_expression)
+ (equality_expression)
+ (conjunction_expression)
+ (disjunction_expression)
+
+ (call_suffix)
+ (function_value_parameters)
+] @indent
+
+[
+ "}"
+ ")"
+ "]"
+] @outdent
diff --git a/runtime/queries/kotlin/injections.scm b/runtime/queries/kotlin/injections.scm
index abdc20502448..40640d2bcf1b 100644
--- a/runtime/queries/kotlin/injections.scm
+++ b/runtime/queries/kotlin/injections.scm
@@ -1,11 +1,15 @@
-((comment) @injection.content
+([
+ (line_comment)
+ (multiline_comment)
+ ] @injection.content
(#set! injection.language "comment"))
; There are 3 ways to define a regex
; - "[abc]?".toRegex()
((call_expression
(navigation_expression
- ([(line_string_literal) (multi_line_string_literal)] @injection.content)
+ (string_literal
+ (string_content) @injection.content)
(navigation_suffix
((simple_identifier) @_function
(#eq? @_function "toRegex")))))
@@ -18,7 +22,8 @@
(call_suffix
(value_arguments
(value_argument
- [ (line_string_literal) (multi_line_string_literal) ] @injection.content))))
+ (string_literal
+ (string_content) @injection.content)))))
(#set! injection.language "regex"))
; - Regex.fromLiteral("[abc]?")
@@ -32,5 +37,6 @@
(call_suffix
(value_arguments
(value_argument
- [ (line_string_literal) (multi_line_string_literal) ] @injection.content))))
+ (string_literal
+ (string_content) @injection.content)))))
(#set! injection.language "regex"))
diff --git a/runtime/queries/kotlin/textobjects.scm b/runtime/queries/kotlin/textobjects.scm
new file mode 100644
index 000000000000..46bb26b2ed67
--- /dev/null
+++ b/runtime/queries/kotlin/textobjects.scm
@@ -0,0 +1,42 @@
+(function_declaration
+ (function_body)? @function.inside) @function.around
+
+; Unlike function_body above, the constructor body is does not have its own
+; symbol in the current grammar.
+(secondary_constructor) @function.around
+
+(class_declaration
+ (class_body)? @class.inside) @class.around
+
+(class_declaration
+ (enum_class_body) @class.inside) @class.around
+
+[
+ (line_comment)
+ (multiline_comment)
+] @comment.inside
+
+(line_comment)+ @comment.around
+
+(multiline_comment) @comment.around
+
+(enum_entry) @entry.around
+(lambda_literal) @entry.around
+(property_declaration) @entry.around
+(object_declaration) @entry.around
+(assignment) @entry.around
+
+; TODO: This doesn't work with annotations yet, but fixing it without breaking
+; the case of multiple parameters is non-trivial.
+(function_value_parameters
+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
+
+; secondary constructor uses function_value_parameters above
+(primary_constructor
+ ((_)@parameter.inside . ","? @parameter.around) @parameter.around)
+
+(function_type_parameters
+ ((_)@parameter.inside . ","? @parameter.around) @parameter.around)
+
+(value_arguments
+ ((_)@parameter.inside . ","? @parameter.around) @parameter.around)
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 0e6c60729980..833196b6b54c 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -121,7 +121,7 @@
| just | β | β | β | |
| kdl | β | β | β | |
| koka | β | | β | `koka` |
-| kotlin | β | | | `kotlin-language-server` |
+| kotlin | β | β | β | `kotlin-language-server` |
| koto | β | β | β | `koto-ls` |
| latex | β | β | | `texlab` |
| ld | β | | β | |
diff --git a/languages.toml b/languages.toml
index 01c0181ffcae..321f1864b7ba 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1940,7 +1940,7 @@ language-servers = [ "kotlin-language-server" ]
[[grammar]]
name = "kotlin"
-source = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "a4f71eb9b8c9b19ded3e0e9470be4b1b77c2b569" }
+source = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "c4ddea359a7ff4d92360b2efcd6cfce5dc25afe6" }
[[language]]
name = "hcl"
diff --git a/runtime/queries/kotlin/highlights.scm b/runtime/queries/kotlin/highlights.scm
index 11fae331718f..68b08c3d13fa 100644
--- a/runtime/queries/kotlin/highlights.scm
+++ b/runtime/queries/kotlin/highlights.scm
@@ -68,19 +68,10 @@
"->"
] @operator
"$" @punctuation
(interpolated_identifier) @none)
- "${" @punctuation
- (interpolated_expression) @none
- "}" @punctuation.)
-
-; NOTE: `interpolated_identifier`s can be highlighted in any way
- "$" @punctuation
- (interpolated_identifier) @none)
"${" @punctuation
(interpolated_expression) @none
"}" @punctuation)
@@ -108,6 +99,7 @@
"class"
"object"
"interface"
+ "companion"
; "typeof" ; NOTE: It is reserved for future use
] @keyword
@@ -156,17 +148,14 @@
;;; Literals
; NOTE: Escapes not allowed in multi-line strings
-(line_string_literal (character_escape_seq) @constant.character.escape)
+(character_literal (character_escape_seq) @constant.character.escape)
-[
- (line_string_literal)
- (multi_line_string_literal)
-] @string
+(string_literal) @string
(character_literal) @constant.character
- "null" ; should be highlighted the same as booleans
+ (null_literal) ; should be highlighted the same as booleans
(boolean_literal)
] @constant.builtin.boolean
@@ -180,7 +169,8 @@
] @constant.numeric.integer
+ (line_comment)
+ (multiline_comment)
(shebang_line)
] @comment
diff --git a/runtime/queries/kotlin/indents.scm b/runtime/queries/kotlin/indents.scm
index 000000000000..6fe73aec3cce
+++ b/runtime/queries/kotlin/indents.scm
@@ -0,0 +1,44 @@
+ (class_body)
+ (enum_class_body)
+ (lambda_literal)
+ (function_body)
+ (anonymous_initializer)
+ (control_structure_body)
+ (secondary_constructor)
+ (try_expression)
+ (catch_block)
+ (finally_block)
+ (property_declaration)
+ (assignment)
+ (when_expression)
+ (if_expression)
+ ; Binary expressions
+ (multiplicative_expression)
+ (additive_expression)
+ (range_expression)
+ (infix_expression)
+ (elvis_expression)
+ (check_expression)
+ (conjunction_expression)
+ (call_suffix)
+ (function_value_parameters)
+] @indent
+ "}"
+ "]"
+] @outdent
diff --git a/runtime/queries/kotlin/injections.scm b/runtime/queries/kotlin/injections.scm
index abdc20502448..40640d2bcf1b 100644
--- a/runtime/queries/kotlin/injections.scm
+++ b/runtime/queries/kotlin/injections.scm
@@ -1,11 +1,15 @@
-((comment) @injection.content
+([
+ ] @injection.content
(#set! injection.language "comment"))
; There are 3 ways to define a regex
; - "[abc]?".toRegex()
((call_expression
(navigation_expression
- ([(line_string_literal) (multi_line_string_literal)] @injection.content)
+ (string_literal
+ (string_content) @injection.content)
(navigation_suffix
((simple_identifier) @_function
(#eq? @_function "toRegex")))))
@@ -18,7 +22,8 @@
; - Regex.fromLiteral("[abc]?")
@@ -32,5 +37,6 @@
diff --git a/runtime/queries/kotlin/textobjects.scm b/runtime/queries/kotlin/textobjects.scm
index 000000000000..46bb26b2ed67
+++ b/runtime/queries/kotlin/textobjects.scm
@@ -0,0 +1,42 @@
+(function_declaration
+ (function_body)? @function.inside) @function.around
+; Unlike function_body above, the constructor body is does not have its own
+(secondary_constructor) @function.around
+ (class_body)? @class.inside) @class.around
+ (enum_class_body) @class.inside) @class.around
+] @comment.inside
+(line_comment)+ @comment.around
+(multiline_comment) @comment.around
+(enum_entry) @entry.around
+(lambda_literal) @entry.around
+(property_declaration) @entry.around
+(object_declaration) @entry.around
+(assignment) @entry.around
+; TODO: This doesn't work with annotations yet, but fixing it without breaking
+; the case of multiple parameters is non-trivial.
+(function_value_parameters
+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
+; secondary constructor uses function_value_parameters above
+(function_type_parameters
+(value_arguments | [
"-\t(comment)",
"+ ; _block is hidden in the grammar, so list all public wrappers explicitly.",
"+ (call_expression)",
"+ (disjunction_expression)",
"+ \")\"",
"+; symbol in the current grammar.",
"+(primary_constructor"
] | [
85,
102,
115,
130,
138,
191,
221
] | {
"additions": 106,
"author": "sdoerner",
"deletions": 24,
"html_url": "https://github.com/helix-editor/helix/pull/12925",
"issue_id": 12925,
"merged_at": "2025-02-20T17:58:28Z",
"omission_probability": 0.1,
"pr_number": 12925,
"repo": "helix-editor/helix",
"title": "Add indents and textobjects for Kotlin.",
"total_changes": 130
} |
292 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 102f4dc4ade0..2338c28e59b2 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -182,7 +182,7 @@
| ron | β | | β | | |
| rst | β | | | | |
| ruby | β | β | β | | `solargraph` |
-| rust | β | β | β | | `rust-analyzer` |
+| rust | β | β | β | β | `rust-analyzer` |
| sage | β | β | | | |
| scala | β | β | β | | `metals` |
| scheme | β | | β | | |
diff --git a/runtime/queries/rust/symbols.scm b/runtime/queries/rust/symbols.scm
new file mode 100644
index 000000000000..8d0dae31ee79
--- /dev/null
+++ b/runtime/queries/rust/symbols.scm
@@ -0,0 +1,33 @@
+(struct_item
+ name: (type_identifier) @definition.struct
+ body: (field_declaration_list))
+
+(const_item
+ name: (identifier) @definition.constant)
+
+(trait_item
+ name: (type_identifier) @definition.interface
+ body: (declaration_list))
+
+(function_item
+ name: (identifier) @definition.function
+ parameters: (parameters)
+ body: (block))
+
+(function_signature_item
+ name: (identifier) @definition.function
+ parameters: (parameters))
+
+(enum_item
+ name: (type_identifier) @definition.type
+ body: (enum_variant_list))
+
+(enum_variant
+ name: (identifier) @definition.struct)
+
+(mod_item
+ name: (identifier) @definition.module
+ body: (declaration_list))
+
+(macro_definition
+ macro: (identifier) @definition.macro)
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 102f4dc4ade0..2338c28e59b2 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -182,7 +182,7 @@
| ron | β | | β | | |
| rst | β | | | | |
| ruby | β | β | β | | `solargraph` |
-| rust | β | β | β | | `rust-analyzer` |
+| rust | β | β | β | β | `rust-analyzer` |
| sage | β | β | | | |
| scala | β | β | β | | `metals` |
| scheme | β | | β | | |
diff --git a/runtime/queries/rust/symbols.scm b/runtime/queries/rust/symbols.scm
new file mode 100644
index 000000000000..8d0dae31ee79
--- /dev/null
+++ b/runtime/queries/rust/symbols.scm
@@ -0,0 +1,33 @@
+(struct_item
+(const_item
+ name: (identifier) @definition.constant)
+(trait_item
+ name: (type_identifier) @definition.interface
+(function_item
+ parameters: (parameters)
+ body: (block))
+(function_signature_item
+ parameters: (parameters))
+(enum_item
+ name: (type_identifier) @definition.type
+ body: (enum_variant_list))
+(enum_variant
+ name: (identifier) @definition.struct)
+(mod_item
+ name: (identifier) @definition.module
+(macro_definition
+ macro: (identifier) @definition.macro) | [
"+ name: (type_identifier) @definition.struct",
"+ body: (field_declaration_list))"
] | [
20,
21
] | {
"additions": 34,
"author": "EricHenry",
"deletions": 1,
"html_url": "https://github.com/helix-editor/helix/pull/12859",
"issue_id": 12859,
"merged_at": "2025-02-20T14:47:14Z",
"omission_probability": 0.1,
"pr_number": 12859,
"repo": "helix-editor/helix",
"title": "Rust symbol queries",
"total_changes": 35
} |
293 | diff --git a/Cargo.lock b/Cargo.lock
index c6b2efa1e72c..d20f1e4dba20 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -136,9 +136,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
[[package]]
name = "cc"
-version = "1.2.13"
+version = "1.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda"
+checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
dependencies = [
"shlex",
]
@@ -2393,9 +2393,9 @@ dependencies = [
[[package]]
name = "smallvec"
-version = "1.13.2"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[package]]
name = "smartstring"
@@ -2466,9 +2466,9 @@ dependencies = [
[[package]]
name = "tempfile"
-version = "3.16.0"
+version = "3.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91"
+checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230"
dependencies = [
"cfg-if",
"fastrand",
diff --git a/Cargo.toml b/Cargo.toml
index ab0f8b48d7c7..da53c192e5cb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.16.0"
+tempfile = "3.17.1"
bitflags = "2.8"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index e834582f33ea..4f9cfd86cf58 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -21,7 +21,7 @@ helix-loader = { path = "../helix-loader" }
helix-parsec = { path = "../helix-parsec" }
ropey.workspace = true
-smallvec = "1.13"
+smallvec = "1.14"
smartstring = "1.0.1"
unicode-segmentation.workspace = true
# unicode-width is changing width definitions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 39b6b86715fb..43066354d18d 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -102,7 +102,7 @@ crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc
helix-loader = { path = "../helix-loader" }
[dev-dependencies]
-smallvec = "1.13"
+smallvec = "1.14"
indoc = "2.0.5"
tempfile.workspace = true
same-file = "1.0.1"
| diff --git a/Cargo.lock b/Cargo.lock
index c6b2efa1e72c..d20f1e4dba20 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -136,9 +136,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
name = "cc"
-version = "1.2.13"
+version = "1.2.14"
-checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda"
+checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
"shlex",
]
@@ -2393,9 +2393,9 @@ dependencies = [
name = "smallvec"
-version = "1.13.2"
+version = "1.14.0"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
name = "smartstring"
@@ -2466,9 +2466,9 @@ dependencies = [
name = "tempfile"
-version = "3.16.0"
+version = "3.17.1"
-checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91"
+checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230"
"cfg-if",
"fastrand",
diff --git a/Cargo.toml b/Cargo.toml
index ab0f8b48d7c7..da53c192e5cb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,7 +41,7 @@ tree-sitter = { version = "0.22" }
nucleo = "0.5.0"
slotmap = "1.0.7"
thiserror = "2.0"
-tempfile = "3.16.0"
+tempfile = "3.17.1"
bitflags = "2.8"
unicode-segmentation = "1.2"
ropey = { version = "1.6.1", default-features = false, features = ["simd"] }
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index e834582f33ea..4f9cfd86cf58 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -21,7 +21,7 @@ helix-loader = { path = "../helix-loader" }
helix-parsec = { path = "../helix-parsec" }
ropey.workspace = true
smartstring = "1.0.1"
unicode-segmentation.workspace = true
# unicode-width is changing width definitions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 39b6b86715fb..43066354d18d 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -102,7 +102,7 @@ crossterm = { version = "0.28", features = ["event-stream", "use-dev-tty", "libc
helix-loader = { path = "../helix-loader" }
[dev-dependencies]
indoc = "2.0.5"
tempfile.workspace = true
same-file = "1.0.1" | [] | [] | {
"additions": 9,
"author": "dependabot[bot]",
"deletions": 9,
"html_url": "https://github.com/helix-editor/helix/pull/12903",
"issue_id": 12903,
"merged_at": "2025-02-17T23:36:50Z",
"omission_probability": 0.1,
"pr_number": 12903,
"repo": "helix-editor/helix",
"title": "build(deps): bump the rust-dependencies group with 3 updates",
"total_changes": 18
} |
294 | diff --git a/runtime/queries/nix/injections.scm b/runtime/queries/nix/injections.scm
index 6b4ddc1f42c9..a7d4e4d192d5 100644
--- a/runtime/queries/nix/injections.scm
+++ b/runtime/queries/nix/injections.scm
@@ -167,6 +167,67 @@
(#set! injection.language "python")
(#set! injection.combined))
+; pkgs.writers.writeNu[Bin] name attrs content
+(apply_expression
+ (apply_expression
+ function: (apply_expression
+ function: ((_) @_func)))
+ argument: (indented_string_expression (string_fragment) @injection.content)
+ (#match? @_func "(^|\\.)writeNu(Bin)?$")
+ (#set! injection.language "nu")
+ (#set! injection.combined))
+
+; pkgs.writers.writeRuby[Bin] name attrs content
+(apply_expression
+ (apply_expression
+ function: (apply_expression
+ function: ((_) @_func)))
+ argument: (indented_string_expression (string_fragment) @injection.content)
+ (#match? @_func "(^|\\.)writeRuby(Bin)?$")
+ (#set! injection.language "ruby")
+ (#set! injection.combined))
+
+; pkgs.writers.writeLua[Bin] name attrs content
+(apply_expression
+ (apply_expression
+ function: (apply_expression
+ function: ((_) @_func)))
+ argument: (indented_string_expression (string_fragment) @injection.content)
+ (#match? @_func "(^|\\.)writeLua(Bin)?$")
+ (#set! injection.language "lua")
+ (#set! injection.combined))
+
+; pkgs.writers.writeNginxConfig name attrs content
+(apply_expression
+ (apply_expression
+ function: (apply_expression
+ function: ((_) @_func)))
+ argument: (indented_string_expression (string_fragment) @injection.content)
+ (#match? @_func "(^|\\.)writeNginxConfig$")
+ (#set! injection.language "nginx")
+ (#set! injection.combined))
+
+; pkgs.writers.writeGuile[Bin] name attrs content
+(apply_expression
+ (apply_expression
+ function: (apply_expression
+ function: ((_) @_func)))
+ argument: (indented_string_expression (string_fragment) @injection.content)
+ (#match? @_func "(^|\\.)writeGuile(Bin)?$")
+ (#set! injection.language "scheme") ; Guile is a GNU specific implementation of scheme
+ (#set! injection.combined))
+
+
+; pkgs.writers.writeBabashka[Bin] name attrs content
+(apply_expression
+ (apply_expression
+ function: (apply_expression
+ function: ((_) @_func)))
+ argument: (indented_string_expression (string_fragment) @injection.content)
+ (#match? @_func "(^|\\.)writeBabashka(Bin)?$")
+ (#set! injection.language "clojure")
+ (#set! injection.combined))
+
; pkgs.writers.writeFSharp[Bin] name content
; No query available for f-sharp as of the time of writing
; See: https://github.com/helix-editor/helix/issues/4943
| diff --git a/runtime/queries/nix/injections.scm b/runtime/queries/nix/injections.scm
index 6b4ddc1f42c9..a7d4e4d192d5 100644
--- a/runtime/queries/nix/injections.scm
+++ b/runtime/queries/nix/injections.scm
@@ -167,6 +167,67 @@
(#set! injection.language "python")
(#set! injection.combined))
+; pkgs.writers.writeNu[Bin] name attrs content
+ (#match? @_func "(^|\\.)writeNu(Bin)?$")
+ (#set! injection.language "nu")
+; pkgs.writers.writeRuby[Bin] name attrs content
+ (#match? @_func "(^|\\.)writeRuby(Bin)?$")
+ (#set! injection.language "ruby")
+; pkgs.writers.writeLua[Bin] name attrs content
+ (#match? @_func "(^|\\.)writeLua(Bin)?$")
+ (#set! injection.language "lua")
+; pkgs.writers.writeNginxConfig name attrs content
+ (#match? @_func "(^|\\.)writeNginxConfig$")
+ (#set! injection.language "nginx")
+; pkgs.writers.writeGuile[Bin] name attrs content
+ (#match? @_func "(^|\\.)writeGuile(Bin)?$")
+ (#match? @_func "(^|\\.)writeBabashka(Bin)?$")
; pkgs.writers.writeFSharp[Bin] name content
; No query available for f-sharp as of the time of writing
; See: https://github.com/helix-editor/helix/issues/4943 | [
"+ (#set! injection.language \"scheme\") ; Guile is a GNU specific implementation of scheme",
"+; pkgs.writers.writeBabashka[Bin] name attrs content",
"+ (#set! injection.language \"clojure\")"
] | [
55,
59,
66
] | {
"additions": 61,
"author": "kpbaks",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/12774",
"issue_id": 12774,
"merged_at": "2025-02-10T20:46:53Z",
"omission_probability": 0.1,
"pr_number": 12774,
"repo": "helix-editor/helix",
"title": "feat: add mising pkgs.writers.write* nix tree-sitter injections",
"total_changes": 61
} |
295 | diff --git a/languages.toml b/languages.toml
index 945082a3c572..d09ee76da2ad 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2137,7 +2137,7 @@ injection-regex = "sql"
[[grammar]]
name = "sql"
-source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "da2d1eff425b146d3c8cab7be8dfa98b11d896dc" }
+source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "b9d109588d5b5ed986c857464830c2f0bef53f18" }
[[language]]
name = "gdscript"
diff --git a/runtime/queries/sql/highlights.scm b/runtime/queries/sql/highlights.scm
index e575debc572a..82397edcecb4 100644
--- a/runtime/queries/sql/highlights.scm
+++ b/runtime/queries/sql/highlights.scm
@@ -110,6 +110,8 @@
(keyword_primary)
(keyword_delete)
(keyword_create)
+ (keyword_show)
+ (keyword_unload)
(keyword_insert)
(keyword_merge)
(keyword_distinct)
@@ -147,9 +149,6 @@
(keyword_for)
(keyword_if)
(keyword_exists)
- (keyword_max)
- (keyword_min)
- (keyword_avg)
(keyword_column)
(keyword_columns)
(keyword_cross)
@@ -195,7 +194,6 @@
(keyword_current)
(keyword_ties)
(keyword_others)
- (keyword_preserve)
(keyword_zerofill)
(keyword_format)
(keyword_fields)
@@ -219,7 +217,6 @@
(keyword_vacuum)
(keyword_cache)
(keyword_language)
- (keyword_sql)
(keyword_called)
(keyword_conflict)
(keyword_declare)
@@ -229,8 +226,6 @@
(keyword_name)
(keyword_oid)
(keyword_oids)
- (keyword_options)
- (keyword_plpgsql)
(keyword_precision)
(keyword_regclass)
(keyword_regnamespace)
@@ -274,6 +269,7 @@
(keyword_out)
(keyword_inout)
(keyword_variadic)
+ (keyword_ordinality)
(keyword_session)
(keyword_isolation)
(keyword_level)
@@ -304,6 +300,25 @@
(keyword_statement)
(keyword_execute)
(keyword_procedure)
+ (keyword_copy)
+ (keyword_delimiter)
+ (keyword_encoding)
+ (keyword_escape)
+ (keyword_force_not_null)
+ (keyword_force_null)
+ (keyword_force_quote)
+ (keyword_freeze)
+ (keyword_header)
+ (keyword_match)
+ (keyword_program)
+ (keyword_quote)
+ (keyword_stdin)
+ (keyword_extended)
+ (keyword_main)
+ (keyword_plain)
+ (keyword_storage)
+ (keyword_compression)
+ (keyword_duplicate)
] @keyword
[
| diff --git a/languages.toml b/languages.toml
index 945082a3c572..d09ee76da2ad 100644
--- a/languages.toml
+++ b/languages.toml
@@ -2137,7 +2137,7 @@ injection-regex = "sql"
[[grammar]]
name = "sql"
-source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "da2d1eff425b146d3c8cab7be8dfa98b11d896dc" }
+source = { git = "https://github.com/DerekStride/tree-sitter-sql", rev = "b9d109588d5b5ed986c857464830c2f0bef53f18" }
[[language]]
name = "gdscript"
diff --git a/runtime/queries/sql/highlights.scm b/runtime/queries/sql/highlights.scm
index e575debc572a..82397edcecb4 100644
--- a/runtime/queries/sql/highlights.scm
+++ b/runtime/queries/sql/highlights.scm
@@ -110,6 +110,8 @@
(keyword_primary)
(keyword_delete)
(keyword_create)
+ (keyword_show)
+ (keyword_unload)
(keyword_insert)
(keyword_merge)
(keyword_distinct)
@@ -147,9 +149,6 @@
(keyword_for)
(keyword_if)
(keyword_exists)
- (keyword_max)
- (keyword_min)
- (keyword_avg)
(keyword_column)
(keyword_columns)
(keyword_cross)
@@ -195,7 +194,6 @@
(keyword_current)
(keyword_ties)
(keyword_others)
- (keyword_preserve)
(keyword_zerofill)
(keyword_format)
(keyword_fields)
@@ -219,7 +217,6 @@
(keyword_vacuum)
(keyword_cache)
(keyword_language)
- (keyword_sql)
(keyword_called)
(keyword_conflict)
(keyword_declare)
@@ -229,8 +226,6 @@
(keyword_name)
(keyword_oid)
(keyword_oids)
- (keyword_options)
(keyword_precision)
(keyword_regclass)
(keyword_regnamespace)
@@ -274,6 +269,7 @@
(keyword_out)
(keyword_inout)
(keyword_variadic)
+ (keyword_ordinality)
(keyword_session)
(keyword_isolation)
(keyword_level)
@@ -304,6 +300,25 @@
(keyword_statement)
(keyword_execute)
(keyword_procedure)
+ (keyword_copy)
+ (keyword_delimiter)
+ (keyword_encoding)
+ (keyword_escape)
+ (keyword_force_not_null)
+ (keyword_force_null)
+ (keyword_force_quote)
+ (keyword_header)
+ (keyword_match)
+ (keyword_quote)
+ (keyword_stdin)
+ (keyword_main)
+ (keyword_plain)
+ (keyword_compression)
] @keyword
[ | [
"- (keyword_plpgsql)",
"+ (keyword_freeze)",
"+ (keyword_program)",
"+ (keyword_extended)",
"+ (keyword_storage)",
"+ (keyword_duplicate)"
] | [
57,
80,
83,
86,
89,
91
] | {
"additions": 23,
"author": "RoloEdits",
"deletions": 8,
"html_url": "https://github.com/helix-editor/helix/pull/12837",
"issue_id": 12837,
"merged_at": "2025-02-13T13:16:27Z",
"omission_probability": 0.1,
"pr_number": 12837,
"repo": "helix-editor/helix",
"title": "feat(sql): update tree-sitter files",
"total_changes": 31
} |
296 | diff --git a/runtime/themes/cyan_light.toml b/runtime/themes/cyan_light.toml
index 2ac57cd3249b..6273b0dd98b6 100644
--- a/runtime/themes/cyan_light.toml
+++ b/runtime/themes/cyan_light.toml
@@ -87,24 +87,25 @@
"bold",
] }
-"ui.statusline" = { fg = "shade06", bg = "shade02" }
-"ui.statusline.inactive" = { fg = "shade04", bg = "shade01" }
+"ui.statusline" = { fg = "shade06", bg = "shade01" }
+"ui.statusline.inactive" = { fg = "shade04", bg = "shade00" }
"ui.statusline.normal" = { fg = "shade00", bg = "blue" }
"ui.statusline.insert" = { fg = "shade00", bg = "green" }
"ui.statusline.select" = { fg = "shade00", bg = "purple" }
-"ui.popup" = { bg = "shade01", fg = "shade04" }
-"ui.window" = { bg = "shade00", fg = "shade04" }
-"ui.help" = { fg = "shade06", bg = "shade01" }
+"ui.popup" = { fg = "shade04", bg = "shade00" }
+"ui.window" = { fg = "shade04", bg = "shade00" }
+"ui.help" = { fg = "shade06", bg = "shade00" }
"ui.text" = "shade05"
"ui.text.focus" = { fg = "shade07", bg = "light_blue" }
+"ui.text.directory" = "blue"
"ui.virtual" = "shade03"
"ui.virtual.ruler" = { bg = "shade01" }
"ui.virtual.inlay-hint" = { fg = "shade03_darker" }
"ui.virtual.jump-label" = { fg = "shade07", bg = "shade01", modifiers = ["bold" ] }
-"ui.menu" = { fg = "shade05", bg = "shade01" }
+"ui.menu" = { fg = "shade05", bg = "shade01_lighter" }
"ui.menu.selected" = { fg = "shade07", bg = "light_blue" }
"hint" = "shade04"
@@ -130,6 +131,7 @@ shade05 = "#434b6c"
shade06 = "#343a54"
shade07 = "#25293c"
+shade01_lighter = "#e6e8f0"
shade03_darker = "#9199bb"
shade04_lighter = "#616d9d"
| diff --git a/runtime/themes/cyan_light.toml b/runtime/themes/cyan_light.toml
index 2ac57cd3249b..6273b0dd98b6 100644
--- a/runtime/themes/cyan_light.toml
+++ b/runtime/themes/cyan_light.toml
@@ -87,24 +87,25 @@
"bold",
] }
-"ui.statusline" = { fg = "shade06", bg = "shade02" }
-"ui.statusline.inactive" = { fg = "shade04", bg = "shade01" }
+"ui.statusline" = { fg = "shade06", bg = "shade01" }
"ui.statusline.normal" = { fg = "shade00", bg = "blue" }
"ui.statusline.insert" = { fg = "shade00", bg = "green" }
"ui.statusline.select" = { fg = "shade00", bg = "purple" }
-"ui.popup" = { bg = "shade01", fg = "shade04" }
-"ui.window" = { bg = "shade00", fg = "shade04" }
-"ui.help" = { fg = "shade06", bg = "shade01" }
+"ui.popup" = { fg = "shade04", bg = "shade00" }
+"ui.window" = { fg = "shade04", bg = "shade00" }
+"ui.help" = { fg = "shade06", bg = "shade00" }
"ui.text" = "shade05"
"ui.text.focus" = { fg = "shade07", bg = "light_blue" }
+"ui.text.directory" = "blue"
"ui.virtual" = "shade03"
"ui.virtual.ruler" = { bg = "shade01" }
"ui.virtual.inlay-hint" = { fg = "shade03_darker" }
"ui.virtual.jump-label" = { fg = "shade07", bg = "shade01", modifiers = ["bold" ] }
-"ui.menu" = { fg = "shade05", bg = "shade01" }
+"ui.menu" = { fg = "shade05", bg = "shade01_lighter" }
"ui.menu.selected" = { fg = "shade07", bg = "light_blue" }
"hint" = "shade04"
@@ -130,6 +131,7 @@ shade05 = "#434b6c"
shade06 = "#343a54"
shade07 = "#25293c"
+shade01_lighter = "#e6e8f0"
shade03_darker = "#9199bb"
shade04_lighter = "#616d9d" | [
"+\"ui.statusline.inactive\" = { fg = \"shade04\", bg = \"shade00\" }"
] | [
11
] | {
"additions": 8,
"author": "atahrijouti",
"deletions": 6,
"html_url": "https://github.com/helix-editor/helix/pull/12864",
"issue_id": 12864,
"merged_at": "2025-02-13T13:21:37Z",
"omission_probability": 0.1,
"pr_number": 12864,
"repo": "helix-editor/helix",
"title": "Cyan light UI grays and directory prompt",
"total_changes": 14
} |
297 | diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 9c48bf72382e..c5c53acd5ce7 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -678,10 +678,16 @@ pub(super) fn buffers_remaining_impl(editor: &mut Editor) -> anyhow::Result<()>
Ok(())
}
+#[derive(Debug, Clone, Copy)]
+pub struct WriteAllOptions {
+ pub force: bool,
+ pub write_scratch: bool,
+ pub auto_format: bool,
+}
+
pub fn write_all_impl(
cx: &mut compositor::Context,
- force: bool,
- write_scratch: bool,
+ options: WriteAllOptions,
) -> anyhow::Result<()> {
let mut errors: Vec<&'static str> = Vec::new();
let config = cx.editor.config();
@@ -699,7 +705,7 @@ pub fn write_all_impl(
return None;
}
if doc.path().is_none() {
- if write_scratch {
+ if options.write_scratch {
errors.push("cannot write a buffer without a filename");
}
return None;
@@ -722,14 +728,14 @@ pub fn write_all_impl(
// Save an undo checkpoint for any outstanding changes.
doc.append_changes_to_history(view);
- let fmt = if config.auto_format {
+ let fmt = if options.auto_format && config.auto_format {
doc.auto_format().map(|fmt| {
let callback = make_format_callback(
doc_id,
doc.version(),
target_view,
fmt,
- Some((None, force)),
+ Some((None, options.force)),
);
jobs.add(Job::with_callback(callback).wait_before_exiting());
})
@@ -738,11 +744,11 @@ pub fn write_all_impl(
};
if fmt.is_none() {
- cx.editor.save::<PathBuf>(doc_id, None, force)?;
+ cx.editor.save::<PathBuf>(doc_id, None, options.force)?;
}
}
- if !errors.is_empty() && !force {
+ if !errors.is_empty() && !options.force {
bail!("{:?}", errors);
}
@@ -758,7 +764,14 @@ fn write_all(
return Ok(());
}
- write_all_impl(cx, false, true)
+ write_all_impl(
+ cx,
+ WriteAllOptions {
+ force: false,
+ write_scratch: true,
+ auto_format: true,
+ },
+ )
}
fn force_write_all(
@@ -770,7 +783,14 @@ fn force_write_all(
return Ok(());
}
- write_all_impl(cx, true, true)
+ write_all_impl(
+ cx,
+ WriteAllOptions {
+ force: true,
+ write_scratch: true,
+ auto_format: true,
+ },
+ )
}
fn write_all_quit(
@@ -781,7 +801,14 @@ fn write_all_quit(
if event != PromptEvent::Validate {
return Ok(());
}
- write_all_impl(cx, false, true)?;
+ write_all_impl(
+ cx,
+ WriteAllOptions {
+ force: false,
+ write_scratch: true,
+ auto_format: true,
+ },
+ )?;
quit_all_impl(cx, false)
}
@@ -793,7 +820,14 @@ fn force_write_all_quit(
if event != PromptEvent::Validate {
return Ok(());
}
- let _ = write_all_impl(cx, true, true);
+ let _ = write_all_impl(
+ cx,
+ WriteAllOptions {
+ force: true,
+ write_scratch: true,
+ auto_format: true,
+ },
+ );
quit_all_impl(cx, true)
}
diff --git a/helix-term/src/handlers/auto_save.rs b/helix-term/src/handlers/auto_save.rs
index 4e154df808a7..47e2ecfdf13d 100644
--- a/helix-term/src/handlers/auto_save.rs
+++ b/helix-term/src/handlers/auto_save.rs
@@ -87,7 +87,13 @@ fn request_auto_save(editor: &mut Editor) {
jobs: &mut Jobs::new(),
};
- if let Err(e) = commands::typed::write_all_impl(context, false, false) {
+ let options = commands::WriteAllOptions {
+ force: false,
+ write_scratch: false,
+ auto_format: false,
+ };
+
+ if let Err(e) = commands::typed::write_all_impl(context, options) {
context.editor.set_error(format!("{}", e));
}
}
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 6fecd512b5a0..d8500ed4d7ea 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1522,7 +1522,12 @@ impl Component for EditorView {
}
Event::FocusLost => {
if context.editor.config().auto_save.focus_lost {
- if let Err(e) = commands::typed::write_all_impl(context, false, false) {
+ let options = commands::WriteAllOptions {
+ force: false,
+ write_scratch: false,
+ auto_format: false,
+ };
+ if let Err(e) = commands::typed::write_all_impl(context, options) {
context.editor.set_error(format!("{}", e));
}
}
| diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 9c48bf72382e..c5c53acd5ce7 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -678,10 +678,16 @@ pub(super) fn buffers_remaining_impl(editor: &mut Editor) -> anyhow::Result<()>
Ok(())
+#[derive(Debug, Clone, Copy)]
+pub struct WriteAllOptions {
+ pub force: bool,
+ pub write_scratch: bool,
+ pub auto_format: bool,
+}
pub fn write_all_impl(
cx: &mut compositor::Context,
- force: bool,
- write_scratch: bool,
+ options: WriteAllOptions,
) -> anyhow::Result<()> {
let mut errors: Vec<&'static str> = Vec::new();
let config = cx.editor.config();
@@ -699,7 +705,7 @@ pub fn write_all_impl(
if doc.path().is_none() {
- if write_scratch {
+ if options.write_scratch {
errors.push("cannot write a buffer without a filename");
@@ -722,14 +728,14 @@ pub fn write_all_impl(
// Save an undo checkpoint for any outstanding changes.
doc.append_changes_to_history(view);
- let fmt = if config.auto_format {
+ let fmt = if options.auto_format && config.auto_format {
doc.auto_format().map(|fmt| {
let callback = make_format_callback(
doc_id,
doc.version(),
target_view,
fmt,
- Some((None, force)),
+ Some((None, options.force)),
);
jobs.add(Job::with_callback(callback).wait_before_exiting());
})
@@ -738,11 +744,11 @@ pub fn write_all_impl(
};
if fmt.is_none() {
- cx.editor.save::<PathBuf>(doc_id, None, force)?;
+ cx.editor.save::<PathBuf>(doc_id, None, options.force)?;
}
- if !errors.is_empty() && !force {
+ if !errors.is_empty() && !options.force {
bail!("{:?}", errors);
@@ -758,7 +764,14 @@ fn write_all(
- write_all_impl(cx, false, true)
fn force_write_all(
@@ -770,7 +783,14 @@ fn force_write_all(
- write_all_impl(cx, true, true)
fn write_all_quit(
@@ -781,7 +801,14 @@ fn write_all_quit(
- write_all_impl(cx, false, true)?;
+ )?;
quit_all_impl(cx, false)
@@ -793,7 +820,14 @@ fn force_write_all_quit(
- let _ = write_all_impl(cx, true, true);
+ let _ = write_all_impl(
quit_all_impl(cx, true)
diff --git a/helix-term/src/handlers/auto_save.rs b/helix-term/src/handlers/auto_save.rs
index 4e154df808a7..47e2ecfdf13d 100644
--- a/helix-term/src/handlers/auto_save.rs
+++ b/helix-term/src/handlers/auto_save.rs
@@ -87,7 +87,13 @@ fn request_auto_save(editor: &mut Editor) {
jobs: &mut Jobs::new(),
};
- if let Err(e) = commands::typed::write_all_impl(context, false, false) {
+ let options = commands::WriteAllOptions {
+ force: false,
+ write_scratch: false,
+ auto_format: false,
+ };
+ if let Err(e) = commands::typed::write_all_impl(context, options) {
context.editor.set_error(format!("{}", e));
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 6fecd512b5a0..d8500ed4d7ea 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1522,7 +1522,12 @@ impl Component for EditorView {
Event::FocusLost => {
if context.editor.config().auto_save.focus_lost {
+ let options = commands::WriteAllOptions {
+ force: false,
+ write_scratch: false,
+ auto_format: false,
+ };
+ if let Err(e) = commands::typed::write_all_impl(context, options) {
context.editor.set_error(format!("{}", e));
} | [
"+ );",
"- if let Err(e) = commands::typed::write_all_impl(context, false, false) {"
] | [
123,
154
] | {
"additions": 58,
"author": "voiceroy",
"deletions": 13,
"html_url": "https://github.com/helix-editor/helix/pull/12817",
"issue_id": 12817,
"merged_at": "2025-02-12T18:11:04Z",
"omission_probability": 0.1,
"pr_number": 12817,
"repo": "helix-editor/helix",
"title": "Prevent auto-format in auto-save",
"total_changes": 71
} |
298 | diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 81aac6a6cc43..c677b1d9b0b9 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -103,6 +103,7 @@
| idris | | | | `idris2-lsp` |
| iex | β | | | |
| ini | β | | | |
+| ink | β | | | |
| inko | β | β | β | |
| janet | β | | | |
| java | β | β | β | `jdtls` |
diff --git a/languages.toml b/languages.toml
index 8eabe75def80..ecf23a9ac76c 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4174,3 +4174,17 @@ language-servers = [ "yls" ]
[[grammar]]
name = "yara"
source = { git = "https://github.com/egibs/tree-sitter-yara", rev = "eb3ede203275c38000177f72ec0f9965312806ef" }
+
+[[language]]
+name = "ink"
+scope = "source.ink"
+file-types = ["ink"]
+injection-regex = "ink"
+comment-token = "//"
+block-comment-tokens = { start = "/*", end = "*/"}
+indent = { tab-width = 4, unit = "\t" }
+soft-wrap = { enable = true }
+
+[[grammar]]
+name = "ink"
+source = { git = "https://github.com/rhizoome/tree-sitter-ink", rev = "8486e9b1627b0bc6b2deb9ee8102277a7c1281ac" }
diff --git a/runtime/queries/ink/highlights.scm b/runtime/queries/ink/highlights.scm
new file mode 100644
index 000000000000..771721a1d0c9
--- /dev/null
+++ b/runtime/queries/ink/highlights.scm
@@ -0,0 +1,53 @@
+; tags and labels
+(label) @label
+(tag (identifier) @commment)
+(tag) @comment
+
+; values
+(identifier) @function
+(string) @string
+(boolean) @constant
+(number) @constant.numeric
+
+; headers
+(knot_header) @keyword
+(stitch_header) @keyword
+(function_header) @keyword
+
+; marks (ink)
+(option_mark) @keyword.directive
+(gather_mark) @type.builtin
+(glue) @type.builtin
+
+; calls
+(divert_or_thread) @function
+
+; operators
+(assignment) @operator
+
+; special marks/operators (ink)
+(arrow) @special
+(double_arrow) @special
+(back_arrow) @constant
+(dot) @special
+(mark_start) @special
+(mark_end) @special
+(hide_start) @special
+(hide_end) @special
+
+; declarations
+(var_line) @attribute
+(const_line) @constant
+(list_line) @type
+
+; comments
+(line_comment) @comment
+(block_comment) @comment
+
+; unparsed code
+(inline_block) @keyword
+(condition_block) @keyword
+(code_text) @keyword
+
+; support injection
+(program) @ui.text
| diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 81aac6a6cc43..c677b1d9b0b9 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -103,6 +103,7 @@
| idris | | | | `idris2-lsp` |
| iex | β | | | |
| ini | β | | | |
+| ink | β | | | |
| inko | β | β | β | |
| janet | β | | | |
| java | β | β | β | `jdtls` |
diff --git a/languages.toml b/languages.toml
index 8eabe75def80..ecf23a9ac76c 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4174,3 +4174,17 @@ language-servers = [ "yls" ]
[[grammar]]
name = "yara"
source = { git = "https://github.com/egibs/tree-sitter-yara", rev = "eb3ede203275c38000177f72ec0f9965312806ef" }
+[[language]]
+scope = "source.ink"
+file-types = ["ink"]
+injection-regex = "ink"
+comment-token = "//"
+block-comment-tokens = { start = "/*", end = "*/"}
+indent = { tab-width = 4, unit = "\t" }
+soft-wrap = { enable = true }
+[[grammar]]
+source = { git = "https://github.com/rhizoome/tree-sitter-ink", rev = "8486e9b1627b0bc6b2deb9ee8102277a7c1281ac" }
diff --git a/runtime/queries/ink/highlights.scm b/runtime/queries/ink/highlights.scm
new file mode 100644
index 000000000000..771721a1d0c9
--- /dev/null
+++ b/runtime/queries/ink/highlights.scm
@@ -0,0 +1,53 @@
+; tags and labels
+(label) @label
+(tag (identifier) @commment)
+(tag) @comment
+; values
+(identifier) @function
+(string) @string
+(boolean) @constant
+(number) @constant.numeric
+; headers
+(function_header) @keyword
+; marks (ink)
+(option_mark) @keyword.directive
+(gather_mark) @type.builtin
+(glue) @type.builtin
+; calls
+(divert_or_thread) @function
+; operators
+(assignment) @operator
+; special marks/operators (ink)
+(arrow) @special
+(double_arrow) @special
+(dot) @special
+(mark_start) @special
+(mark_end) @special
+(hide_start) @special
+(hide_end) @special
+; declarations
+(var_line) @attribute
+(const_line) @constant
+(list_line) @type
+; comments
+(line_comment) @comment
+(block_comment) @comment
+; unparsed code
+(inline_block) @keyword
+(condition_block) @keyword
+(code_text) @keyword
+; support injection
+(program) @ui.text | [
"+(knot_header) @keyword",
"+(stitch_header) @keyword",
"+(back_arrow) @constant"
] | [
52,
53,
70
] | {
"additions": 68,
"author": "rhizoome",
"deletions": 0,
"html_url": "https://github.com/helix-editor/helix/pull/12773",
"issue_id": 12773,
"merged_at": "2025-02-12T15:46:50Z",
"omission_probability": 0.1,
"pr_number": 12773,
"repo": "helix-editor/helix",
"title": "feat: Add support for the Ink programming language",
"total_changes": 68
} |
299 | diff --git a/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs b/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs
index dfa2e5593b276..818a8c9aea58a 100644
--- a/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs
+++ b/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs
@@ -91,8 +91,8 @@ impl UpdateOutputOperation {
cell,
})
}
- Ok(Ok(RawVc::LocalOutput(_, _))) => {
- panic!("LocalOutput must not be output of a task");
+ Ok(Ok(RawVc::LocalOutput(..))) => {
+ panic!("Non-local tasks must not return a local Vc");
}
Ok(Err(err)) => {
task.insert(CachedDataItem::Error {
diff --git a/turbopack/crates/turbo-tasks-backend/tests/transient_vc.rs b/turbopack/crates/turbo-tasks-backend/tests/transient_vc.rs
new file mode 120000
index 0000000000000..a12b998ce9f5b
--- /dev/null
+++ b/turbopack/crates/turbo-tasks-backend/tests/transient_vc.rs
@@ -0,0 +1 @@
+../../turbo-tasks-testing/tests/transient_vc.rs
\ No newline at end of file
diff --git a/turbopack/crates/turbo-tasks-memory/tests/transient_vc.rs b/turbopack/crates/turbo-tasks-memory/tests/transient_vc.rs
new file mode 120000
index 0000000000000..a12b998ce9f5b
--- /dev/null
+++ b/turbopack/crates/turbo-tasks-memory/tests/transient_vc.rs
@@ -0,0 +1 @@
+../../turbo-tasks-testing/tests/transient_vc.rs
\ No newline at end of file
diff --git a/turbopack/crates/turbo-tasks-testing/tests/transient_vc.rs b/turbopack/crates/turbo-tasks-testing/tests/transient_vc.rs
new file mode 100644
index 0000000000000..2cc4fbe4f8408
--- /dev/null
+++ b/turbopack/crates/turbo-tasks-testing/tests/transient_vc.rs
@@ -0,0 +1,55 @@
+#![feature(arbitrary_self_types)]
+#![feature(arbitrary_self_types_pointers)]
+
+use anyhow::Result;
+use turbo_tasks::{TaskInput, TransientValue, Vc};
+use turbo_tasks_testing::{register, run_without_cache_check, Registration};
+
+static REGISTRATION: Registration = register!();
+
+#[tokio::test]
+async fn test_transient_vc() -> Result<()> {
+ run_without_cache_check(®ISTRATION, async {
+ test_transient_operation(TransientValue::new(123))
+ .read_strongly_consistent()
+ .await?;
+ Ok(())
+ })
+ .await
+}
+
+#[turbo_tasks::function(operation)]
+async fn test_transient_operation(transient_arg: TransientValue<i32>) -> Result<()> {
+ let called_with_transient = has_transient_arg(transient_arg);
+ let called_with_persistent = has_persistent_arg(123);
+
+ assert!(called_with_transient.is_transient());
+ assert!(!called_with_persistent.is_transient());
+ assert!(has_vc_arg(called_with_transient).is_transient());
+ assert!(!has_vc_arg(called_with_persistent).is_transient());
+
+ let called_with_transient_resolved = called_with_transient.to_resolved().await?;
+ let called_with_persistent_resolved = called_with_persistent.to_resolved().await?;
+
+ assert!(called_with_transient_resolved.is_transient());
+ assert!(!called_with_persistent_resolved.is_transient());
+ assert!(has_vc_arg(*called_with_transient_resolved).is_transient());
+ assert!(!has_vc_arg(*called_with_persistent_resolved).is_transient());
+
+ Ok(())
+}
+
+#[turbo_tasks::function]
+fn has_transient_arg(arg: TransientValue<i32>) -> Vc<i32> {
+ Vc::cell(*arg)
+}
+
+#[turbo_tasks::function]
+fn has_persistent_arg(arg: i32) -> Vc<i32> {
+ Vc::cell(arg)
+}
+
+#[turbo_tasks::function]
+async fn has_vc_arg(arg: Vc<i32>) -> Result<Vc<i32>> {
+ Ok(Vc::cell(*arg.await?))
+}
diff --git a/turbopack/crates/turbo-tasks/src/manager.rs b/turbopack/crates/turbo-tasks/src/manager.rs
index 79f1481e05dd0..72903d935bff7 100644
--- a/turbopack/crates/turbo-tasks/src/manager.rs
+++ b/turbopack/crates/turbo-tasks/src/manager.rs
@@ -306,7 +306,7 @@ pub struct UpdateInfo {
placeholder_for_future_fields: (),
}
-#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub enum TaskPersistence {
/// Tasks that may be persisted across sessions using serialization.
Persistent,
@@ -796,7 +796,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
#[cfg(not(feature = "tokio_tracing"))]
tokio::task::spawn(future);
- RawVc::LocalOutput(parent_task_id, local_task_id)
+ RawVc::LocalOutput(parent_task_id, persistence, local_task_id)
}
fn begin_primary_job(&self) {
diff --git a/turbopack/crates/turbo-tasks/src/raw_vc.rs b/turbopack/crates/turbo-tasks/src/raw_vc.rs
index 3a2ed8114db55..682b4ab02e058 100644
--- a/turbopack/crates/turbo-tasks/src/raw_vc.rs
+++ b/turbopack/crates/turbo-tasks/src/raw_vc.rs
@@ -12,7 +12,7 @@ use crate::{
manager::{read_local_output, read_task_cell, read_task_output, with_turbo_tasks},
registry::{self, get_value_type},
turbo_tasks, CollectiblesSource, ReadCellOptions, ReadConsistency, ResolvedVc, TaskId,
- TraitTypeId, ValueType, ValueTypeId, VcValueTrait,
+ TaskPersistence, TraitTypeId, ValueType, ValueTypeId, VcValueTrait,
};
#[derive(Error, Debug)]
@@ -57,31 +57,34 @@ impl Display for CellId {
pub enum RawVc {
TaskOutput(TaskId),
TaskCell(TaskId, CellId),
- LocalOutput(TaskId, LocalTaskId),
+ LocalOutput(TaskId, TaskPersistence, LocalTaskId),
}
impl RawVc {
pub fn is_resolved(&self) -> bool {
match self {
- RawVc::TaskOutput(_) => false,
- RawVc::TaskCell(_, _) => true,
- RawVc::LocalOutput(_, _) => false,
+ RawVc::TaskOutput(..) => false,
+ RawVc::TaskCell(..) => true,
+ RawVc::LocalOutput(..) => false,
}
}
pub fn is_local(&self) -> bool {
match self {
- RawVc::TaskOutput(_) => false,
- RawVc::TaskCell(_, _) => false,
- RawVc::LocalOutput(_, _) => true,
+ RawVc::TaskOutput(..) => false,
+ RawVc::TaskCell(..) => false,
+ RawVc::LocalOutput(..) => true,
}
}
+ /// Returns `true` if the task this `RawVc` reads from cannot be serialized and will not be
+ /// stored in the persistent cache.
+ ///
+ /// See [`TaskPersistence`] for more details.
pub fn is_transient(&self) -> bool {
match self {
- RawVc::TaskOutput(task) | RawVc::TaskCell(task, _) | RawVc::LocalOutput(task, _) => {
- task.is_transient()
- }
+ RawVc::TaskOutput(task) | RawVc::TaskCell(task, ..) => task.is_transient(),
+ RawVc::LocalOutput(_, persistence, ..) => *persistence == TaskPersistence::Transient,
}
}
@@ -145,7 +148,7 @@ impl RawVc {
return Err(ResolveTypeError::NoContent);
}
}
- RawVc::LocalOutput(task_id, local_task_id) => {
+ RawVc::LocalOutput(task_id, _persistence, local_task_id) => {
current = read_local_output(&*tt, task_id, local_task_id)
.await
.map_err(|source| ResolveTypeError::TaskError { source })?;
@@ -182,7 +185,7 @@ impl RawVc {
consistency = ReadConsistency::Eventual;
}
RawVc::TaskCell(_, _) => return Ok(current),
- RawVc::LocalOutput(task_id, local_task_id) => {
+ RawVc::LocalOutput(task_id, _persistence, local_task_id) => {
debug_assert_eq!(consistency, ReadConsistency::Eventual);
current = read_local_output(&*tt, task_id, local_task_id).await?;
}
@@ -197,7 +200,7 @@ impl RawVc {
let mut current = self;
loop {
match current {
- RawVc::LocalOutput(task_id, local_task_id) => {
+ RawVc::LocalOutput(task_id, _persistence, local_task_id) => {
current = read_local_output(&*tt, task_id, local_task_id).await?;
}
non_local => return Ok(non_local),
@@ -212,14 +215,14 @@ impl RawVc {
pub fn get_task_id(&self) -> TaskId {
match self {
- RawVc::TaskOutput(t) | RawVc::TaskCell(t, _) | RawVc::LocalOutput(t, _) => *t,
+ RawVc::TaskOutput(t) | RawVc::TaskCell(t, _) | RawVc::LocalOutput(t, ..) => *t,
}
}
pub fn try_get_type_id(&self) -> Option<ValueTypeId> {
match self {
RawVc::TaskCell(_, CellId { type_id, .. }) => Some(*type_id),
- RawVc::TaskOutput(_) | RawVc::LocalOutput(_, _) => None,
+ RawVc::TaskOutput(_) | RawVc::LocalOutput(..) => None,
}
}
@@ -357,7 +360,7 @@ impl Future for ReadRawVcFuture {
Err(err) => return Poll::Ready(Err(err)),
}
}
- RawVc::LocalOutput(task_id, local_output_id) => {
+ RawVc::LocalOutput(task_id, _persistence, local_output_id) => {
debug_assert_eq!(this.consistency, ReadConsistency::Eventual);
let read_result = tt.try_read_local_output(task_id, local_output_id);
match read_result {
diff --git a/turbopack/crates/turbo-tasks/src/task/task_input.rs b/turbopack/crates/turbo-tasks/src/task/task_input.rs
index 87bb526fd7e5f..6cfffe03ccc56 100644
--- a/turbopack/crates/turbo-tasks/src/task/task_input.rs
+++ b/turbopack/crates/turbo-tasks/src/task/task_input.rs
@@ -139,7 +139,7 @@ where
}
fn is_transient(&self) -> bool {
- self.node.get_task_id().is_transient()
+ self.node.is_transient()
}
async fn resolve_input(&self) -> Result<Self> {
| diff --git a/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs b/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs
index dfa2e5593b276..818a8c9aea58a 100644
--- a/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs
+++ b/turbopack/crates/turbo-tasks-backend/src/backend/operation/update_output.rs
@@ -91,8 +91,8 @@ impl UpdateOutputOperation {
cell,
})
- Ok(Ok(RawVc::LocalOutput(_, _))) => {
- panic!("LocalOutput must not be output of a task");
+ Ok(Ok(RawVc::LocalOutput(..))) => {
+ panic!("Non-local tasks must not return a local Vc");
Ok(Err(err)) => {
task.insert(CachedDataItem::Error {
diff --git a/turbopack/crates/turbo-tasks-backend/tests/transient_vc.rs b/turbopack/crates/turbo-tasks-backend/tests/transient_vc.rs
+++ b/turbopack/crates/turbo-tasks-backend/tests/transient_vc.rs
diff --git a/turbopack/crates/turbo-tasks-memory/tests/transient_vc.rs b/turbopack/crates/turbo-tasks-memory/tests/transient_vc.rs
+++ b/turbopack/crates/turbo-tasks-memory/tests/transient_vc.rs
diff --git a/turbopack/crates/turbo-tasks-testing/tests/transient_vc.rs b/turbopack/crates/turbo-tasks-testing/tests/transient_vc.rs
new file mode 100644
index 0000000000000..2cc4fbe4f8408
+++ b/turbopack/crates/turbo-tasks-testing/tests/transient_vc.rs
@@ -0,0 +1,55 @@
+#![feature(arbitrary_self_types)]
+#![feature(arbitrary_self_types_pointers)]
+use anyhow::Result;
+use turbo_tasks::{TaskInput, TransientValue, Vc};
+use turbo_tasks_testing::{register, run_without_cache_check, Registration};
+static REGISTRATION: Registration = register!();
+#[tokio::test]
+async fn test_transient_vc() -> Result<()> {
+ run_without_cache_check(®ISTRATION, async {
+ .read_strongly_consistent()
+ .await?;
+ Ok(())
+ })
+ .await
+#[turbo_tasks::function(operation)]
+async fn test_transient_operation(transient_arg: TransientValue<i32>) -> Result<()> {
+ let called_with_transient = has_transient_arg(transient_arg);
+ let called_with_persistent = has_persistent_arg(123);
+ assert!(called_with_transient.is_transient());
+ assert!(has_vc_arg(called_with_transient).is_transient());
+ assert!(!has_vc_arg(called_with_persistent).is_transient());
+ let called_with_transient_resolved = called_with_transient.to_resolved().await?;
+ let called_with_persistent_resolved = called_with_persistent.to_resolved().await?;
+ assert!(called_with_transient_resolved.is_transient());
+ assert!(!called_with_persistent_resolved.is_transient());
+ assert!(has_vc_arg(*called_with_transient_resolved).is_transient());
+ assert!(!has_vc_arg(*called_with_persistent_resolved).is_transient());
+ Ok(())
+fn has_transient_arg(arg: TransientValue<i32>) -> Vc<i32> {
+ Vc::cell(*arg)
+fn has_persistent_arg(arg: i32) -> Vc<i32> {
+ Vc::cell(arg)
+async fn has_vc_arg(arg: Vc<i32>) -> Result<Vc<i32>> {
+ Ok(Vc::cell(*arg.await?))
diff --git a/turbopack/crates/turbo-tasks/src/manager.rs b/turbopack/crates/turbo-tasks/src/manager.rs
index 79f1481e05dd0..72903d935bff7 100644
--- a/turbopack/crates/turbo-tasks/src/manager.rs
+++ b/turbopack/crates/turbo-tasks/src/manager.rs
@@ -306,7 +306,7 @@ pub struct UpdateInfo {
placeholder_for_future_fields: (),
-#[derive(Clone, Copy, Debug, Eq, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub enum TaskPersistence {
/// Tasks that may be persisted across sessions using serialization.
Persistent,
@@ -796,7 +796,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
#[cfg(not(feature = "tokio_tracing"))]
tokio::task::spawn(future);
- RawVc::LocalOutput(parent_task_id, local_task_id)
+ RawVc::LocalOutput(parent_task_id, persistence, local_task_id)
fn begin_primary_job(&self) {
diff --git a/turbopack/crates/turbo-tasks/src/raw_vc.rs b/turbopack/crates/turbo-tasks/src/raw_vc.rs
index 3a2ed8114db55..682b4ab02e058 100644
--- a/turbopack/crates/turbo-tasks/src/raw_vc.rs
+++ b/turbopack/crates/turbo-tasks/src/raw_vc.rs
@@ -12,7 +12,7 @@ use crate::{
manager::{read_local_output, read_task_cell, read_task_output, with_turbo_tasks},
registry::{self, get_value_type},
turbo_tasks, CollectiblesSource, ReadCellOptions, ReadConsistency, ResolvedVc, TaskId,
- TraitTypeId, ValueType, ValueTypeId, VcValueTrait,
+ TaskPersistence, TraitTypeId, ValueType, ValueTypeId, VcValueTrait,
};
#[derive(Error, Debug)]
@@ -57,31 +57,34 @@ impl Display for CellId {
pub enum RawVc {
TaskOutput(TaskId),
TaskCell(TaskId, CellId),
- LocalOutput(TaskId, LocalTaskId),
+ LocalOutput(TaskId, TaskPersistence, LocalTaskId),
impl RawVc {
pub fn is_resolved(&self) -> bool {
- RawVc::TaskCell(_, _) => true,
- RawVc::LocalOutput(_, _) => false,
+ RawVc::TaskCell(..) => true,
+ RawVc::LocalOutput(..) => false,
pub fn is_local(&self) -> bool {
- RawVc::TaskCell(_, _) => false,
- RawVc::LocalOutput(_, _) => true,
+ RawVc::TaskCell(..) => false,
+ RawVc::LocalOutput(..) => true,
+ /// Returns `true` if the task this `RawVc` reads from cannot be serialized and will not be
+ /// stored in the persistent cache.
+ ///
+ /// See [`TaskPersistence`] for more details.
pub fn is_transient(&self) -> bool {
- RawVc::TaskOutput(task) | RawVc::TaskCell(task, _) | RawVc::LocalOutput(task, _) => {
- task.is_transient()
- }
+ RawVc::TaskOutput(task) | RawVc::TaskCell(task, ..) => task.is_transient(),
+ RawVc::LocalOutput(_, persistence, ..) => *persistence == TaskPersistence::Transient,
@@ -145,7 +148,7 @@ impl RawVc {
return Err(ResolveTypeError::NoContent);
current = read_local_output(&*tt, task_id, local_task_id)
.await
.map_err(|source| ResolveTypeError::TaskError { source })?;
@@ -182,7 +185,7 @@ impl RawVc {
consistency = ReadConsistency::Eventual;
RawVc::TaskCell(_, _) => return Ok(current),
debug_assert_eq!(consistency, ReadConsistency::Eventual);
@@ -197,7 +200,7 @@ impl RawVc {
let mut current = self;
loop {
match current {
non_local => return Ok(non_local),
@@ -212,14 +215,14 @@ impl RawVc {
pub fn get_task_id(&self) -> TaskId {
+ RawVc::TaskOutput(t) | RawVc::TaskCell(t, _) | RawVc::LocalOutput(t, ..) => *t,
pub fn try_get_type_id(&self) -> Option<ValueTypeId> {
RawVc::TaskCell(_, CellId { type_id, .. }) => Some(*type_id),
- RawVc::TaskOutput(_) | RawVc::LocalOutput(_, _) => None,
+ RawVc::TaskOutput(_) | RawVc::LocalOutput(..) => None,
@@ -357,7 +360,7 @@ impl Future for ReadRawVcFuture {
Err(err) => return Poll::Ready(Err(err)),
}
- RawVc::LocalOutput(task_id, local_output_id) => {
+ RawVc::LocalOutput(task_id, _persistence, local_output_id) => {
debug_assert_eq!(this.consistency, ReadConsistency::Eventual);
let read_result = tt.try_read_local_output(task_id, local_output_id);
match read_result {
diff --git a/turbopack/crates/turbo-tasks/src/task/task_input.rs b/turbopack/crates/turbo-tasks/src/task/task_input.rs
index 87bb526fd7e5f..6cfffe03ccc56 100644
--- a/turbopack/crates/turbo-tasks/src/task/task_input.rs
+++ b/turbopack/crates/turbo-tasks/src/task/task_input.rs
@@ -139,7 +139,7 @@ where
fn is_transient(&self) -> bool {
- self.node.get_task_id().is_transient()
+ self.node.is_transient()
async fn resolve_input(&self) -> Result<Self> { | [
"+ test_transient_operation(TransientValue::new(123))",
"+ assert!(!called_with_persistent.is_transient());",
"- RawVc::TaskOutput(t) | RawVc::TaskCell(t, _) | RawVc::LocalOutput(t, _) => *t,"
] | [
49,
63,
203
] | {
"additions": 82,
"author": "bgw",
"deletions": 22,
"html_url": "https://github.com/vercel/next.js/pull/78488",
"issue_id": 78488,
"merged_at": "2025-04-24T22:47:00Z",
"omission_probability": 0.1,
"pr_number": 78488,
"repo": "vercel/next.js",
"title": "fix(turbo-tasks): Store persistence of wrapped task on RawVc::LocalOutput",
"total_changes": 104
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.