mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(lsp): do not rename in strings and comments (#11041)
This commit is contained in:
parent
2ea41d3ac1
commit
60071c941b
3 changed files with 18 additions and 10 deletions
|
@ -1766,13 +1766,14 @@ impl Inner {
|
||||||
)));
|
)));
|
||||||
};
|
};
|
||||||
|
|
||||||
let req = tsc::RequestMethod::FindRenameLocations((
|
let req = tsc::RequestMethod::FindRenameLocations {
|
||||||
specifier,
|
specifier,
|
||||||
line_index.offset_tsc(params.text_document_position.position)?,
|
position: line_index
|
||||||
true,
|
.offset_tsc(params.text_document_position.position)?,
|
||||||
true,
|
find_in_strings: false,
|
||||||
false,
|
find_in_comments: false,
|
||||||
));
|
provide_prefix_and_suffix_text_for_rename: false,
|
||||||
|
};
|
||||||
|
|
||||||
let maybe_locations: Option<Vec<tsc::RenameLocation>> = self
|
let maybe_locations: Option<Vec<tsc::RenameLocation>> = self
|
||||||
.ts_server
|
.ts_server
|
||||||
|
|
|
@ -2319,7 +2319,13 @@ pub enum RequestMethod {
|
||||||
/// Configure the compilation settings for the server.
|
/// Configure the compilation settings for the server.
|
||||||
Configure(TsConfig),
|
Configure(TsConfig),
|
||||||
/// Get rename locations at a given position.
|
/// Get rename locations at a given position.
|
||||||
FindRenameLocations((ModuleSpecifier, u32, bool, bool, bool)),
|
FindRenameLocations {
|
||||||
|
specifier: ModuleSpecifier,
|
||||||
|
position: u32,
|
||||||
|
find_in_strings: bool,
|
||||||
|
find_in_comments: bool,
|
||||||
|
provide_prefix_and_suffix_text_for_rename: bool,
|
||||||
|
},
|
||||||
/// Retrieve the text of an assets that exists in memory in the isolate.
|
/// Retrieve the text of an assets that exists in memory in the isolate.
|
||||||
GetAsset(ModuleSpecifier),
|
GetAsset(ModuleSpecifier),
|
||||||
/// Retrieve code fixes for a range of a file with the provided error codes.
|
/// Retrieve code fixes for a range of a file with the provided error codes.
|
||||||
|
@ -2370,13 +2376,13 @@ impl RequestMethod {
|
||||||
"method": "configure",
|
"method": "configure",
|
||||||
"compilerOptions": config,
|
"compilerOptions": config,
|
||||||
}),
|
}),
|
||||||
RequestMethod::FindRenameLocations((
|
RequestMethod::FindRenameLocations {
|
||||||
specifier,
|
specifier,
|
||||||
position,
|
position,
|
||||||
find_in_strings,
|
find_in_strings,
|
||||||
find_in_comments,
|
find_in_comments,
|
||||||
provide_prefix_and_suffix_text_for_rename,
|
provide_prefix_and_suffix_text_for_rename,
|
||||||
)) => {
|
} => {
|
||||||
json!({
|
json!({
|
||||||
"id": id,
|
"id": id,
|
||||||
"method": "findRenameLocations",
|
"method": "findRenameLocations",
|
||||||
|
|
|
@ -957,7 +957,8 @@ fn lsp_rename() {
|
||||||
"uri": "file:///a/file.ts",
|
"uri": "file:///a/file.ts",
|
||||||
"languageId": "typescript",
|
"languageId": "typescript",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"text": "let variable = 'a';\nconsole.log(variable);"
|
// this should not rename in comments and strings
|
||||||
|
"text": "let variable = 'a'; // variable\nconsole.log(variable);\n\"variable\";\n"
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue