mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
Merge pull request #20246 from overleaf/dp-math-preview-closing-delimiter
Don't show math preview tooltip if the node has a parse error GitOrigin-RevId: 330ebb945c70da4b5fe9ee4ee2f149a95435899b
This commit is contained in:
parent
4802d04fb0
commit
f4c57fce4c
2 changed files with 20 additions and 0 deletions
|
@ -25,6 +25,7 @@ import { isSplitTestEnabled } from '@/utils/splitTestUtils'
|
|||
import ReactDOM from 'react-dom'
|
||||
import { SplitTestProvider } from '@/shared/context/split-test-context'
|
||||
import SplitTestBadge from '@/shared/components/split-test-badge'
|
||||
import { nodeHasError } from '../utils/tree-operations/common'
|
||||
|
||||
const REPOSITION_EVENT = 'editor:repositionMathTooltips'
|
||||
|
||||
|
@ -134,6 +135,8 @@ const getMathContainer = (state: EditorState, pos: number) => {
|
|||
const [node] = descendantsOfNodeWithType(ancestorNode, 'Math', 'Math')
|
||||
if (!node) return null
|
||||
|
||||
if (nodeHasError(ancestorNode)) return null
|
||||
|
||||
return parseMathContainer(state, node, ancestorNode)
|
||||
}
|
||||
|
||||
|
|
|
@ -61,3 +61,20 @@ export const getOptionalArgumentText = (
|
|||
return state.doc.sliceString(shortArgNode.from, shortArgNode.to)
|
||||
}
|
||||
}
|
||||
|
||||
export const nodeHasError = (node: SyntaxNode): boolean => {
|
||||
let hasError = false
|
||||
|
||||
node.cursor().iterate(({ type }) => {
|
||||
if (hasError) return false
|
||||
|
||||
if (type.isError) {
|
||||
hasError = true
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
return hasError
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue