microsoft / TypeScript-TmLanguage

TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom.
MIT License
411 stars 126 forks source link

Broken syntax highlighting for async generic arrow functions with multiline arguments #819

Open jabuj opened 4 years ago

jabuj commented 4 years ago

TS and JS Grammar Extension version: 0.0.53 / latest

Syntax highlighting breaks for async generic arrow functions, whose arguments span multiple lines. This is basically the same problem as #481 but with async keyword

Code

async <TData, TError extends string = string>(
  url: string,
  config?: AxiosRequestConfig,
): Promise<Result<TData, TError>> => {
  try {
    const { data } = await Axios.get<ServerResponse<TData, TError>>(
      url,
      config,
    )
    return Result.fromResponse(data)
  } catch (e) {
    return handleError<TData, TError>(e)
  }
}

image

It works fine when I either move type arguments to next line/remove async/move arguments to one line. In the first two cases, type arguments and normal arguments highlighting doesn't work though.

image image image

Just noticed GitHub highlighting breaks as well. Is it a grammar limitation?

elzii commented 4 years ago

+1 - Have noticed this issue for a few years now. Is there discussion happening somewhere or an open PR for this?

sheetalkamat commented 3 years ago

We do support multiline arrows but mostly as assignment or object member assignment. We havent heard about feedback on arrows just like this. This would be disruptive fix and not sure if ideal. So we would wait for hearing more about this issue.