ligasgr / intellij-xquery

Plugin to support XQuery in Intellij Idea
Apache License 2.0
35 stars 23 forks source link

Formatter "messing up" indention on cut/paste, on newline? #42

Closed malteseduck closed 11 years ago

malteseduck commented 11 years ago

I don't know if this is a bug or not, but it seems that many times when I cut and paste XQuery code to various places the format of the XQuery is lost. Here is a simple example:

xquery version "3.0";

let $test as xs:string := "test"
return (
    fn:concat(
        "this ",
        "is ",
        "a ",
        $test
    )
)

If I type a comma after the closing ")" for the fn:concat() function and hit the return key then the cursor moves to beginning of the line on the new line instead of being indented to match the current indentation.

When I cut and paste this over itself (or anywhere else) then the "fn:concat(" and the closing ")" for that function lose their indentation. I had a whole block of XQuery I pasted somewhere and had to re-indent it all (not your fault, that is what I get for using the working version).

There are some cases where I move the the cursor to the new line and it adds another indentation level when you wouldn't think it should. I will try to reproduce it and create another issue if I can.

malteseduck commented 11 years ago

Here is the case. Trying to type this:

"test"
,
"case"
,
"for"
,
"you"

Actually results in this:

"test"
,
        "case"
,
        "for"
,
        "you"
ligasgr commented 11 years ago

Hi,

Thanks for raising this issue. I'm still trying to find out a good resource on xquery code style (I'll probably try to make formatter rules to resemble http://xqdoc.org/xquery-style.pdf in the future). I tried to follow the typical formatting behaviour of IntelliJ for java code to have "the feeling" similar but in case of xquery specific constructs I'll have to fix that.

Have you got any suggestions around formatting style or a good resources?

Thanks

ligasgr commented 11 years ago

Please re-open if similar problem happens for similar expressions. In case of any other formatter issues (there might be plenty), please raise separate issues. Thanks for using the plugin and for the feedback :) It's invaluable!

malteseduck commented 11 years ago

I have usually used that document you mention for code style. Here is one by Micah Dubinko: http://developer.marklogic.com/blog/xquery-coding-guidelines. Those two are the main ones I have seen.