You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use formatWithCursor() to preserve cursor position after formatting
Previously, the extension used Prettier's format() API which caused the
cursor to jump to an arbitrary position after formatting. This change
uses Prettier's formatWithCursor() API to preserve the cursor position.
Changes:
- Add formatWithCursor to PrettierInstance and PrettierModule interfaces
- Implement formatWithCursor in PrettierDynamicInstance
- Add formatWithCursor to ModuleResolverWeb for browser support
- Update PrettierEditService to use formatWithCursor when cursor
position is available, and schedule cursor repositioning after
VS Code applies the edit
Fixes#3939
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ All notable changes to the "prettier-vscode" extension will be documented in thi
6
6
7
7
## [Unreleased]
8
8
9
+
- Preserve cursor position after formatting using Prettier's `formatWithCursor()` API (#3939)
10
+
9
11
## [12.2.0]
10
12
11
13
- Fixed `source.fixAll.prettier` code action running even when `editor.defaultFormatter` was set to a different extension (#3908). The code action now respects the user's formatter choice and only runs when Prettier is the default formatter or when `source.fixAll.prettier` is explicitly enabled.
0 commit comments