mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
Show better error when rename fails in md (#161525)
* Show better error when rename fails in md * Pick up latest MDLanguage service
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancellationToken, Connection, InitializeParams, InitializeResult, NotebookDocuments, TextDocuments } from 'vscode-languageserver';
|
||||
import { CancellationToken, Connection, InitializeParams, InitializeResult, NotebookDocuments, ResponseError, TextDocuments } from 'vscode-languageserver';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import * as lsp from 'vscode-languageserver-types';
|
||||
import * as md from 'vscode-markdown-languageservice';
|
||||
@@ -170,7 +170,16 @@ export async function startServer(connection: Connection, serverConfig: {
|
||||
if (!document) {
|
||||
return undefined;
|
||||
}
|
||||
return mdLs!.prepareRename(document, params.position, token);
|
||||
|
||||
try {
|
||||
return await mdLs!.prepareRename(document, params.position, token);
|
||||
} catch (e) {
|
||||
if (e instanceof md.RenameNotSupportedAtLocationError) {
|
||||
throw new ResponseError(0, e.message);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
connection.onRenameRequest(async (params, token) => {
|
||||
|
||||
Reference in New Issue
Block a user