mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
LogBox - Display code frame column number correctly
Summary: Code frame columns are returned 0 based but displayed in editors 1 based, this diff bumps the column we display by one to match. Changelog: [Internal] Reviewed By: cpojer Differential Revision: D18426163 fbshipit-source-id: 2c6aefb6fe7ce161cd768b6748b7739d486ed438
This commit is contained in:
committed by
Facebook Github Bot
parent
d06a7c1748
commit
28a3b25c31
@@ -62,7 +62,9 @@ function LogBoxInspectorCodeFrame(props: Props): React.Node {
|
||||
}}>
|
||||
<Text style={styles.fileText}>
|
||||
{getFileName()} ({codeFrame.location.row}:
|
||||
{codeFrame.location.column})
|
||||
{codeFrame.location.column +
|
||||
1 /* Code frame columns are zero indexed */}
|
||||
)
|
||||
</Text>
|
||||
</LogBoxButton>
|
||||
</View>
|
||||
|
||||
@@ -65,11 +65,12 @@ function formatFrameLocation(frame: StackFrame): string {
|
||||
|
||||
location = location + ':' + lineNumber;
|
||||
|
||||
if (column == null) {
|
||||
if (column == null || isNaN(parseInt(column, 10))) {
|
||||
return location;
|
||||
}
|
||||
|
||||
return location + ':' + column;
|
||||
// Stack frame columns are zero indexed but editors start at one.
|
||||
return location + ':' + (parseInt(column, 10) + 1);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
||||
@@ -109,7 +109,7 @@ exports[`LogBoxInspectorCodeFrame should render a code frame 1`] = `
|
||||
(
|
||||
199
|
||||
:
|
||||
0
|
||||
1
|
||||
)
|
||||
</Text>
|
||||
</LogBoxButton>
|
||||
|
||||
@@ -52,7 +52,7 @@ exports[`LogBoxInspectorStackFrame should render collapsed stack frame with dimm
|
||||
]
|
||||
}
|
||||
>
|
||||
app.js:1:1
|
||||
app.js:1:2
|
||||
</Text>
|
||||
</LogBoxButton>
|
||||
`;
|
||||
@@ -105,7 +105,7 @@ exports[`LogBoxInspectorStackFrame should render stack frame 1`] = `
|
||||
]
|
||||
}
|
||||
>
|
||||
app.js:1:1
|
||||
app.js:1:2
|
||||
</Text>
|
||||
</LogBoxButton>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user