Make paste resource respect paste location (#207635)

Fixes #207186
This commit is contained in:
Matt Bierner
2024-03-13 14:27:44 -07:00
committed by GitHub
parent 7c6e82d367
commit e5f5e91423
9 changed files with 435 additions and 331 deletions

View File

@@ -3,12 +3,33 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { coalesce } from './arrays';
import * as vscode from 'vscode';
function splitUriList(str: string): string[] {
return str.split('\r\n');
}
export function parseUriList(str: string): string[] {
function parseUriList(str: string): string[] {
return splitUriList(str)
.filter(value => !value.startsWith('#')) // Remove comments
.map(value => value.trim());
}
export class UriList {
static from(str: string): UriList {
return new UriList(coalesce(parseUriList(str).map(line => {
try {
return { uri: vscode.Uri.parse(line), str: line };
} catch {
// Uri parse failure
return undefined;
}
})));
}
private constructor(
public readonly entries: ReadonlyArray<{ readonly uri: vscode.Uri; readonly str: string }>
) { }
}