File tree 2 files changed +13
-0
lines changed
packages/react-devtools-extensions/src
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,17 @@ function checkNodeLocation(
40
40
return false ;
41
41
}
42
42
43
+ // Column numbers are representated differently between tools/engines.
44
+ // Error.prototype.stack columns are 1-based (like most IDEs) but ASTs are 0-based.
45
+ //
46
+ // In practice this will probably never matter,
47
+ // because this code matches the 1-based Error stack location for the hook Identifier (e.g. useState)
48
+ // with the larger 0-based VariableDeclarator (e.g. [foo, setFoo] = useState())
49
+ // so the ranges should always overlap.
50
+ //
51
+ // For more info see https://github.com/facebook/react/pull/21833#discussion_r666831276
52
+ column -= 1 ;
53
+
43
54
if (
44
55
( line === start . line && column < start . column ) ||
45
56
( line === end . line && column > end . column )
Original file line number Diff line number Diff line change @@ -378,6 +378,7 @@ function findHookNames(
378
378
line : lineNumber ,
379
379
380
380
// Column numbers are representated differently between tools/engines.
381
+ // Error.prototype.stack columns are 1-based (like most IDEs) but ASTs are 0-based.
381
382
// For more info see https://github.com/facebook/react/issues/21792#issuecomment-873171991
382
383
column : columnNumber - 1 ,
383
384
} ) ;
@@ -476,6 +477,7 @@ async function parseSourceAST(
476
477
line : lineNumber ,
477
478
478
479
// Column numbers are representated differently between tools/engines.
480
+ // Error.prototype.stack columns are 1-based (like most IDEs) but ASTs are 0-based.
479
481
// For more info see https://github.com/facebook/react/issues/21792#issuecomment-873171991
480
482
column : columnNumber - 1 ,
481
483
} ) ;
You can’t perform that action at this time.
0 commit comments