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

Auto-close problems #149

Open
redtopia opened this issue Oct 1, 2014 · 29 comments
Open

Auto-close problems #149

redtopia opened this issue Oct 1, 2014 · 29 comments

Comments

@redtopia
Copy link

redtopia commented Oct 1, 2014

The auto-close feature appears to assume that all CF tags need to be closed. In my codebase, it's common not to close the ones that are not required to be closed (<cfset> and <cfmodule>). Other problems:

<script> - not closed correctly
<cfcatch> - not closed at all
<cfelse> - closed with </cfelse>
@redtopia
Copy link
Author

redtopia commented Oct 3, 2014

I am also finding it impossible to turn off this feature. In my package settings for "Settings - User", I have "auto_close_cfml": false set, but the package still auto-closes.

@redtopia
Copy link
Author

redtopia commented Oct 9, 2014

Bump... I am finding it incredibly frustrating to work with the constant incorrect auto-close markup insertions. Is there any way to turn this feature off until it works better?

@atomi
Copy link
Contributor

atomi commented Oct 9, 2014

I don't know I've been busy with devops stuff. Are you using the development branch for ST3?

@redtopia
Copy link
Author

redtopia commented Oct 9, 2014

I'm using the latest beta... build 3065

@redtopia
Copy link
Author

Any movement on this... there are numerous problems with this feature and all I want to do is turn it off. Here's one that messes me up all day long:

    <cfif NOT IsDefined("Session.mlErrors")>
        <cfset Session.mlErrors = []>
    </cfset>

As you can see, autoclose is trying to close cfset.

I realize I could modify my coding and close all CF tags, but I would much rather simply turn this feature off. Is there any way for me to do that????? PLEASE HELP!

@atomi
Copy link
Contributor

atomi commented Oct 19, 2014

You can remove the ">" keybinding in the CF package all together if you don't want autoclose but disabling it via settings works for me.

@redtopia
Copy link
Author

Here's my User Settings under: Package Settings -> ColdFusion -> Settings - User

{
    // setting this to true will enable verbose tag completions
    // cf10 only for now
    "verbose_tag_completions": false,

    // will close block coldfusion tags on ">" keypress
    "auto_close_cfml": false,

    // will auto indent tags on auto_close_cfml
    "auto_indent_on_close": false,

    // enables method completions in cfscript components
    "component_method_completions": true,

    // cf7, cf8, cf9, or cf10
    "dictionary": "cf10"
}

Here are the default package settings: Package Settings -> ColdFusion -> Settings - Default

{
    // will close block cfml tags on ">" keypress
    "auto_close_cfml": false,

    // will auto indent tags on auto_close_cfml
    "auto_indent_on_close": true,

    // enables method completions in cfscript components
    "component_method_completions": true,

    // railo4, cf7, cf8, cf9, or cf10 (restart required)
    "dictionary": "cf10"
}

I just installed the latest release of ST3 (3066), and restarted. With the settings above, I cannot turn off this feature. I've restarted... autoclose continues to happen. Going the other route, by changing the key bindings, I'm assuming I would need to add something in the Key Bindings - User for the ">" key. In the Key Bindings - Default, I see this:

// Auto-close ColdFusion block tags
{ "keys": [">"], "command": "close_cftag", "context":
    [
        // selectors aren't working as I expect, we'll just use general scopes here
        { "key": "selector", "operator": "equal", "operand": "text.html.cfm, source.cfscript.cfc"},
        { "key": "following_text", "operator": "not_regex_contains", "operand": "^>", "match_all": true }
    ]
},

Exactly what should I do to this, and should I edit the Key Bindings - Default file, or add something to the Key Bindings - User file?

@redtopia
Copy link
Author

Is this project dead, or will is any work being done to support ST3? I really need a solution to this problem or I need to find a new editor.

@jimpriest
Copy link

This project is open source, free and hacked on by various people in their free time.

The important part is 'in their free time'.

There are two things in play here, Sublime Text, which you've indicated you are using the latest version of (3066), and the CF package.

Are you using the latest 'develop' branch of the CF package? Installation instructions are outlined at the top of the README.md file of this Github project.

@jimpriest
Copy link

I'm running a recent version of ST3 and the development branch of this package (on Windows).

I turned auto_close_cfml to false and if I now type it no longer automatically creates the closing , so it does appear to work.

@redtopia
Copy link
Author

I don't have git installed... can I download the zip folder and unzip it into my packages folder? That's how I originally got it working.

@jimpriest
Copy link

That should work. Change the branch on Github to "Development" and then when you download the zip it should be 'development.zip'.

Then unzip and figure out where your 'Packages' directory is. What OS are you using?

@redtopia
Copy link
Author

Thanks... I'll try reinstalling. I'm running Windows 7.

@redtopia
Copy link
Author

Still not working. Here's my test case, which demonstrates the problems I'm having with this package.

<cfif x EQ 1>
    <cfset y = 1>
