Fix new file creation

This commit is contained in:
Saoud Rizwan
2024-09-05 13:18:13 -04:00
parent 94fd9e8f47
commit 26f7d99208

View File

@@ -892,11 +892,15 @@ export class ClaudeDev {
// edit needs to happen after we close the original tab // edit needs to happen after we close the original tab
const edit = new vscode.WorkspaceEdit() const edit = new vscode.WorkspaceEdit()
const fullRange = new vscode.Range( if (!fileExists) {
updatedDocument.positionAt(0), edit.insert(updatedDocument.uri, new vscode.Position(0, 0), newContent)
updatedDocument.positionAt(updatedDocument.getText().length) } else {
) const fullRange = new vscode.Range(
edit.replace(updatedDocument.uri, fullRange, newContent) updatedDocument.positionAt(0),
updatedDocument.positionAt(updatedDocument.getText().length)
)
edit.replace(updatedDocument.uri, fullRange, newContent)
}
// Apply the edit, but without saving so this doesnt trigger a local save in timeline history // Apply the edit, but without saving so this doesnt trigger a local save in timeline history
await vscode.workspace.applyEdit(edit) // has the added benefit of maintaing the file's original EOLs await vscode.workspace.applyEdit(edit) // has the added benefit of maintaing the file's original EOLs