         name: 'variable.parameter.optional.function.environment.latex'
         patterns: [{ include: '$self' }]
       9: name: 'punctuation.definition.arguments.optional.end.latex'
-    end: '((\\\\)end)(\\{)(\\4)(\\})'
+    end: '((\\\\)end)(\\{)(\\4)(\\})|(?=})'
     endCaptures:
       1: name: 'support.function.environment.end.latex'
       2: name: 'punctuation.definition.function.latex'

            (\\{)
            (\\4)
            (\\})
            (?:\\s*)?
         '''
    name: 'meta.function.environment.tabular.latex'
    patterns: [

            name: 'variable.parameter.optional.function.environment.latex'
            patterns: [{ include: '$self' }]
          9: name: 'punctuation.definition.arguments.optional.end.latex'
        end: '((\\\\)end)(\\{)(\\4)(\\})|(?=})'
        endCaptures:
          1: name: 'support.function.environment.end.latex'
          2: name: 'punctuation.definition.function.latex'