</cfset>

After typing x EQ 1>, the suggestion menu is highlighted to "bitMaskClear", so if I hit the ENTER key, bitMaskClear is inserted into my code. I have to hit ESC first, which is also a huge problem I need to fix. Then, I enter cfset y = 1>, no problems... phew! Then I enter </ and as soon as I enter the forward slash, auto-complete tries to close my cfset tag.

Is there anything I can do to make this work better?

@atuttle
Copy link
Collaborator

atuttle commented Oct 21, 2014

Let's start by trying to get a super-clean repro. Remove or disable all other pugins except this one and make sure your problem still exists.

@atuttle
Copy link
Collaborator

atuttle commented Oct 21, 2014

For what it's worth, I do see the same </cfset> problem for myself when I use your code sample, but I literally never have this problem because I added a special keyboard shortcut for unrelated productivity purposes:

{ "keys": ["alt+,"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } }

You have to have the XML package installed for this to work. What this does is when I type alt+, (which I like to think of as alt+<) it creates a tag-pair for me. It is a paragraph tag: <p></p> but the first P is already highlighted, and as I type, the closing tag is updated. So if I want a CFIF tag-pair, my keystrokes are:

  • alt+<
  • cfif
  • space
  • conditional logic
  • escape (to break out of the additional logic that comes with this command... hit tab and you'll be taken to the next "location" in the tag... I just hit escape)

I know it's a workaround, but if you give it a shot you might find you like it. Like I said, I never even realized this was a problem because I always use alt+<.

@redtopia
Copy link
Author

OK, I'll give it a try. And because you do it this way, you probably don't see the auto-suggest problem in your work flow either, right?

@atuttle
Copy link
Collaborator

atuttle commented Oct 21, 2014

I suspect that your particular autosuggest option ("bitMaskClear") is coming from another one of your plugins.

@redtopia
Copy link
Author

I temporarily disabled all my packages and the problem still exists.

@atuttle
Copy link
Collaborator

atuttle commented Oct 21, 2014

Like I said, I see the </cfset> problem too. Verified I'm on the latest development branch of the CF package and the latest stable build of ST3. I'm not on the nightlies/unstable channel.

@jimpriest
Copy link

Weird. I'm on 3065, Windows 7.

If I type

<cfif x EQ 1>

As soon as I close the closing > the CFIF tag autocompletes the cfif so I end up with:

<cfif x EQ 1>
  |
</cfif>

and puts my cursor between them so I can type the cfset.

@atuttle
Copy link
Collaborator

atuttle commented Oct 21, 2014

3065, OSX 10.9.5

@redtopia
Copy link
Author

I'm running ST3 3066. I get that behavior (minus the new line) when I have autocomplete turned on. When I turn it off, I get the autosuggest problem, and as I showed you, it still tries to close when I enter </

@jimpriest
Copy link

My CF settings:

    "auto_close_cfml": true,
    "auto_indent_on_close": true,
    "component_method_completions": true,
    "dictionary": "cf10"

@atuttle
Copy link
Collaborator

atuttle commented Oct 21, 2014

Ok, this is weird. I know I tried exactly what @redtopia outlined above and got the same result. Then I verified my sublime settings matched @jimpriest's (they do), turned on Quicktime and prepared to record a quick screencast, ran through it once quickly to remind myself of the steps, and it worked as @jimpriest described. Very weird.

  1. Created CFIF tagpair using autocomplete on >
  2. Created CFSET tag as described (NOT self-closing)
  3. Attempted to get plugin to add </cfset> by adding a newline after <cfset y = 1> and typing </ but it instead added </cfif> (correct)

Then I realized the difference: It works as expected in CFM files, but NOT as expected in CFC files.

... and then I tried to reproduce the issue on video (again) and it misbehaved in the CFM file too.

I have no idea what's going on.

@redtopia
Copy link
Author

I agree that this is messed up. I have not yet tried @atuttle 's XML plugin yet, but I cannot find any combination of settings that make this plugin work very well. The least offensive setting is to keep auto_close_cfml="true", but this still sucks because it closes everything, even <cfelseif ...>

What it would take to turn off auto_close_cfml?

@atomi
Copy link
Contributor

atomi commented Oct 22, 2014

@atuttle can you post the vids?

@atomi
Copy link
Contributor

atomi commented Oct 22, 2014

@atuttle nevermind.
I know what's going on.

When you type

<cfif blah>

<cfelse>

</--------this gets closed with cfelse when auto_close_cfml is false

So the problem is Sublime Text's own tag closing is set : "auto_close_tags": true,
For the time being if you set auto_close_tags to false in your sublime-settings that will get rid of it.

I'll see if I can re-scope the cfelse tag so that Sublime doesn't consider it an html tag it should close.

@redtopia
Copy link
Author

YES! That's it! Thank you SO MUCH! It would be great to rescope CFML because I want autoclose to work for HTML/XML.

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

No branches or pull requests

4 participants