Fix existing: Extrude from command bar selects extrude line after (#3547)

* Fix existing: Extrude from command bar selects extrude line after #3545

* remove as

---------

Co-authored-by: Frank Noirot <frank@zoo.dev>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
This commit is contained in:
Kurt Hutten
2024-08-22 16:13:08 +10:00
committed by GitHub
parent 682099c1ad
commit 37a1208924
2 changed files with 36 additions and 44 deletions

View File

@ -12,10 +12,9 @@ test.afterEach(async ({ page }, testInfo) => {
}) })
test.describe('Command bar tests', () => { test.describe('Command bar tests', () => {
// TODO fixme: enter is not working in the command bar test('Extrude from command bar selects extrude line after', async ({
test.fixme( page,
'Extrude from command bar selects extrude line after', }) => {
async ({ page }) => {
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -51,11 +50,9 @@ test.describe('Command bar tests', () => {
await expect(page.locator('.cm-activeLine')).toHaveText( await expect(page.locator('.cm-activeLine')).toHaveText(
`const extrude001 = extrude(${KCL_DEFAULT_LENGTH}, sketch001)` `const extrude001 = extrude(${KCL_DEFAULT_LENGTH}, sketch001)`
) )
} })
)
// TODO fixme: enter is not working in the command bar test('Fillet from command bar', async ({ page }) => {
test.fixme('Fillet from command bar', async ({ page }) => {
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',

View File

@ -1,6 +1,5 @@
import { Completion } from '@codemirror/autocomplete' import { Completion } from '@codemirror/autocomplete'
import { EditorView, ViewUpdate } from '@codemirror/view' import { EditorView, ViewUpdate } from '@codemirror/view'
import { EditorState } from '@codemirror/state'
import { CustomIcon } from 'components/CustomIcon' import { CustomIcon } from 'components/CustomIcon'
import { useCommandsContext } from 'hooks/useCommandsContext' import { useCommandsContext } from 'hooks/useCommandsContext'
import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext' import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext'
@ -84,17 +83,13 @@ function CommandBarKclInput({
if (event.key === 'Backspace' && value === '') { if (event.key === 'Backspace' && value === '') {
event.preventDefault() event.preventDefault()
stepBack() stepBack()
} else if (event.key === 'Enter') {
event.preventDefault()
handleSubmit()
} }
}, },
}), }),
varMentions(varMentionData), varMentions(varMentionData),
EditorState.transactionFilter.of((tr) => {
if (tr.newDoc.lines > 1) {
handleSubmit()
return []
}
return tr
}),
EditorView.updateListener.of((vu: ViewUpdate) => { EditorView.updateListener.of((vu: ViewUpdate) => {
if (vu.docChanged) { if (vu.docChanged) {
setValue(vu.state.doc.toString()) setValue(vu.state.doc.toString())