GithubHelp home page GithubHelp logo

Comments (6)

cgrushko avatar cgrushko commented on May 7, 2024 1

heh :) well, the first and third are "expected", right? the first one is a continuation indent, whereas the third one is a block indent.

The second is clearly a bug. Should be, at the minimum, a continuation indent.

What do you think?

from ktfmt.

sgrimm avatar sgrimm commented on May 7, 2024 1

Yeah, that's better now. I would personally prefer block indent for single-statement when branches so the indentation doesn't change if you add braces and is consistent when you have a mix of block and single-statement branches, but I am completely on board with the idea that ktfmt should be opinionated even if I don't agree with 100% of its opinions. I agree that only the second case was clearly a bug. Thanks!

from ktfmt.

sgrimm avatar sgrimm commented on May 7, 2024 1

Yeah, that's fair; the lack of distinction between continuation and block indent makes their intent ambiguous. My preference is for block indent but like I said, I totally acknowledge I'm bikeshedding at the moment and am happy with the fix for the second case.

from ktfmt.

cgrushko avatar cgrushko commented on May 7, 2024

I'm going to close the issue since the 2nd case is now fixed. The others are problematic to change without introducing inconsistencies into the formatter. Let me know what you think.

from ktfmt.

sgrimm avatar sgrimm commented on May 7, 2024

I guess a stronger argument is that the Kotlin style guide uses block indent for the single-statement when branch case. https://kotlinlang.org/docs/reference/coding-conventions.html#formatting-control-flow-statements

from ktfmt.

cgrushko avatar cgrushko commented on May 7, 2024

The Kotlin style guide uses indentation of continuation == block == 4, whereas ktfmt uses 4 and 2 respectively; so, the Kotlin style guide gets away with it because there's no difference. (unless I was looking at the wrong place?)

from ktfmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.