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

error on usage #6

Closed ctf0 closed 4 years ago

ctf0 commented 4 years ago

if there is something i could do on my end, plz tell me and i can send a PR 👍

ctf0 commented 4 years ago

@Gruntfuggly any news on this ?

Gruntfuggly commented 4 years ago

Sorry - I hadn't seen this - must of missed the email. I'll look into it...

Gruntfuggly commented 4 years ago

Not seeing the error here (with 1.41.1). Where did you define the snippet? It seems to work OK for me if I put it in a global snippets or the PHP snippets.

There is a debug output channel (auto-snippets.debug). Can you enable it and see what is displayed in there?

ctf0 commented 4 years ago

i found the issue.

when u create an empty php file, even if the syntax in the status bar says its PHP the scope is actually still html using inspect tm scope cmnd until u add the php tag <?php then the snippet will show up.

not sure why they did it like that, but is there a way around that ?

believe it or not checking inspect context key shows resourceLangId: "php" & editorLangId: "php" lol 😞

Gruntfuggly commented 4 years ago

Are you sure there isn't another extension interfering? Or have you added something to files.associations ?

ctf0 commented 4 years ago

nop, have u tried the steps i described to repro ?

Gruntfuggly commented 4 years ago

You don't have to use the language to generate the snippet - you can use a glob pattern instead. Try "pattern":"*.php" instead?

Gruntfuggly commented 4 years ago

Yes - I used your config and snippet.

Gruntfuggly commented 4 years ago

Or maybe "**/*.php"

ctf0 commented 4 years ago

nothing changed, r u using the same editor version ?

Gruntfuggly commented 4 years ago

I'm on 1.41.1, the stable version. Maybe is insiders? Hold on...

Gruntfuggly commented 4 years ago

Just tried on 1.42.0-insiders, and it was OK too.

Output window shows:

Opened empty file /Users/nige/Projects/vscode-extensions/auto-snippet/empty.php
 Matched language php
 Inserting snippet basic-php
 Running command: namespaceResolver.generateNamespace
ctf0 commented 4 years ago

i've tried many things but all remain the same, other from the bug i described i dont know how to solve it 😢 .

still thanx for ur help.

Gruntfuggly commented 4 years ago

Did you try the glob pattern as an alternative?

ctf0 commented 4 years ago

yeap, non works

Gruntfuggly commented 4 years ago

Whats displayed in the debug log? If I use the pattern above I get:

Opened empty file /Users/nige/Projects/vscode-extensions/auto-snippet/chips.php
 Matched pattern **/*.php
 Inserting snippet basic-php
 Running command: namespaceResolver.generateNamespace
ctf0 commented 4 years ago

i keep getting

Opened empty file /Users/koka/Public/GitHub/demos/app/asd.php
 Matched language php
 Inserting snippet basic-php
Opened empty file /Users/koka/Public/GitHub/demos/app/asd.php.git
 No snippet found

but nothing is added to the file, also not sure where asd.php.git came from

Gruntfuggly commented 4 years ago

That's because vscode opens a background file for version control, but you can ignore it.

I've realised one thing - there is a timeout when inserting a snippet, which generates the error you are seeing. It basically gives it 1 second to insert the snippet, and shows the error if it doesn't happen. It doesn't explain why you're not seeing the snippet, but it makes sense that it's not finding the snippet and inserting it. So it looks like it can't find it for some reason?

Could there be a syntax error in your snippets file?

ctf0 commented 4 years ago

its exactly as above, also it works well when i manually initiate it

Gruntfuggly commented 4 years ago

Did you ever get to the bottom of this or is it still an issue?

ctf0 commented 4 years ago

sadly no, i stopped using it because of the side effect 😢

Gruntfuggly commented 4 years ago

Sorry we couldn't work out what the problem was. If you ever decide to investigate it again, let me know.