Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Generated code suggestion can't be applied to the file correctly #6171

Copy link
Copy link
@rebornix

Description

@rebornix
Issue body actions

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

image

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.