Skip to content

Commit

Permalink
fix: cr issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pmizio committed Oct 12, 2023
1 parent 85756bc commit 60d8ad3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h1 align="center">typescript-tools.nvim</h1
<h1 align="center">typescript-tools.nvim</h1>
<p align="center"><sup>⚡ TypeScript integration NeoVim deserves ⚡</sup></p>

### 🚧 Warning 🚧

Please note that the plugin is currently in the early beta version, which means you may encounter
bugs.
Expand Down Expand Up @@ -242,7 +245,7 @@ This plugin provides several custom user commands (they are only applied to curr
- `TSToolsGoToSourceDefinition` - goes to
[source definition](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#go-to-source-definition)
(available since TS v4.7)
- `TSToolsRename` - allow to rename current file and apply changes to connected files
- `TSToolsRenameFile` - allow to rename current file and apply changes to connected files

## Supported LSP methods

Expand Down
4 changes: 2 additions & 2 deletions lua/typescript-tools/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function M.request_diagnostics(callback)
end

---@param is_sync boolean
function M.rename(is_sync)
function M.rename_file(is_sync)
local source = vim.api.nvim_buf_get_name(0)

a.void(function()
Expand Down Expand Up @@ -189,7 +189,7 @@ function M.rename(is_sync)

au.scheduler()
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_get_name(bufnr) == source then
if vim.api.nvim_buf_is_valid(bufnr) and vim.api.nvim_buf_get_name(bufnr) == source then
vim.api.nvim_buf_set_name(bufnr, newSource)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/typescript-tools/user_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function M.setup_user_commands()
api.fix_all(is_sync)
end)

create_command("TSToolsRename", function(is_sync)
api.rename(is_sync)
create_command("TSToolsRenameFile", function(is_sync)
api.rename_file(is_sync)
end)
end

Expand Down

0 comments on commit 60d8ad3

Please sign in to comment.