<p dir="auto"><em>From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/alexanderby/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/alexanderby">@alexanderby</a> on November 19, 2015 9:35</em></p>
<p dir="auto">When formatting JavaScript or TypeScript, comments placed between parts of multi-line expressions are placed wrong.<br>
Expected to look like</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="doStuff()
    .then()
    // Comment
    .then();"><pre class="notranslate"><span class="pl-en">doStuff</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-c">// Comment</span>
    <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">but actually is</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="doStuff()
    .then()
// Comment
    .then();"><pre class="notranslate"><span class="pl-en">doStuff</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
<span class="pl-c">// Comment</span>
    <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><em>Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="117775495" data-permission-text="Title is private" data-url="https://github.com/microsoft/vscode/issues/184" data-hovercard-type="issue" data-hovercard-url="/microsoft/vscode/issues/184/hovercard" href="https://github.com/microsoft/vscode/issues/184">microsoft/vscode#184</a></em></p>
<p dir="auto">To reproduce:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare var _: any;

function chainer() {
    _.chain()
         // something here
        .then()
         // something here 
        .then()
         // something here
        .then();
}"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">_</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">chainer</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">_</span><span class="pl-kos">.</span><span class="pl-en">chain</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
         <span class="pl-c">// something here</span>
        <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
         <span class="pl-c">// something here </span>
        <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
         <span class="pl-c">// something here</span>
        <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Format the code. You get</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
declare var _: any;

function chainer() {
    _.chain()
    // something here
        .then()
    // something here 
        .then()
    // something here
        .then();
}"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">_</span>: <span class="pl-smi">any</span><span class="pl-kos">;</span>

<span class="pl-k">function</span> <span class="pl-en">chainer</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">_</span><span class="pl-kos">.</span><span class="pl-en">chain</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-c">// something here</span>
        <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-c">// something here </span>
        <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-c">// something here</span>
        <span class="pl-kos">.</span><span class="pl-en">then</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Observe the unindented comments.</p>