summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-06-19 11:23:50 -0400
committerGitHub <noreply@github.com>2021-06-19 11:23:50 -0400
commit60071c941be503e219830cc50d2ad5e3cc8324a0 (patch)
treeed76f3b43f73ff837d5b1367a1530d65cd09de87
parent2ea41d3ac159e4c2e998d13412dc19680b01a6ca (diff)
fix(lsp): do not rename in strings and comments (#11041)
-rw-r--r--cli/lsp/language_server.rs13
-rw-r--r--cli/lsp/tsc.rs12
-rw-r--r--cli/tests/integration_tests_lsp.rs3
3 files changed, 18 insertions, 10 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 022d56aae..5a016d5c3 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -1766,13 +1766,14 @@ impl Inner {
)));
};
- let req = tsc::RequestMethod::FindRenameLocations((
+ let req = tsc::RequestMethod::FindRenameLocations {
specifier,
- line_index.offset_tsc(params.text_document_position.position)?,
- true,
- true,
- false,
- ));
+ position: line_index
+ .offset_tsc(params.text_document_position.position)?,
+ find_in_strings: false,
+ find_in_comments: false,
+ provide_prefix_and_suffix_text_for_rename: false,
+ };
let maybe_locations: Option<Vec<tsc::RenameLocation>> = self
.ts_server
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index d1690b252..359f1f24b 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -2319,7 +2319,13 @@ pub enum RequestMethod {
/// Configure the compilation settings for the server.
Configure(TsConfig),
/// 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.
GetAsset(ModuleSpecifier),
/// Retrieve code fixes for a range of a file with the provided error codes.
@@ -2370,13 +2376,13 @@ impl RequestMethod {
"method": "configure",
"compilerOptions": config,
}),
- RequestMethod::FindRenameLocations((
+ RequestMethod::FindRenameLocations {
specifier,
position,
find_in_strings,
find_in_comments,
provide_prefix_and_suffix_text_for_rename,
- )) => {
+ } => {
json!({
"id": id,
"method": "findRenameLocations",
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs
index 0d203c7f8..1f58c0749 100644
--- a/cli/tests/integration_tests_lsp.rs
+++ b/cli/tests/integration_tests_lsp.rs
@@ -957,7 +957,8 @@ fn lsp_rename() {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"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"
}
}),
);