Skip to content

Conversation

@vinistock
Copy link
Contributor

Being able to override the base level of indentation allows us to format parts of a document that may be nested. This will allow the Ruby LSP to implement range formatting.

For example,

class Foo
  def bar # if we select only the bar method definition for formatting, we need to start from indentation level 2
    puts "Hello"
  end
end

The necessary changes in prettier print are here ruby-syntax-tree/prettier_print#4.

Concerns

Currently, the implementation adds the new base indentation to the last new line of the formatted source. For example,

  def foo
    puts "level 2"
  end
   # <-- Two spaces are added after this new line as well

I'm not sure if this is coming from Syntax Tree or prettier print. This is why we currently have the rstrip in the tests.

Being able to override the base level of indentation allows us to format
parts of a document that may be nested.
@kddnewton
Copy link
Member

@vinistock whenever you get the chance can you rebase this an use prettierprint v1.2.0? Just released.

Copy link
Member

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update prettier_print dependency

@kddnewton kddnewton merged commit 0b53ea1 into ruby-syntax-tree:main Dec 29, 2022
@vinistock vinistock deleted the vs/allow_formatting_with_a_different_base_level branch January 9, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants