<ul dir="auto">
<li>VSCode Version: 1.1.0</li>
<li>OS Version: OS X 10.11.4</li>
</ul>
<p dir="auto">Steps to Reproduce:</p>
<ol dir="auto">
<li>Create a new text file <code class="notranslate">test.js</code></li>
<li>Set the content to the following:</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let x = true ? '' : `${1}`
console.log('still part of the template!')"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span> ? <span class="pl-s">''</span> : <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-c1">1</span><span class="pl-kos">}</span></span>`</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'still part of the template!'</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">VS Code fails to parse the opening <code class="notranslate">of the template string at the end of the ternary operator correctly. It therefore sees the final</code> as an opening tick, and interprets the rest of the file as a template string:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1312873/15242549/aedfa33e-18ee-11e6-9c3b-6ddf3a019bfb.png"><img width="356" alt="screenshot 2016-05-13 09 39 32" src="https://cloud.githubusercontent.com/assets/1312873/15242549/aedfa33e-18ee-11e6-9c3b-6ddf3a019bfb.png" style="max-width: 100%;"></a></p>
<p dir="auto">As a workaround you can wrap the failure case in parenthesis:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let x = true ? '' : (`${1}`)
console.log('still part of the template!')"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span> ? <span class="pl-s">''</span> : <span class="pl-kos">(</span><span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-c1">1</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">)</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'still part of the template!'</span><span class="pl-kos">)</span></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1312873/15242603/0bf29504-18ef-11e6-822b-fb97977930d0.png"><img width="365" alt="screenshot 2016-05-13 09 42 34" src="https://cloud.githubusercontent.com/assets/1312873/15242603/0bf29504-18ef-11e6-822b-fb97977930d0.png" style="max-width: 100%;"></a></p>
<p dir="auto"><em>From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/garthk/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/garthk">@garthk</a> on April 8, 2016 4:30</em></p>
<ul dir="auto">
<li>VSCode Version: <code class="notranslate">Version 0.10.10 (0.10.10)</code> or <code class="notranslate">Version 0.10.14-insider (0.10.14-insider) 17fa1cbb49e3c5edd5868f304a64115fcc7c9c2c</code></li>
<li>OS Version: OS X <code class="notranslate">10.11.4 (15E65)</code></li>
<li><code class="notranslate">javascript.validate.enable</code> set either <code class="notranslate">true</code> or <code class="notranslate">false</code></li>
</ul>
<p dir="auto">Steps to Reproduce:</p>
<ol dir="auto">
<li>Open a new Code – Insiders window</li>
<li>Paste in the following JavaScript</li>
<li>Observe</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function test1(x) {
    const defaultValue = `${x}`;
    const value = x ? x : y;
    console.log('so far, so good');
}

function test2(x) {
    const value = !x ? `${x}` : x;
    console.log('so far, so good');
}

function test3(x) {
    const value = x ? x : `${x}`; // this comment is coloured as if it's part of the template literal
    console.log('this entire line, too');
} // and this one"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">test1</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">defaultValue</span> <span class="pl-c1">=</span> <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">x</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span> ? <span class="pl-s1">x</span> : <span class="pl-s1">y</span><span class="pl-kos">;</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'so far, so good'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">test2</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-c1">!</span><span class="pl-s1">x</span> ? <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">x</span><span class="pl-kos">}</span></span>`</span> : <span class="pl-s1">x</span><span class="pl-kos">;</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'so far, so good'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">test3</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span> ? <span class="pl-s1">x</span> : <span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">x</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">;</span> <span class="pl-c">// this comment is coloured as if it's part of the template literal</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'this entire line, too'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span> <span class="pl-c">// and this one</span></pre></div>
<p dir="auto">If I'm getting this right:</p>
<ul dir="auto">
<li><code class="notranslate">test1</code> shows <code class="notranslate">code</code> knows when a template literal ends, usually</li>
<li><code class="notranslate">test2</code> shows <code class="notranslate">code</code> still knows when a template literal ends if it's the first <em>AssignmentExpression</em> in a ternary</li>
<li><code class="notranslate">test3</code> shows <code class="notranslate">code</code> somehow misses the end of a template literal as the second <em>AssignmentExpression</em> in a ternary, highlighting from then on as a string</li>
</ul>
<p dir="auto"><em>Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="146810193" data-permission-text="Title is private" data-url="https://github.com/microsoft/vscode/issues/5090" data-hovercard-type="issue" data-hovercard-url="/microsoft/vscode/issues/5090/hovercard" href="https://github.com/microsoft/vscode/issues/5090">microsoft/vscode#5090</a></em></p>