turn on formatting test now working (#2341)

turn on test now working

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-05-10 16:51:54 -07:00
committed by GitHub
parent 726fd02bad
commit 6501072d80
2 changed files with 22 additions and 15 deletions

View File

@ -299,12 +299,18 @@ test('if you click the format button it formats your code', async ({
test('if you use the format keyboard binding it formats your code', async ({ test('if you use the format keyboard binding it formats your code', async ({
page, page,
}) => { }) => {
test.skip(
true,
"I can't figure out how to get the keyboard shortcut to work (in playwright)"
)
const u = getUtils(page) const u = getUtils(page)
await page.addInitScript(async () => {
localStorage.setItem(
'persistCode',
`const part001 = startSketchOn('XY')
|> startProfileAt([-10, -10], %)
|> line([20, 0], %)
|> line([0, 20], %)
|> line([-20, 0], %)
|> close(%)`
)
})
await page.setViewportSize({ width: 1000, height: 500 }) await page.setViewportSize({ width: 1000, height: 500 })
const lspStartPromise = page.waitForEvent('console', async (message) => { const lspStartPromise = page.waitForEvent('console', async (message) => {
// it would be better to wait for a message that the kcl lsp has started by looking for the message message.text().includes('[lsp] [window/logMessage]') // it would be better to wait for a message that the kcl lsp has started by looking for the message message.text().includes('[lsp] [window/logMessage]')
@ -322,15 +328,12 @@ test('if you use the format keyboard binding it formats your code', async ({
// check no error to begin with // check no error to begin with
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
await page.click('.cm-content') await u.openDebugPanel()
await page.keyboard.type(`const part001 = startSketchOn('XY') await u.expectCmdLog('[data-message-type="execution-done"]')
|> startProfileAt([-10, -10], %) await u.closeDebugPanel()
|> line([20, 0], %)
|> line([0, 20], %)
|> line([-20, 0], %)
|> close(%)`)
await page.click('.cm-content') // focus the editor
await page.click('.cm-line')
// Hit alt+shift+f to format the code // Hit alt+shift+f to format the code
await page.keyboard.press('Alt+Shift+KeyF') await page.keyboard.press('Alt+Shift+KeyF')

View File

@ -264,8 +264,12 @@ export class LanguageServerPlugin implements PluginValue {
) )
return null return null
this.sendChange({ this.client.textDocumentDidChange({
documentText: this.view.state.doc.toString(), textDocument: {
uri: this.documentUri,
version: this.documentVersion++,
},
contentChanges: [{ text: this.view.state.doc.toString() }],
}) })
const result = await this.client.textDocumentFormatting({ const result = await this.client.textDocumentFormatting({