SublimeText / ColdFusion

ColdFusion Sublime Text Package
MIT License
197 stars 64 forks source link

Auto-close problems #149

Open redtopia opened 10 years ago

redtopia commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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

redtopia commented 10 years ago

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

redtopia commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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

redtopia commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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:

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 commented 10 years ago

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 commented 10 years ago

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

redtopia commented 10 years ago

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

atuttle commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

3065, OSX 10.9.5

redtopia commented 10 years ago

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 commented 10 years ago

My CF settings:

    "auto_close_cfml": true,
    "auto_indent_on_close": true,
    "component_method_completions": true,
    "dictionary": "cf10"
atuttle commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

@atuttle can you post the vids?

atomi commented 10 years ago

@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 commented 10 years ago

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