-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy/paste improvements #9734
Copy/paste improvements #9734
Conversation
for (const copiedNode of clipboardData) { | ||
const { expression, documentation, visualization, colorOverride } = copiedNode | ||
graphStore.createNode( | ||
(clipboardData.length === 1 ? graphNavigator.sceneMousePos : null) ?? Vec2.Zero, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Positioning of multiple nodes is currently rudimentary; this will be fixed with the new API that will be introduced for #9703.
// Copy and paste it. | ||
await page.keyboard.press(`${CONTROL_KEY}+C`) | ||
await page.keyboard.press(`${CONTROL_KEY}+V`) | ||
await expect(nodeToCopy).toBeSelected() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think newly-created nodes should always be selected; I'll implement this as part of #9703.
Depends on #9731 for tests to pass. |
import * as locate from './locate' | ||
|
||
const MAIN_FILE_NODES = 11 | ||
|
||
const COLLAPSE_SHORTCUT = os.platform() === 'darwin' ? 'Meta+G' : 'Control+G' | ||
const COLLAPSE_SHORTCUT = `${CONTROL_KEY}+G` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some changes ago, now it's possible to read COLLAPSE shortcut from bindings.ts (used for example in https://github.com/enso-org/enso/blob/e1893b65af1774bacd4b862cff11d28886bb81c2/app/gui2/src/composables/__tests__/selection.test.ts) You may try to use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think E2E tests have access to the main app source tree
@@ -10,18 +11,18 @@ test('Adding new node', async ({ page }) => { | |||
await locate.addNewNodeButton(page).click() | |||
await expect(locate.componentBrowserInput(page)).toBeVisible() | |||
await page.keyboard.insertText('foo') | |||
await page.keyboard.press('Control+Enter') | |||
await page.keyboard.press(`${CONTROL_KEY}+Enter`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Does it mean that E2E tests never worked on mac?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the most recent tests, but yeah, it has never worked on mac
app/gui2/shared/ast/text.ts
Outdated
')', | ||
'gu', | ||
) | ||
const escapeRegex = new RegExp(`${[...fixedEscapes, '\\p{Surrogate}'].join('|')}`, 'gu') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why is it inside ``? join should return string already.
- What is this
{Surrogate}
tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment:
Unpaired-surrogate codepoints are not technically valid in Unicode, but they are allowed in Javascript strings.
Enso source files must be strictly UTF-8 conformant.
documentation?: string | undefined | ||
visualization?: VisualizationMetadata | undefined | ||
colorOverride?: string | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if, by default, we would copy all the metadata. So we could keep metadata
field as Omit<NodeMetadataFields, 'position'>
// Unpaired-surrogate codepoints are not technically valid in Unicode, but they are allowed in Javascript strings. | ||
// Enso source files must be strictly UTF-8 conformant. | ||
'\\p{Surrogate}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I actually missed that this is Regex feature (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape)
app/gui2/shared/ast/tree.ts
Outdated
function isNodeMetadataField(property: string) { | ||
return ['position', 'visualization', 'colorOverride'].includes(property) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about https://www.npmjs.com/package/ts-transformer-keys? You could use keys<NodeMetadataFields>()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use compiler plugins without switching from vite's default transpiler (esbuild) to tsc, which would have a build-time cost: evanw/esbuild#1963.
We have a utility function allKeys
that adds type-level correctness checking; I'll use that here. It is not as convenient as the TS-transformer (it requires an "example object" as an input), but it doesn't impose any unusual requirements on our build process.
@@ -22,16 +22,14 @@ interface ClipboardData { | |||
interface CopiedNode { | |||
expression: string | |||
documentation?: string | undefined | |||
visualization?: VisualizationMetadata | undefined | |||
colorOverride?: string | undefined | |||
metadata?: NodeMetadataFields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't want to exclude position from copied metadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position
is ignored in the metadata supplied for node creation because a separate parameter overrides it.
Pull Request Description
Copying nodes:
Table
node, handled the same way as Excel data.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.