From 0736b6115aebd959d64eb60f57a697222a98e619 Mon Sep 17 00:00:00 2001
From: deathaxe <deathaxe82@googlemail.com>
Date: Wed, 13 Dec 2023 17:46:28 +0100
Subject: [PATCH] [Python] Fix type parameter punctuation scope

Fixes #3886
---
 Python/Fold.tmPreferences          |  8 ++++++++
 Python/Python.sublime-syntax       |  2 +-
 Python/tests/syntax_test_python.py | 12 ++++++------
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/Python/Fold.tmPreferences b/Python/Fold.tmPreferences
index fc6c9a463d..5360acac3f 100644
--- a/Python/Fold.tmPreferences
+++ b/Python/Fold.tmPreferences
@@ -15,6 +15,14 @@
                 <key>end</key>
                 <string>comment.block.documentation punctuation.definition.comment.end</string>
             </dict>
+            <dict>
+                <key>begin</key>
+                <string>punctuation.definition.generic.begin</string>
+                <key>end</key>
+                <string>punctuation.definition.generic.end</string>
+                <key>excludeTrailingNewlines</key>
+                <false/>
+            </dict>
             <dict>
                 <key>begin</key>
                 <string>punctuation.section.arguments.begin</string>
diff --git a/Python/Python.sublime-syntax b/Python/Python.sublime-syntax
index d05c8f5901..0939d19ffd 100644
--- a/Python/Python.sublime-syntax
+++ b/Python/Python.sublime-syntax
@@ -1090,7 +1090,7 @@ contexts:
   type-parameter-list-body:
     - meta_content_scope: meta.generic.python
     - match: \]
-      scope: meta.generic.python punctuation.section.parameters.end.python
+      scope: meta.generic.python punctuation.definition.generic.end.python
       pop: 1
     - match: ','
       scope: punctuation.separator.parameters.python
diff --git a/Python/tests/syntax_test_python.py b/Python/tests/syntax_test_python.py
index 61fcf5fd6c..a516d7e5c9 100644
--- a/Python/tests/syntax_test_python.py
+++ b/Python/tests/syntax_test_python.py
@@ -2047,7 +2047,7 @@ def f[T: Hashable, U: (int, str), *V, **P](x: T = SOME_CONSTANT, y: U, *args: *T
 #                                   ^ punctuation.separator.parameters.python
 #                                     ^^ keyword.operator.unpacking.mapping.python
 #                                       ^ variable.parameter.type.python
-#                                        ^ punctuation.section.parameters.end.python
+#                                        ^ punctuation.definition.generic.end.python
 #                                         ^ punctuation.section.parameters.begin.python
 #                                          ^ variable.parameter.python
 #                                           ^ punctuation.separator.annotation.python
@@ -2107,7 +2107,7 @@ def f[
 #^^^^ meta.function.python meta.generic.python
 #    ^^ meta.function.parameters.python
 #       ^^^^ meta.function.return-type.python
-#   ^ punctuation.section.parameters.end.python
+#   ^ punctuation.definition.generic.end.python
 #    ^ punctuation.section.parameters.begin.python
 #     ^ punctuation.section.parameters.end.python
 #       ^^ punctuation.separator.return-type.python
@@ -2224,7 +2224,7 @@ class GenericClass[T: X, **U]:
 #                      ^ punctuation.separator.parameters.python
 #                        ^^ keyword.operator.unpacking.mapping.python
 #                          ^ variable.parameter.type.python
-#                           ^ punctuation.section.parameters.end.python
+#                           ^ punctuation.definition.generic.end.python
 #                            ^ punctuation.section.class.begin.python
 
     from typing import override
@@ -2266,7 +2266,7 @@ def method(arg: T):
 #          ^ variable.parameter.type.python
 #           ^ punctuation.separator.bound.python
 #             ^^^ meta.type.python support.type.python
-#                ^ punctuation.section.parameters.end.python
+#                ^ punctuation.definition.generic.end.python
 #                  ^ keyword.operator.assignment.python
 #                    ^^^^ support.type.python
 #                        ^^^ meta.brackets.python
@@ -2283,7 +2283,7 @@ def method(arg: T):
 #      ^ variable.parameter.type.python
 #       ^ punctuation.separator.bound.python
 #         ^^^ meta.type.python support.type.python
-#            ^ punctuation.section.parameters.end.python
+#            ^ punctuation.definition.generic.end.python
 #              ^ keyword.operator.assignment.python
 #                ^^^^ support.type.python
 #                    ^^^ meta.brackets.python
@@ -2300,7 +2300,7 @@ def method(arg: T):
 # ^ variable.parameter.type.python
 #  ^ punctuation.separator.bound.python
 #    ^^^ meta.type.python support.type.python
-#       ^ punctuation.section.parameters.end.python
+#       ^ punctuation.definition.generic.end.python
 #         ^ keyword.operator.assignment.python
 #           ^^^^ support.type.python
 #               ^^^ meta.brackets.python