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

[js/ts] Indentation inside multi-line template strings #261

Open
rictic opened this issue Aug 7, 2019 · 0 comments
Open

[js/ts] Indentation inside multi-line template strings #261

rictic opened this issue Aug 7, 2019 · 0 comments

Comments

@rictic
Copy link
Contributor

rictic commented Aug 7, 2019

Consider a user trying to write:

function render() {
  return html`
      <div>
          <span>
              Hello world
          </span>
      </div>
  `;
}

user gets to here (where | represents their insertion cursor) and presses enter:

function render() {
  return html`|
}
function render() {
  return html`
      |
}

Good so far. That's pretty reasonable. But by the third line an issue becomes clear:

function render() {
  return html`
      <div>
          <span>|
}
function render() {
  return html`
      <div>
          <span>
      |
}

The best outcome would be to use the inline language's indentation information, so that the outcome was

function render() {
  return html`
      <div>
          <span>
              |
}

A simpler and almost-as-good option would be to just copy the indentation of the previous line of the template literal:

function render() {
  return html`
      <div>
          <span>
         |
}
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

No branches or pull requests

1 participant