Skip to content

formatWithCursor hangs/takes several seconds on text HTML input #13387

@abose

Description

@abose

Hi all,

I was integrating prettier as a default extension in brackets editor. using formatWithCursor API to prettify code leads to hangs and general slowness.
Prettier is hosted in web worker inside brackets. formatWithCursor API is causing large delays and hangs in most large html files, but normal format api works just fine.

  • Attached zip project with samples files that causing hangs. pretty.zip
  • Also see this URL in dev tools to see a quick simple use case that hangs for several seconds in beautify API.

questions

  • I could not find the use of formatWithCursor in vscode extension code. How does the vscode extension handle cursor movement without using the API.
  • Is formatWithCursor recommended for usage within editors as i am seeing several seconds of delay to prettify code in not so large attached sample files.

Any help would be much appreciated.

Environments:

  • Prettier Version: 2.7.1
  • Running Prettier via: Browser API
  • Runtime: Chrome v83, web worker
  • Operating System: Linux
  • Prettier plugins (if any): parser-html.js

Steps to reproduce:

  • Extract the contents of pretty.zip
  • open index.html in any editor and see debugger. observe that the main thread hangs for several seconds on calling formatWithCursor.

Expected behavior:

  • Gets result with cursor

Actual behavior:

  • hangs browser

Thanks,
Arun

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:duplicateIssues that are a duplicate of a previous issuetype:editor supportIssues about tools Prettier provides for use inside editor integrations.type:perfIssue with performance of Prettier

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions