Sublime Forum

Plugin to hlep with img tags in HTML

#42

Neither. Nothing in the popup, and no attributes.

0 Likes

#43

hmm… not sure what the problem could be. It might help if you gave me more info. Could you send me a basic snippet of code you’re using it with?

Also, could you humor me by re-downloading the beta branch, making the branch is set to ‘beta’ in git (this has caused some problems in the past. When you download a branch from github, it could still be set to master.) You mentioned having AutoFileNameBeta as the folder. Do you still have AutoFileName (master) installed? Make sure that’s not installed too. Also, I don’t think its a problem but it might help, could you disable ZenCoding?

If there are no errors in the console, I’m not really sure what the problem is. Sorry.

0 Likes

#44

Yeah, it’s weird cause it was working (aside from writing out the attributes). This is what I did:

  • re-grabbed beta from Github (461b5dc),
  • removed ZenCoding,
  • updated autofilename.sublime-settings: “afn_proj_root”: “/Users/skube/Desktop”
  • made sure the User keybindings had the code you posted earlier
  • restarted ST2
  • created an HTML file as listed below and saved to the desktop
  • within the IMG tag typed “/” then Ctrl+Spacebar

[code]

<img src="/">
[/code]

The result:

  • the popup takes me to OS root (not the expected Desktop)
  • even after navigating to Desktop, the image file doesn’t show dimensions

In any case, thanks for all the work, perhaps it’s something silly and will be fine after you merge branches.

0 Likes

#45

COD312: I have git cloned the repo and checked out the beta branch (all in {packages}/AutoFileName) and there’s definitely one bug but not a big deal.

If you’re editing a new, unsaved document, the completions don’t work and the following comes up on the console:

Traceback (most recent call last):
  File "/Applications/Sublime Text 2.app/Contents/MacOS/sublime_plugin.py", line 236, in on_query_completions
    res = callback.on_query_completions(v, prefix, locations)
  File "./autofilename.py", line 83, in on_query_completions
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/posixpath.py", line 82, in split
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

My guess is due to the ‘path’ of the current document being “” or None or something similar. As I said, not a big deal but something to consider.

As for use, I’ll have a proper test (OSX I’m afraid, though) but it’s great the beta version actually addresses my points. I have noticed, however, that there’s no automatic completions popup. I still have to to <img src="{ctrl+space} in order to get the popup. Is that correct? I haven’t done the suggested keybinding step in the README as it sounded like you said that is no longer required. Correct me if I’m wrong.

Finally, regarding my comment on png/jpg/gif, the only reason I said that (as I realise ST’s fuzzy completion negates the requirement there though) was to stop it having to load too many files for completion.

0 Likes

#46

This has already be addressed in an unpushlished ‘experimental’ branch.

Just added this :smile: (and it’s pretty awesome)

AutoFileName has more uses than just img insertion. So there is no reason to limit it. Was there a problem with using the wildcard to hide some results? Also, from a technical standpoint, if I told AutoFileName to only show images, it wouldn’t speed anything up because it would still need to look at every file to check the extension. The only really time killer is loading the image dimensions because it has to read in the image byte stream to get the dimensions :frowning: but don’t you worry about that.

Well, I added the wildcard because sometimes fuzzy completion isn’t enough. Typing in png will display results for pingpong.html or this_is_not_a_png.jpg. So instead you can have |.png.

Thank you. The more testers the better. That way I can find all the bugs and use cases before I merge.

@skube: Fortunately, the image dimensions stopped working for me too. So I can now better diagnose what the problem is.

0 Likes

#47

MERGED!

0 Likes

#48

Still doesn’t work for me :cry:

0 Likes

#49

Just the image dimensions? or the whole plugin?

0 Likes

#50

[quote=“C0D312”]

Just the image dimensions? or the whole plugin?[/quote]

just pulled the latest merged version and the behavior is all quite nice now. love how it autotriggers and i don’t even have to type the / anymore to keep digging down into directories.

