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

Brace pairing behaviours don't always take affect #1393

Closed
mnpenner opened this issue Apr 24, 2013 · 9 comments
Closed

Brace pairing behaviours don't always take affect #1393

mnpenner opened this issue Apr 24, 2013 · 9 comments

Comments

@mnpenner
Copy link

Here are my settings:

var editor = ace.edit('editor');
var session = editor.getSession();
editor.setTheme('ace/theme/ambiance');
session.setMode('ace/mode/css');
session.setUseWrapMode(true);
editor.setShowPrintMargin(false);
editor.setBehavioursEnabled(true); // auto-pairing of special characters, like quotation marks, parenthesis, or brackets
editor.commands.addCommand({
    name: 'Start New Line',
    bindKey: {
        win: 'Shift+Enter',
        mac: 'Shift+Enter'
    },
    readOnly: false,
    exec: function(editor) {
        editor.navigateLineEnd();
        editor.insert('\n');
    }
});

In an empty editor, when I type td { it does not add a closing }. If I add it manually, and then type td { for a second time it works as expected (adding the closing }).

It seems behaviours don't work for the first style tag in a CSS document, but after that it does.

Using src-min-noconflict from rev 1d8a5a3b39dde30c3f652c8c9f3f26a9b4016e70.

@nightwing
Copy link
Member

looks like this is caused by eclipse style "smart" autopairing added for js, it should be disabled for css

@mnpenner
Copy link
Author

Are you saying editor.setBehavioursEnabled(true) doesn't work correctly for anything other than JS? Because it's quite handy, even as-is.

@kasperpeulen
Copy link

I would like to have editor.setBehavioursEnabled(true) also work latex mode.

@ghost
Copy link

ghost commented Jan 28, 2015

I'm noticing this issue in Golang as well. Although, the Behavior code appears to be in the JS file:
https://github.com/ajaxorg/ace-builds/blob/master/src/mode-golang.js#L200:L554

And console.log(editor.getBehavioursEnabled()); is outputting true

I still don't get the auto-pairing functionality in the editor. Everything else seems to work fine though.

I noticed the same behavior in the Kitchen Sink demo: http://ace.c9.io/kitchen-sink.html

Here are a few of the languages I tested:

  • Works: JavaScript, Ruby, CSS, JSON, PHP
  • Doesn't Work: Go, R, MySQL

@nightwing
Copy link
Member

Looks like go mode includes CstyleBehaviour but doesn't use it.
Actually are there languages that do not need pairing brackets? it might be better to move this into general behavior, and let modes disable pairing for bracket types they don't want.

@ghost
Copy link

ghost commented Jan 28, 2015

I can't think of any languages that wouldn't benefit from it besides maybe HTML.

In the meantime, is there an easy way to include auto-pairing in other languages like Golang?

@mnpenner mnpenner changed the title Behaviours don't always take affect Brace pairing behaviours don't always take affect Jan 28, 2015
@kayex
Copy link

kayex commented Sep 18, 2015

Is there any way to force the golang mode to use cstyleBehaviour? As previously mentioned, it seems that it is already included but not used.

@thorst
Copy link

thorst commented Feb 2, 2016

I was able to add this to tcl by looking at the javascript mode and looking at the tcl mode. You need to:

  • http://jsbeautifier.org/ the minified cod
  • copy ace.define("ace/mode/behaviour/cstyle" section from javascript into your mode
  • at the bottom ace.define("ace/mode/tcl" section

modify:

  • tt = e("./behaviour/cstyle").CstyleBehaviour,
  • and then in the function this.$behaviour = new tt;

@nightwing
Copy link
Member

this have been fixed some time ago #2936

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

5 participants