Microsoft/vscode

With `md.supportHtml = true` and VS Code Remote SSH, a single img tag on compleition items cannot be loaded

Open

#137,632 建立於 2021年11月22日

在 GitHub 查看
 (2 留言) (0 反應) (1 負責人)TypeScript (10,221 fork)batch import
bughelp wantedmarkdown-ext

倉庫指標

Star
 (74,848 star)
PR 合併指標
 (平均合併 11小時 43分鐘) (30 天內合併 1,000 個 PR)

描述

Version: 1.63.0-insider (Universal) Commit: bedf867b5b02c1c800fbaf4d6ce09cefbafa1592 Date: 2021-11-18T05:17:00.890Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin arm64 20.6.0

Related to #136027

With md.supportHtml = true and VS Code Remote SSH, a single img tag on compleition items cannot be loaded. If we write the img tag and markdown images in the same item, the img tag can be loaded.

Steps to Reproduce:

  1. Open a remote workspace with VS Code Remote SSH
  2. Execute https://github.com/tamuratak/vscode-extension-samples/tree/supporthtml_img_local_2/completions-sample
  3. Execute Trigger Suggest
  4. The image cannot be loaded.

スクリーンショット 2021-11-22 13 20 32

If I replace the markdown with 1 <img src="${pngPathUriString}"> 2 ![img](${pngPathUriString}), then the images can be loaded.

スクリーンショット 2021-11-22 13 21 31




import * as vscode from 'vscode';
import * as path from 'path';


export function activate(context: vscode.ExtensionContext) {

	const provider1 = vscode.languages.registerCompletionItemProvider('plaintext', {

		provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {

			const pngPath = path.join(__dirname, '..', 'a.png')
			const pngPathUriString = vscode.Uri.file(pngPath).toString()

			const snippetCompletion = new vscode.CompletionItem('Good part of the day');
			snippetCompletion.insertText = new vscode.SnippetString('Good ${1|morning,afternoon,evening|}. It is ${1}, right?');
			const md = new vscode.MarkdownString(`1 <img src="${pngPathUriString}">`);
			md.supportHtml = true
			snippetCompletion.documentation = md

			// return all completion items as array
			return [
				snippetCompletion
			];
		}
	});
	context.subscriptions.push(provider1);
}

貢獻者指南