浏览代码

Fixes microsoft/monaco-editor#2162

Alexandru Dima 4 年之前
父节点
当前提交
1be8b30e74
共有 2 个文件被更改,包括 21 次插入9 次删除
  1. 8 2
      monaco.d.ts
  2. 13 7
      src/languageFeatures.ts

+ 8 - 2
monaco.d.ts

@@ -19,7 +19,9 @@ declare namespace monaco.languages.typescript {
 		None = 0,
 		Preserve = 1,
 		React = 2,
-		ReactNative = 3
+		ReactNative = 3,
+		ReactJSX = 4,
+		ReactJSXDev = 5
 	}
 	export enum NewLineKind {
 		CarriageReturnLineFeed = 0,
@@ -303,7 +305,11 @@ declare namespace monaco.languages.typescript {
 		 * Get signature help items for the item at the given file and position.
 		 * @returns `Promise<typescript.SignatureHelpItems | undefined>`
 		 */
-		getSignatureHelpItems(fileName: string, position: number): Promise<any | undefined>;
+		getSignatureHelpItems(
+			fileName: string,
+			position: number,
+			options: any
+		): Promise<any | undefined>;
 		/**
 		 * Get quick info for the item at the given position in the file.
 		 * @returns `Promise<typescript.QuickInfo | undefined>`

+ 13 - 7
src/languageFeatures.ts

@@ -1094,13 +1094,19 @@ export class RenameAdapter extends Adapter implements languages.RenameProvider {
 
 		const edits: languages.WorkspaceTextEdit[] = [];
 		for (const renameLocation of renameLocations) {
-			edits.push({
-				resource: Uri.parse(renameLocation.fileName),
-				edit: {
-					range: this._textSpanToRange(model, renameLocation.textSpan),
-					text: newName
-				}
-			});
+			const resource = Uri.parse(renameLocation.fileName);
+			const model = editor.getModel(resource);
+			if (model) {
+				edits.push({
+					resource,
+					edit: {
+						range: this._textSpanToRange(model, renameLocation.textSpan),
+						text: newName
+					}
+				});
+			} else {
+				throw new Error(`Unknown URI ${resource}.`);
+			}
 		}
 
 		return { edits };