Move smart select and folding to md language server (#154334)

* Move smart select and folding to md language server

Also fixes a few minor issues:

- Don't log to web console
- Remove convert code since it is no longer needed
- Use correct extension id

* bump cache

* Bump package version

Co-authored-by: João Moreno <joao.moreno@microsoft.com>
This commit is contained in:
Matt Bierner
2022-07-07 07:30:03 -07:00
committed by GitHub
parent f9711dfc35
commit 2fb56e9d62
10 changed files with 55 additions and 1401 deletions

View File

@@ -5,14 +5,7 @@
import { ILogger } from 'vscode-markdown-languageservice';
class ConsoleLogger implements ILogger {
public verbose(title: string, message: string, data?: any): void {
this.appendLine(`[Verbose ${ConsoleLogger.now()}] ${title}: ${message}`);
if (data) {
this.appendLine(ConsoleLogger.data2String(data));
}
}
export class LogFunctionLogger implements ILogger {
private static now(): string {
const now = new Date();
@@ -21,10 +14,6 @@ class ConsoleLogger implements ILogger {
+ ':' + String(now.getUTCSeconds()).padStart(2, '0') + '.' + String(now.getMilliseconds()).padStart(3, '0');
}
private appendLine(value: string): void {
console.log(value);
}
private static data2String(data: any): string {
if (data instanceof Error) {
if (typeof data.stack === 'string') {
@@ -37,6 +26,21 @@ class ConsoleLogger implements ILogger {
}
return JSON.stringify(data, undefined, 2);
}
constructor(
private readonly _logFn: typeof console.log
) { }
public verbose(title: string, message: string, data?: any): void {
this.appendLine(`[Verbose ${LogFunctionLogger.now()}] ${title}: ${message}`);
if (data) {
this.appendLine(LogFunctionLogger.data2String(data));
}
}
private appendLine(value: string): void {
this._logFn(value);
}
}
export const consoleLogger = new ConsoleLogger();
export const consoleLogger = new LogFunctionLogger(console.log);