microsoft / microsoft/TypeScript

Unexpected behaviors in attribute completions of JSX/TSX

Đang mở
#52,873 9 bình luận 0 reaction 1 người được giao Xem trên GitHub

@mjbvz đang làm issue này rồi.

Từ ngày 24/2/2023.

Needs Proposal Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.75.1
  • OS Version: Mac OS 13.1

Steps to Reproduce:

  1. Set the JSX attribute completion style of typescript to braces
  2. Create a .tsx file with the following content
export default function Sample(props: {}) {
    return <div
        
    > </div>
}
  1. for the div tag add a onClick callback with the following key strokes:
    3.1. oncl then enter
    3.2. e => { then enter
    3.3. e.st then enter

You can see the uploaded the gif below

Screen Recording 2023-02-11 at 12 01 52 PM

In JSX/TSX, there is an autocompletion for the attributes. When you select a suggested completion, a braces is opened and the cursor is placed in between in highlight mode, like the image below.

Screenshot 2023-02-11 at 12 33 29 PM

The existence of this highlight mode does not provide any value to the user. If you start typing in this highlight mode, the suggested codes are not selected (unlike the normal mode where the first suggested is selected and will be inserted when pressing enter) and if you want to come out of the highlight mode while typing, you have to press esc once to close the suggestion prompt and a second time to close the highlight mode.

In the above example, you would expect the editor to preselect the first suggestion (e.stopPropagation) and is inserted when pressing enter but since the code is in highlight mode, you have to press the down cursor to select the suggestion. If you don't select it manually, pressing enter adds a line break.

After using the jsx attribute completion from the day it was released, I haven't found any reason or use case for the highlight mode after code completion. My suggestion is that after the attribute is completed, the cursor would be placed between the braces in normal mode not in highlight mode.

P.S. I don't know what is the name used internally for the highlight mode (searched, but couldn't find), so if I'm wrong please correct me.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.