Skip to content

Commit

Permalink
Prevent file save on import addition to avoid tree view refreshes
Browse files Browse the repository at this point in the history
  • Loading branch information
vinzbarbuto committed Oct 3, 2024
1 parent 58858b4 commit 2ac798e
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/lfview/lf-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,22 +720,17 @@ export class LFDataProvider implements vscode.TreeDataProvider<LFDataProviderNod

/**
* Adds the specified text to the active text editor at the given index.
* If the text is added successfully, the document is saved.
*
* @param editor - The active text editor.
* @param idx - The index at which to insert the text.
* @param importText - The text to insert.
* @returns A Promise that resolves when the text has been added and the document saved.
*/
async addTextOnActiveEditor(editor: vscode.TextEditor, idx: number, importText: string): Promise<void> {
const document = editor.document;
try {
const success = await editor.edit(editBuilder => {
await editor.edit(editBuilder => {
editBuilder.insert(new vscode.Position(idx, 0), importText);
});
if (success) {
await document.save();
}
} catch (error) {
console.error('Failed to add text or save document:', error);
}
Expand Down

0 comments on commit 2ac798e

Please sign in to comment.