Skip to content

Commit

Permalink
[formatter] Update VSCode Extension to V2 (#20743)
Browse files Browse the repository at this point in the history
## Description 

Updates the Prettier Extension dependency to match the most recent plugin version.

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
  • Loading branch information
damirka authored Dec 27, 2024
1 parent 0441f76 commit aa99382
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions external-crates/move/tooling/prettier-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "mysten",
"displayName": "Move Formatter Developer Preview",
"description": "Adds Move code formatting to VSCode using Prettier@v3",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"preview": true,
"icon": "img/move.png",
Expand Down Expand Up @@ -76,7 +76,7 @@
"lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix"
},
"dependencies": {
"@mysten/prettier-plugin-move": "^0.1.1",
"@mysten/prettier-plugin-move": "^0.2.2",
"cosmiconfig": "^9.0.0",
"prettier": "^3.3.2"
},
Expand Down
15 changes: 14 additions & 1 deletion external-crates/move/tooling/prettier-extension/src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,20 @@ function activate(context) {
* - Prettier extension settings
*/
async function findMatchingConfig(documentUri) {
const root = vscode.workspace.getWorkspaceFolder(documentUri).uri.path;
const workspaceFolder = vscode.workspace.getWorkspaceFolder(documentUri);
if (!workspaceFolder) {
const formatterConfig = vscode.workspace.getConfiguration(EXTENSION_NAME);
return {
tabWidth: formatterConfig.get('tabWidth'),
printWidth: formatterConfig.get('printWidth'),
wrapComments: formatterConfig.get('wrapComments'),
useModuleLabel: formatterConfig.get('useModuleLabel'),
autoGroupImports: formatterConfig.get('autoGroupImports'),
enableErrorDebug: formatterConfig.get('errorDebugMode'),
};
}

const root = workspaceFolder.uri.path;
let lookup = documentUri.path;
let search = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parentPort.on('message', async (message) => {
const { text, options } = JSON.parse(message);

return format(text, {
parser: 'move-parse',
parser: 'move',
plugins: [plugin],
tabWidth: options.tabWidth,
printWidth: options.printWidth,
Expand Down

0 comments on commit aa99382

Please sign in to comment.