Gruntfuggly / auto-snippet

A vscode extension to automatically insert a predefined snippet when a file is created, or an empty file is opened.
Other
14 stars 1 forks source link

Inserts snippet on every file move #8

Closed prk3 closed 3 years ago

prk3 commented 3 years ago

Hey. Big thanks for working on this addon. It's one of the first plugins I add to a fresh vscode setup.

I noticed a small bug. When you move a new file between folders, a snippet is inserted multiple times. Here is a screen capture. Peek 2020-09-30 16-25

vscode version: 1.49.2 auto-snippet version: 0.0.8 config:

"autoSnippet.snippets": [
        {
            "pattern": "**/*.rs",
            "snippet": "test-snippet"
        },
    ],
"test-snippet": {
        "prefix": "test-snippet",
        "body": [
            "Some text",
            ""
        ],
        "description": "test-snippet"
    }
Gruntfuggly commented 3 years ago

It should probably check if the editor is empty before inserting. I'll take a look.

Gruntfuggly commented 3 years ago

OK, I've reproduced this - it seems to only happen if the new file hasn't been saved. It does already check that the file is empty, but it seems that until the file is saved, it appears to still be empty.

I'll carry on investigating...

Gruntfuggly commented 3 years ago

I've found a hack which seems to fix it - selecting any text before inserting the snippet works. I'm just checking there are no side effects...

Gruntfuggly commented 3 years ago

OK - I've uploaded a new version - let me know if it works OK.

prk3 commented 3 years ago

Seems like the bug gone. You can see how the text is selected for a fraction of a second. Thanks a lot!