alas, the writing of the height and width attributes is broken now. i can see the height and width in the autocomplete menu, but when i do the completion the attributes are not written into the img tag.

EDIT: in case you were wondering @C0D312, i got rid of the old keymap settings and am using the new ones from the latest commit.

0 Likes

#51

I’m investigating now. Any errors in the console?

EDIT: I found the bug. It was very stupid on my part. Hopefully it will work now. let me know

0 Likes

#52

Thanks. I’m actually impressed by how it feels. Almost native :smile: It’s the little things that count, not the fact that the image dimensions have taken me ages to get working…

0 Likes

#53

[quote=“C0D312”]I’m investigating now. Any errors in the console?

EDIT: I found the bug. It was very stupid on my part. Hopefully it will work now. let me know[/quote]

yes, working for me on the latest pull [f132583].

thanks again for all your work on this really useful plugin.

0 Likes

#54

Yay! Latest version works (sorta) for me again. It seems to work for one or two directories but then seems to fail.

I made sure to set the following in autofilename.sublime-settings:
“auto_file_name_use_project_root”: true,
“afn_proj_root”: “/mywebserverroot/”
and set the User Keybindings as before.

But I’m getting the following error in the console:

Traceback (most recent call last): File ".\sublime_plugin.py", line 236, in on_query_completions res = callback.on_query_completions(v, prefix, locations) File ".\autofilename.py", line 134, in on_query_completions File ".\autofilename.py", line 76, in fix_dir AttributeError: 'NoneType' object has no attribute 'get'

Also, I’m having another problem since updating where ST2 gives an intermittent error (not sure if it’s related*):
“Sublime Text 2 has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.”

Using ST2 2181 on Win7

*edit: I tried disabling the AutoFileName package and I didn’t get the error, so it’s definitely related.

0 Likes

#55

@skube, I’ll have time to test on windows tomorrow. hold tight :smile:

0 Likes

#56

No worries. It’s great that you are responsive and working so hard. I hope it’s not something silly I’m doing wrong.

One question, is there a way to hide hidden files (e.g. .DS_Store) from the popup?

0 Likes

#57

[quote=“skube”]No worries. It’s great that you are responsive and working so hard. I hope it’s not something silly I’m doing wrong.

One question, is there a way to hide hidden files (e.g. .DS_Store) from the popup?[/quote]

Thanks for the suggestion. I’ll add it.

0 Likes

#58

Great work COD312, this works flawlessly for me. However, my friend also on ST2 OSX doesn’t seem to get width and height in the autocomplete (they appear in the popup, which is certainly good enough, don’t get me wrong). It looks like it might be related to HTML5 vs XHTML. My img completion gives me , but hsi is and if I manually create an image tag like and then place my cursor in the src quotes, then I also don’t get dimensions. Is this something that’s wrong with the plugin or more related to scopes and whatnot?

0 Likes

#59

I’ll look into this. It’s probably an off-by-one error somewhere when I check the scope.

Anyway, I think I just fixed the windows problem. All it needed was a little ‘b’. Apparently windows handles file opening differently. To make sure that it reads it correctly on windows, you open the file in binary mode by changing the open statement to open(file, ‘rb’).

Works Cited: stackoverflow.com/questions/6318 … on-windows

0 Likes

#60

pushed fix for windows. Found a silly bug when handling width and height.

This is a bug with the HTML syntax definition. I fixed AutoFileName using a workaround. Essentially, all whitespace before the end tag is consumed as ‘tag.end’ (a different scope than the tag.) Anyway, everything should work now :smile: Let me know.

0 Likes

#61

Seems to work for me now (at least on my windows machine*). Hurray!

A couple of things, how is the popup dropdown ordered? And is there a way to change the order?

*Although, I still have problems starting up ST2 with AutoFileName enabled, which is a major downer and renders the plugin essentially unusable for me.
workaround: I can disable the plugin before quitting ST2, then enable it once ST2 has started.

**Edit: since updating to build 2195, I no longer have problems starting up with AutoFileName enabled.

0 Likes