Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute a snippet without using the widget #8

Open
zaggino opened this issue Nov 27, 2014 · 17 comments
Open

Execute a snippet without using the widget #8

zaggino opened this issue Nov 27, 2014 · 17 comments

Comments

@zaggino
Copy link
Member

zaggino commented Nov 27, 2014

Suggested by @TomMalbran:

It might be cool to write in one line the name of the snippet and then the variables and after pressing Alt-S you get the snippet pasted without going through the inline editor. If there are variables missing, the snippets editor opens on the snippet selected and the cursor placed on the first unfilled parameter.

@TomMalbran
Copy link

As an example for the ng-controller snippet i would write ng-controller myModule myController in a new line and then press Alt-S.

It might be hard if the line is not empty.

@zaggino
Copy link
Member Author

zaggino commented Nov 28, 2014

If the line is not empty (it contains some other non-whitespace before ng-controller myModule myController) I guess this widget would open and prefill ng-controller into search and myModule myController into variables so the user can confirm immediately with Enter key.

@TomMalbran
Copy link

That can work. But if for that line ng-controller is the only possible snippet, maybe it should jus complete it. It should show the editor when is not clear which snippet the user wants.

I am thinking that maybe it should use the line up to the cursor. Then you sort the snippets from the one with the most parameters to the one with the least. For each snippet you check if the word that is at the cursor position - the amount of parameter - 1 is the name of a snippet. If there are 2 possible snippets to show, then it shows the editor.

@zaggino
Copy link
Member Author

zaggino commented Dec 5, 2014

Released 0.2.0 as the first iteration on this issue. Will continue with 0.2.x releases until it gets satisfactory :)

@TomMalbran
Copy link

Cool. Looking good as a first release. One minor thing is that it looks weird that when a snippet is inserted automatically it opens the inline editor and closes it a second later.

@zaggino
Copy link
Member Author

zaggino commented Dec 8, 2014

Updated to 0.2.1, that weird blink with the widget should now be gone and you can also prefill variables from the line now: https://github.com/zaggino/brackets-snippets/blob/master/CHANGELOG.md

@ThaisRobba
Copy link

👍 Just tested it, working nicely so far

@zaggino
Copy link
Member Author

zaggino commented Dec 9, 2014

Implemented in version 0.3.0, let me know if there're any issues that should be fixed.

@ThaisRobba
Copy link

Hmm version 0.3.0 broke it for me. Before, doing

f funcName

Would expand into:

function funcName() {

}

But now it expands into:

function undefined() {

}

@zaggino
Copy link
Member Author

zaggino commented Dec 10, 2014

Going to fix that, can you paste your exact snippet you're using here?

@TomMalbran
Copy link

I found another issue trying to test this one. I created a snippet called f with something like function {{$1:name}}() {}, but when I write f name it uses the bs-container-fluid as the snippet instead of my function snippet.

@ThaisRobba
Copy link

Trigger is

 fun

Snippet is:

function {{$1:funcName}}({{!cursor}}) {

}

@zaggino
Copy link
Member Author

zaggino commented Dec 10, 2014

Version 0.3.1 is up, both issues should be now fixed. Let me know how it goes, thanks :)

@ThaisRobba
Copy link

Yep, works fine now :D

@Alex0007
Copy link

Nothing happened when i press Alt - S in editor line with snippet name

Ubuntu 14.10, Brackets 1.1, extenstion v 0.4.0

@zaggino
Copy link
Member Author

zaggino commented Jan 24, 2015

Try menu: edit > trigger code snippet and the widget should appear.
If not, check the console logs for error messages.

@Alex0007
Copy link

It does not appers with snppets, that have not variables.
2015-01-24 18 33 40
"cl" snippet, for example.
console.log({{!cursor}})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants