Fix range when copying empty selection (#182227)

This fixes the range extensions get when copying an empty selection. As part of this, I've also:

- Added tests for this change
- Made the paste parts of the api optional. This is useful when a test provider only wants to add data on copy
This commit is contained in:
Matt Bierner
2023-05-11 17:31:11 -07:00
committed by GitHub
parent 068cbf3133
commit 9b6b547d2d
9 changed files with 241 additions and 30 deletions

View File

@@ -62,6 +62,17 @@ export function disposeAll(disposables: vscode.Disposable[]) {
vscode.Disposable.from(...disposables).dispose();
}
export function usingDisposables<R>(fn: (this: Mocha.Context, store: vscode.Disposable[]) => Promise<R>) {
return async function (this: Mocha.Context): Promise<R> {
const disposables: vscode.Disposable[] = [];
try {
return await fn.call(this, disposables);
} finally {
disposeAll(disposables);
}
};
}
export function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}