<p dir="auto">Hi,</p>
<p dir="auto">I investigated an enjoying bug in terms of the auto formatting in atom. This happens if you call "Auto Ident" or if code becomes pasted into the editor.</p>
<p dir="auto">In many languages, e.g. Java, Javascript, PHP, ... the following should be formatted as this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="if(somevariable === 3)
   alert(somevariable);
somevariable++;"><pre class="notranslate"><span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">somevariable</span> <span class="pl-c1">===</span> <span class="pl-c1">3</span><span class="pl-kos">)</span>
   <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">somevariable</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">somevariable</span><span class="pl-c1">++</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">This is the similar behavior as:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="if(somevariable === 3) {
   alert(somevariable);
}
somevariable++;"><pre class="notranslate"><span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">somevariable</span> <span class="pl-c1">===</span> <span class="pl-c1">3</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
   <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">somevariable</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>
<span class="pl-s1">somevariable</span><span class="pl-c1">++</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Atom unfortunately format all lines behind the statements the following way:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="if(somevariable === 3) 
   alert(somevariable);
   somevariable++;"><pre class="notranslate"><span class="pl-k">if</span><span class="pl-kos">(</span><span class="pl-s1">somevariable</span> <span class="pl-c1">===</span> <span class="pl-c1">3</span><span class="pl-kos">)</span> 
   <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">somevariable</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
   <span class="pl-s1">somevariable</span><span class="pl-c1">++</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Hope this can be fixed soon 👍</p>
<p dir="auto">This issue can include <a href="https://github.com/atom/language-javascript/issues/49" data-hovercard-type="issue" data-hovercard-url="/atom/language-javascript/issues/49/hovercard">this earlier one</a>.</p>
<p dir="auto">It seems that a lack of braces break the auto indentation. For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (true)
  i = 1;
else
  i = 2;"><pre class="notranslate"><code class="notranslate">if (true)
  i = 1;
else
  i = 2;
</code></pre></div>
<p dir="auto">Turns into:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (true)
  i = 1;
  else
    i = 2;"><pre class="notranslate"><code class="notranslate">if (true)
  i = 1;
  else
    i = 2;
</code></pre></div>