Skip to content

Commit

Permalink
Use the new prisma-fmt format param
Browse files Browse the repository at this point in the history
tabSize is now taken into account again. I confirmed this through manual
testing.

closes #993
  • Loading branch information
tomhoule committed Dec 23, 2021
1 parent ca85d73 commit 441f520
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/language-server/src/MessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ export function handleDocumentFormatting(
document: TextDocument,
onError?: (errorMessage: string) => void,
): TextEdit[] {
const options = params.options

const formatted = format(options.tabSize, document.getText(), onError)
const formatted = format(document.getText(), params, onError)
return [TextEdit.replace(fullDocumentRange(document), formatted)]
}

Expand Down
9 changes: 5 additions & 4 deletions packages/language-server/src/prisma-fmt/format.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import prismaFmt from '@prisma/prisma-fmt-wasm'
import { DocumentFormattingParams } from 'vscode-languageserver'

export default function format(
identWidth: number,
text: string,
schema: string,
options: DocumentFormattingParams,
onError?: (errorMessage: string) => void,
): string {
console.log('running format() from prisma-fmt')
try {
return prismaFmt.format(text)
return prismaFmt.format(schema, JSON.stringify(options))
} catch (errors) {
if (onError) {
onError(
Expand All @@ -19,6 +20,6 @@ export default function format(
)
console.warn(errors)

return text
return schema
}
}

0 comments on commit 441f520

Please sign in to comment.