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

SourceFile.formatText() should respect indentation settings #149

Closed
Maximaximum opened this issue Dec 3, 2017 · 3 comments
Closed

SourceFile.formatText() should respect indentation settings #149

Maximaximum opened this issue Dec 3, 2017 · 3 comments
Labels

Comments

@Maximaximum
Copy link

When I run the following code, the indentationText manipulation setting gets actually ignored inside the file.formatText(); call. The indentation gets produced as 4 space characters, no matter what is passed to the Ast constructor.

  const ast = new Ast({
    manipulationSettings: {
      indentationText: IndentationText.Tab
    }
  });
  ast.addSourceFiles(filesGlob);

  const files = ast.getSourceFiles();

  for (const file of files) {
    const namespaces = file.getNamespaces();
    for (const namespace of namespaces) {
      namespace.unwrap();
    }
  }

  for (const file of files) {
    file.formatText();
  }
  ast.saveUnsavedSourceFilesSync();
@dsherret dsherret added the bug label Dec 3, 2017
@dsherret
Copy link
Owner

dsherret commented Dec 3, 2017

Thanks for reporting this. I'm surprised the underlying typescript compiler printer will always change it to 4 spaces and doesn't have a way to customize that. When formatting, I'll just have to add an extra pass through the file in order to change the 4 spaces to the current manipulation settings.

@dsherret
Copy link
Owner

dsherret commented Dec 4, 2017

This is fixed in 1.2.0. It will also use the newline kind specified in the manipulation settings.

Let me know if you notice any issues.

@Maximaximum
Copy link
Author

Thanks a lot! This is fixed now indeed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants