microsoft / microsoft/vscode-pull-request-github
Generated code suggestion can't be applied to the file correctly
Open
@alexr00 is already working on this.
Since Aug 27, 2024.
bug
- Dominant language
- TypeScript
- Stars
- 2.6k
- Forks
- 796
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 46
Description
Testing #6160
Initial code
preserveElements(indexes: number[]): void {
this.preservedItems.clear();
for (const index of indexes) {
if (index >= 0 && index < this.items.length) {
const item = this.items[index];
this.preservedItems.add(item);
if (!item.row) {
this.insertItemInDOM(index);
}
this.updateItemInDOM(item, index);
}
}
}
new code
preserveElements(indexes: number[]): void {
this.preservedItems.clear();
let updatePreservedElements = false;
for (const index of indexes) {
if (index >= 0 && index < this.items.length) {
const item = this.items[index];
this.preservedItems.add(item);
if (!item.row) {
this.insertItemInDOM(index);
updatePreservedElements = true;
}
this.updateItemInDOM(item, index);
}
}
if (updatePreservedElements) {
this.rerender();
}
}
The generated code suggestion
let updatePreservedElements = false;
for (const index of indexes) {
if (index >= 0 && index < this.items.length) {
const item = this.items[index];
this.preservedItems.add(item);
if (!item.row) {
this.insertItemInDOM(index);
updatePreservedElements = true;
}
}
}
if (updatePreservedElements) {
this.rerender();
}
However when applied to the editor, the file was in a broken state
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.