<h4 dir="auto">Expected Behaviour</h4>
<p dir="auto">deno lsp should support and format files with emojis inside.</p>
<h4 dir="auto">Actual Behaviour</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Starting Deno language server...
  version: 1.6.3 (release, x86_64-unknown-linux-gnu)
Connected to &quot;vscode&quot; 1.52.1
language server initialized
Server ready.
thread 'main' panicked at 'assertion failed: self.is_char_boundary(n)', /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/string.rs:1555:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Error - 10:46:37 PM] Connection to server got closed. Server will not be restarted.
[Error - 10:46:37 PM] Request textDocument/formatting failed.
Error: Connection got disposed.
	at Object.dispose (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageReader.fireClose (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.&lt;anonymous&gt; (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:228:7)
	at Pipe.&lt;anonymous&gt; (net.js:664:12)"><pre class="notranslate"><code class="notranslate">Starting Deno language server...
  version: 1.6.3 (release, x86_64-unknown-linux-gnu)
Connected to "vscode" 1.52.1
language server initialized
Server ready.
thread 'main' panicked at 'assertion failed: self.is_char_boundary(n)', /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/string.rs:1555:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Error - 10:46:37 PM] Connection to server got closed. Server will not be restarted.
[Error - 10:46:37 PM] Request textDocument/formatting failed.
Error: Connection got disposed.
	at Object.dispose (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/main.js:904:25)
	at Object.dispose (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/client.js:74:35)
	at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/client.js:2309:42)
	at LanguageClient.handleConnectionClosed (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/main.js:155:15)
	at closeHandler (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-languageclient/lib/client.js:2296:18)
	at CallbackList.invoke (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at closeHandler (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/main.js:240:26)
	at CallbackList.invoke (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
	at Emitter.fire (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/events.js:121:36)
	at StreamMessageReader.fireClose (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
	at Socket.&lt;anonymous&gt; (/root/.vscode-server/extensions/denoland.vscode-deno-canary-0.0.6/client/node_modules/vscode-jsonrpc/lib/messageReader.js:151:46)
	at Socket.emit (events.js:228:7)
	at Pipe.&lt;anonymous&gt; (net.js:664:12)
</code></pre></div>
<h4 dir="auto">Steps to Reproduce</h4>
<ol dir="auto">
<li>Create a file with <code class="notranslate">globalThis.console.log(</code><g-emoji class="g-emoji" alias="hankey" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4a9.png">💩</g-emoji><code class="notranslate">)</code></li>
<li>Try to format it with vscode-deno-canary</li>
</ol>
<h4 dir="auto">Using</h4>
<ul dir="auto">
<li>deno 1.6.3 (release, x86_64-unknown-linux-gnu)</li>
<li>v8 8.8.294</li>
<li>typescript 4.1.3</li>
<li>vscode 1.52.1</li>
<li>denoland.vscode-deno-canary</li>
</ul>
<p dir="auto">Editing, or creating a document with the following text causes all sorts of issues and lsp server crashes:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const foo = `编写软件很难`;

console.log(foo);"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">foo</span> <span class="pl-c1">=</span> <span class="pl-s">`编写软件很难`</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-s1">foo</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">For example, changing <code class="notranslate">.log</code> to <code class="notranslate">.warn</code> will result in bad diagnostics like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Unterminated template literal."><pre class="notranslate"><code class="notranslate">Unterminated template literal.
</code></pre></div>
<p dir="auto">This is because characters are not being counted the same between what is being sent by the lsp and how the lsp internally calculates them, causing the internal file to be updated in the wrong location.</p>