microsoft / microsoft/TypeScript

Function identifiers no longer receive semantic highlighting tokens

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

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

Từ ngày 14/5/2021.

Needs Investigation Rescheduled
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

Bug Report

Function identifiers (including methods) don't appear to be receiving semantic highlighting tokens from the LSP as of TS 4.2.x.

This is important to me because I prefer the terser style of passing callbacks directly by identifier instead of always wrapping them in anonymous lambdas (e.g., myArray.filter(myPredicate) instead of myArray.filter(it => myPredicate(it))), but with the semantic colorization missing, it's much harder to recognize where this is happening when scanning code.

🔎 Search Terms

semantic highlight, highlighting, function, token

🕗 Version & Regression Information
  • Semantic function tokens worked as expected in 4.1.5
  • They appear to be missing in 4.2.4 (VS Code's version at time of writing)
💻 Code

CodeSnap with TS v4.0.7:
ts40-func-tokens

CodeSnap with TS v.4.2.4:
ts42-func-tokens

Textual representation for the sake of screen-readers and whatnot:

let result = [...newFiles];

const compareFileName: Comparator<INewFile|IDisplayFile> = (a, b) => a.FileName === b.FileName;
const isDisplayFile = (item: INewFile|IDisplayFile): item is IDisplayFile => !!item.ExternalId;

const currentFiles = this._displayFiles$.value ?? [];
const dupes = intersectionWith(compareFileName, newFiles, currentFiles);

if (!dupes.length) {
	return result;
}

// Find the sets of current files and new uploads that are unique.
const [currentUniques, newUniques] = flow(
	xorWith(compareFileName),
	partition(isDisplayFile),
)(currentFiles, newFiles);
🙁 Actual behavior

In the newer snap, notice that references to compareFileName and isDisplayFile are colored as ordinary variables after their declarations. Invoking VS Code's "Inspect Editor Tokens and Scopes" command on those tokens indicates that they're falling back to their TextMate scopes instead of using the semantic information.

🙂 Expected behavior

In the older snap, all references to the function names are colored as functions, making it easier to spot which arguments are callbacks when scanning the code. Invoking the "Inspect..." command on these shows that they're marked with the function semantic token type, with readonly and local modifiers.

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.