Skip to content

Commit b053376

Browse files
committed
Improve rename: it becomes more precise
1 parent 72a4aee commit b053376

7 files changed

Lines changed: 11 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ example:
1818
- ![](images/expect-semicolon.jpg)
1919

2020
### 1.2 Rename
21-
![](images/rename.gif)
21+
![](images/rename_v2.gif)
2222

2323
### 1.3 Code Completion Proposals
2424
![](images/code-completion-proposal.gif)

images/rename.gif

-192 KB
Binary file not shown.

images/rename_v2.gif

589 KB
Loading

out/extension.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out/extension.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"flink-sql-grammar-check.enable": {
4040
"type": "boolean",
4141
"default": false,
42-
"description": "Enable flink sql grammar check. the feature during experiment."
42+
"description": "Enable flink sql grammar check."
4343
}
4444
}
4545
},

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ class FqlRenameProvider implements vscode.RenameProvider {
134134
const line = document.lineAt(i);
135135
const start = line.text.indexOf(originalWord);
136136
if (start >= 0) {
137-
edit.replace(document.uri, new vscode.Range(new vscode.Position(i, start), new vscode.Position(i, start + originalWord.length)), newName);
137+
// 检查单词前后是否有其他字符
138+
const isWordBoundary = (index: number) => {
139+
return index < 0 || index >= line.text.length || /\W/.test(line.text[index]);
140+
};
141+
if (isWordBoundary(start - 1) && isWordBoundary(start + originalWord.length)) {
142+
edit.replace(document.uri, new vscode.Range(new vscode.Position(i, start), new vscode.Position(i, start + originalWord.length)), newName);
143+
}
138144
}
139145
}
140146

0 commit comments

Comments
 (0)