mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Only use the LaTeX indent service for when inserting a line break (#21530)
GitOrigin-RevId: 15c5e5afdee59badc833fe2deb13a80b3c409862
This commit is contained in:
+5
-13
@@ -1,18 +1,10 @@
|
||||
import { indentService } from '@codemirror/language'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
|
||||
export const latexIndentService = () => {
|
||||
return indentService.of((indentContext, pos) => {
|
||||
try {
|
||||
export const latexIndentService = () =>
|
||||
indentService.of((indentContext, pos) => {
|
||||
// only use this for insertNewLineAndIndent
|
||||
if (indentContext.simulatedBreak) {
|
||||
// match the indentation of the previous line (if present)
|
||||
const previousLine = indentContext.state.doc.lineAt(pos)
|
||||
const whitespace = previousLine.text.match(/^\s*/)
|
||||
if (whitespace) {
|
||||
return whitespace[0].length
|
||||
}
|
||||
} catch (err) {
|
||||
debugConsole.error('Error in CM indentService', err)
|
||||
return null
|
||||
}
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user