-
Notifications
You must be signed in to change notification settings - Fork 317
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
Enable the Code Editor, with new apply-text-edits algo. #9055
Conversation
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.
approving the single-line change to dashboard code.
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.
Lots of small nitpicks, nothing serious enough to block merging this. The comments can be addressed either immediately, or as a separate PR.
app/gui2/shared/util/data/text.ts
Outdated
while (starts[0] !== undefined) { | ||
if (starts[0] < range[0]) { | ||
startMap.set(starts[0], starts[0] + offset) | ||
} else if (starts[0] <= range[1]) { | ||
startMap.set(starts[0], range[0] + offset + insert.length) | ||
} else { | ||
break | ||
} | ||
starts.shift() | ||
} | ||
while (ends[0] !== undefined) { | ||
if (ends[0] <= range[0]) { | ||
endMap.set(ends[0], ends[0] + offset) | ||
} else if (ends[0] <= range[1]) { | ||
endMap.set(ends[0], range[0] + offset) | ||
} else { | ||
break | ||
} | ||
ends.shift() | ||
} |
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.
Shifting arrays in a loop is unnecessarily expensive. Better to replace those with index accesses, and maintain two incrementing "read head" indices throuhgout the function.
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.
Hm. The typechecker doesn't seem to know that while (ends[endsIndex] !== undefined)
implies that ends[endsIndex] !== undefined
at the start of the loop body, so I'll use iterators.
(ready) => { | ||
if (ready) graphStore.moduleSource.observe(observeSourceChange) | ||
}, | ||
{ immediate: true }, |
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.
If viewInitialized
is always set asynchronously, then this immediate
has no real effect, since ready
will always be false on the first execution.
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.
Actually in practice projectStore.module
is already non-null when the top-level watchEffect
above runs, so this needs immediate
to work.
function* fieldDataEntries<Fields>(map: FixedMapView<Fields>) { | ||
for (const entry of map.entries()) { | ||
// All fields that are not from `AstFields` are `FieldData`. | ||
if (!astFieldKeys.includes(entry[0] as any)) yield entry as [string, FieldData] |
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.
Since the key type is checked here, the return type can be narrowed.
if (!astFieldKeys.includes(entry[0] as any)) yield entry as [string, FieldData] | |
if (!astFieldKeys.includes(entry[0] as any)) yield entry as [keyof RawAstFields, FieldData] |
This should help further reduce casts down the line.
Also to contain those remaining (trivial in-context) type casts, a separate isAstFieldKey
type asserting function could be created. Same for FieldData
validation, though this one may be a bit harder to balance safety and runtime verification overhead. But given that this effectively deals with arbitrary network received data, we shouldn't just blindly trust it.
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 return the fields that are not from AstFields
, so I don't see a good way to narrow it.
Runtime AST field validation would need to occur when applying updates to the module, and seems orthogonal to this new functionality--on develop
we already trust the received AST fields not to cause TypeErrors.
This reverts commit c811a5a.
Add a test for some functionality introduced in #9055.
Pull Request Description
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
.