ColdFusion icon indicating copy to clipboard operation
ColdFusion copied to clipboard

Auto-close problems

Open redtopia opened this issue 11 years ago • 29 comments

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 avatar Oct 01 '14 22:10 redtopia

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 avatar Oct 03 '14 02:10 redtopia

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?

redtopia avatar Oct 09 '14 02:10 redtopia

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

atomi avatar Oct 09 '14 16:10 atomi

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

redtopia avatar Oct 09 '14 16:10 redtopia

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!

redtopia avatar Oct 17 '14 23:10 redtopia

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.

atomi avatar Oct 19 '14 15:10 atomi

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 avatar Oct 20 '14 02:10 redtopia

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.

redtopia avatar Oct 21 '14 19:10 redtopia

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 avatar Oct 21 '14 19:10 jimpriest

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.

jimpriest avatar Oct 21 '14 19:10 jimpriest

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.

redtopia avatar Oct 21 '14 19:10 redtopia

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?

jimpriest avatar Oct 21 '14 19:10 jimpriest

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

redtopia avatar Oct 21 '14 19:10 redtopia

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?

redtopia avatar Oct 21 '14 19:10 redtopia

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 avatar Oct 21 '14 20:10 atuttle

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+<.

atuttle avatar Oct 21 '14 20:10 atuttle

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?

redtopia avatar Oct 21 '14 20:10 redtopia

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

atuttle avatar Oct 21 '14 20:10 atuttle

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

redtopia avatar Oct 21 '14 20:10 redtopia

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.

atuttle avatar Oct 21 '14 20:10 atuttle

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.

jimpriest avatar Oct 21 '14 20:10 jimpriest

3065, OSX 10.9.5

atuttle avatar Oct 21 '14 20:10 atuttle

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 </

redtopia avatar Oct 21 '14 21:10 redtopia

My CF settings:

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

jimpriest avatar Oct 21 '14 21:10 jimpriest

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.

atuttle avatar Oct 21 '14 23:10 atuttle

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?

redtopia avatar Oct 22 '14 01:10 redtopia

@atuttle can you post the vids?

atomi avatar Oct 22 '14 03:10 atomi

@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.

atomi avatar Oct 22 '14 04:10 atomi

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

redtopia avatar Oct 22 '14 04:10 redtopia