Here are the test files for cino=j1,J1 (flags used in javascript.vim)
There's still a few problems with objects and arrays definitions, as you can see below.

JSSTART
var foo = [
1,
    2,
    3
    ];
JSEND


JSSTART
function bar() {
    var foo = [
        1,
        2,
        3
            ];
}
JSEND

JSSTART
function init(options) {
    $(this).data(class_name+'_public',$.extend({},{
        foo: 'bar',
        bar: 2,
        foobar: [
        1,
        2,
        3
        ],
        callback: function(){
            return true;
        }
    }, options||{}));
}
JSEND


JSSTART
(function($){
    function init(options) {
        $(this).data(class_name+'_public',$.extend({},{
            foo: 'bar',
        bar: 2,
        foobar: [
            1,
        2,
        3
            ],
        callback: function(){
            return true;
        }
        }, options||{}));
    }
})(jQuery);
JSEND


Le 10. 06. 11 05:14, Bram Moolenaar a écrit :
Luc Deschenaux wrote:

With the patch below the J1 flag for cinoptions is now working as
mentioned in runtime/docs/indent.txt:

                 var bar = {
                     foo: {
                         that: this,
                         some: ok,
                     },
                     "bar":{
                         a : 2,
                         b: "123abc",
                         x: 4,
                         "y": 5
                     }
                 }


--- misc1.c.orig    2011-06-09 14:32:21.000000000 +0200
+++ misc1.c    2011-06-09 14:42:35.000000000 +0200
@@ -6965,7 +6965,9 @@
           *            ldfd) {
           *            }
           */
-        if ((ind_keep_case_label
+        if (ind_js) {
+        amount = get_indent();
+        } else if ((ind_keep_case_label
              &&   cin_iscase(skipwhite(ml_get_curline()), FALSE)))
          amount = get_indent();
          else
That appears to work.  Bonus if you can make a test to verify this!
Hmm, there don't seem to be any tests for "J1" in 'cino'.  These would
go in testdir/test3.in.


--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r c6f8f1957c66 src/testdir/test3.in
--- a/src/testdir/test3.in	Mon Jun 13 21:21:22 2011 +0200
+++ b/src/testdir/test3.in	Tue Jun 14 02:58:52 2011 +0200
@@ -1562,7 +1562,7 @@
 
 
 STARTTEST
-:set cino=J1
+:set cino=j1,J1
 /^JSSTART
 =/^JSEND
 ENDTEST
@@ -1583,6 +1583,145 @@
 JSEND
 
 STARTTEST
+:set cino=j1,J1
+/^JSSTART
+=/^JSEND
+ENDTEST
+
+JSSTART
+var foo = [
+1,
+2,
+3
+];
+JSEND
+
+STARTTEST
+:set cino=j1,J1
+/^JSSTART
+=/^JSEND
+ENDTEST
+
+JSSTART
+function bar() {
+var foo = [
+1,
+2,
+3
+];
+}
+JSEND
+
+STARTTEST
+:set cino=j1,J1
+/^JSSTART
+=/^JSEND
+ENDTEST
+
+JSSTART
+(function($){
+
+var class_name='myclass';
+
+function private_method() {
+}
+
+var public_method={
+method: function(options,args){
+private_method();
+}
+}
+
+function init(options) {
+
+$(this).data(class_name+'_public',$.extend({},{
+foo: 'bar',
+bar: 2,
+foobar: [
+1,
+2,
+3
+],
+callback: function(){
+return true;
+}
+}, options||{}));
+}
+
+$.fn[class_name]=function() {
+
+var _arguments=arguments;
+return this.each(function(){
+
+var options=$(this).data(class_name+'_public');
+if (!options) {
+init.apply(this,_arguments);
+
+} else {
+var method=public_method[_arguments[0]];
+
+if (typeof(method)!='function') {
+console.log(class_name+' has no method "'+_arguments[0]+'"');
+return false;
+}
+_arguments[0]=options;
+method.apply(this,_arguments);
+}
+});
+}
+
+})(jQuery);
+JSEND
+
+STARTTEST
+:set cino=j1,J1
+/^JSSTART
+=/^JSEND
+ENDTEST
+
+JSSTART
+function init(options) {
+$(this).data(class_name+'_public',$.extend({},{
+foo: 'bar',
+bar: 2,
+foobar: [
+1,
+2,
+3
+],
+callback: function(){
+return true;
+}
+}, options||{}));
+}
+JSEND
+
+STARTTEST
+:set cino=j1,J1
+/^JSSTART
+=/^JSEND
+ENDTEST
+
+JSSTART
+(function($){
+function init(options) {
+$(this).data(class_name+'_public',$.extend({},{
+foo: 'bar',
+bar: 2,
+foobar: [
+1,
+2,
+3
+],
+callback: function(){
+return true;
+}
+}, options||{}));
+}
+})(jQuery);
+JSEND
+
+STARTTEST
 :g/^STARTTEST/.,/^ENDTEST/d
 :1;/start of AUTO/,$wq! test.out
 ENDTEST
diff -r c6f8f1957c66 src/testdir/test3.ok
--- a/src/testdir/test3.ok	Mon Jun 13 21:21:22 2011 +0200
+++ b/src/testdir/test3.ok	Tue Jun 14 02:58:55 2011 +0200
@@ -1418,3 +1418,117 @@
 }
 JSEND
 
+
+JSSTART
+var foo = [
+	1,
+	2,
+	3
+];
+JSEND
+
+
+JSSTART
+function bar() {
+	var foo = [
+		1,
+		2,
+		3
+	];
+}
+JSEND
+
+
+JSSTART
+(function($){
+
+	var class_name='myclass';
+
+	function private_method() {
+	}
+
+	var public_method={
+		method: function(options,args){
+			private_method();
+		}
+	}
+
+	function init(options) {
+
+		$(this).data(class_name+'_public',$.extend({},{
+			foo: 'bar',
+			bar: 2,
+			foobar: [
+				1,
+				2,
+				3
+			],
+			callback: function(){
+				return true;
+			}  
+		}, options||{}));
+	}
+
+	$.fn[class_name]=function() {
+
+		var _arguments=arguments;
+		return this.each(function(){
+
+			var options=$(this).data(class_name+'_public');
+			if (!options) {
+				init.apply(this,_arguments);
+
+			} else {
+				var method=public_method[_arguments[0]];
+
+				if (typeof(method)!='function') {
+					console.log(class_name+' has no method "'+_arguments[0]+'"');
+					return false;
+				}
+				_arguments[0]=options;
+				method.apply(this,_arguments);
+			}
+		});
+	}
+
+})(jQuery);
+JSEND
+
+
+JSSTART
+function init(options) {
+	$(this).data(class_name+'_public',$.extend({},{
+		foo: 'bar',
+		bar: 2,
+		foobar: [
+			1,
+			2,
+			3
+		],
+		callback: function(){
+			return true;
+		}
+	}, options||{}));
+}
+JSEND
+
+
+JSSTART
+(function($){
+	function init(options) {
+		$(this).data(class_name+'_public',$.extend({},{
+			foo: 'bar',
+			bar: 2,
+			foobar: [
+				1,
+				2,
+				3
+			],
+			callback: function(){
+				return true;
+			}
+		}, options||{}));
+	}
+})(jQuery);
+JSEND
+

Raspunde prin e-mail lui