kcl-lang / kcl

KCL Programming Language (CNCF Sandbox Project). https://kcl-lang.io
https://kcl-lang.io
Apache License 2.0
1.41k stars 110 forks source link

[Bug] Wrong completion items for the newline char in the schema context. #1440

Open Peefy opened 1 week ago

Peefy commented 1 week ago

Enhancement

Case 1


schema Deployment:
    name: str
    volumes?: [Volume]
    image: str
    replica: int = 1
    command: [str]
    labels?: {str:str}

schema Volume:
    name: str
    mountPath: str
    hostPath: str

nginx = Deployment {
    name = "my-nginx"
    image = "nginx:1.14.2"
    volumes = [Volume {
        name = "mydir"
        mountPath = "/test-pd"
        hostPath = "/data"
        # enter newline here.
    }]
    command = ["nginx"]
    labels.run = "my-nginx"
    labels.env = "pre-prod"
}

image

Case 2

import k8s.api.apps.v1 as appsv1
import k8s.api.core.v1 as corev1

statefulSet = appsv1.StatefulSet {
    spec: appsv1.StatefulSetSpec{
        serviceName: "foo"
        template: corev1.PodTemplateSpec{}
        selector: {# Enter newline here}
    }
}

image

Expected items are ["matchExpressions", "matchLabels"]

Case 3

import k8s.api.apps.v1 as appsv1
import k8s.api.core.v1 as corev1

statefulSet = appsv1.StatefulSet {
    spec: appsv1.StatefulSetSpec{
        serviceName: "foo"
        template: corev1.PodTemplateSpec{}
        selector: {
            # Enter newline here
        }
    }
}

image

Expected items are ["matchExpressions", "matchLabels"]