Microsoft/vscode

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

Open

#137.632 aperta il 22 nov 2021

Vedi su GitHub
 (2 commenti) (0 reazioni) (1 assegnatario)TypeScript (10.221 fork)batch import
bughelp wantedmarkdown-ext

Metriche repository

Star
 (74.848 star)
Metriche merge PR
 (Merge medio 11h 43m) (1000 PR mergiate in 30 g)

Descrizione

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);
}

Guida contributor