Repository navigation
Rename a method, property or type across the workspace with Rename symbol (rs) - #698
Conversation
…age server Asks textDocument/prepareRename where the server advertises prepareProvider, then opens a prompt on the name it gives. Ctrl+Enter sends textDocument/rename and reads the WorkspaceEdit from documentChanges or changes, text edits only. Open tabs take their part as one ReplaceLines each, so one undo step, left unsaved; files that aren't open are written after a confirm, keeping their BOM and line endings, and the server is told they changed. A tab edited or a file changed on disk since the server was asked is skipped and named on the status bar. The Usages tab lists one row per changed line afterwards. Closes #697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hang on Windows
new Uri("/work/New.cs") throws on Windows, so the fake never answered
textDocument/rename and Rename_reads_documentChanges_and_leaves_out_the_file_operations
waited until CI's 30-minute timeout.
Closes #697
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
CI on 3d1d4c5: |
Needs changing
Worth considering
|
…s left unchanged After a rename, a changed file open in the other editor group had its Usages rows read from disk, showing the old name. Rows now come from whichever group holds the tab. The status bar said every skipped file "changed while renaming", but a file is also skipped when it isn't UTF-8, can't be written, or is read-only. It now says the file was left unchanged. Closes #697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Pushed 6c4b845.
I've left Worth considering for you. |
…ialog's title csharp-ls answers prepareRename with null when the cursor is just past a name (before a `;` say), so `rs` there said "Can't rename this". Ask about the start of the identifier at or just before the cursor instead, as the word fallback already did. And `_` in the dialog's title was taken as a hotkey marker, so "Rename _bar" showed as "Rename bar". Closes #697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/TuiCode.Workbench/Languages/LanguageServer.cs # src/TuiCode.Workbench/WorkbenchHost.cs # tests/TuiCode.Tests/FakeLanguageServer.cs # tests/TuiCode.Tests/MenuBarHostTests.cs
csharp-ls only knows files inside a project it loaded, and answers prepareRename with null for any other, so a loose test.cs at a repo root got a bare "Can't rename this". When no folder from the file's up to the server's root holds a .csproj, the status bar now says so. Closes #697 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
CI on 62f6b0f failed on ubuntu only, in one test: |
Rename symbol (
rs, in Edit, and the palette) renames the symbol under the cursor (a variable, parameter, field, method, property, class or any other symbol the language server can rename) across the folder, through the language server. It asks for the new name, edits the open tabs (unsaved, oneCtrl+Zper tab), and confirms before writing files that aren't open, keeping their BOM and line endings. Afterwards the Usages tab lists every changed line underRenamed <old> → <new> · <n> in <m> files. Comments and strings are left alone, since only the server's edits are made.Closes #697
Choices worth a look:
gs. So criterion 10 is only half met: the mnemonics list showsrs. To list it, either give it a key or have F1 show key-less commands by their mnemonic. Tell me which you want.workspace/didChangeWatchedFiles, so its next answer isn't based on the old text._bar|;),rsnow renames that name. csharp-ls refuses to prepare a rename there, so TuiCode asks about the start of the name instead._of any message (Renamed _bar to _countshows asRenamed bar to _count). That's MentalDesk.Tui'sAppStatusBartreating_as a hotkey marker, so it affects every status message, not just rename. The fix is in tui-style-guide.What it looks like
With the cursor on a method name in a C# file and the language server ready,
rs(and Edit ▸ Rename symbol, and the palette) opens a dialog titledRename <name>, with aNew name:text field holding the current name, all of it selected.When some changed files aren't open, a confirm first says
Rename <old> to <new>? <n> changes in <m> files. <k> files aren't open and are saved straight away., with[ Rename ]and[ Cancel ], Cancel focused. Cancel changes nothing anywhere. Rename writes the closed files to disk, keeping their encoding and line endings, and edits the open tabs unsaved.After a rename, the sidebar's Usages tab shows
Renamed <old> → <new> · <n> in <m> files, grouped by file, one row per changed line, andEnteron a row opens it there.An empty or unchanged name keeps the dialog open, marks the field and says why at the dialog's foot; so does a name the server rejects, in the server's words.
On something that can't be renamed (a keyword, a type from a library, or with a server that doesn't support rename) the dialog doesn't open, and the status bar says why, in the server's words where it gives them.
Checked by the team
screenWith the cursor on a method name in a C# file and the language server ready,rs(and Edit ▸ Rename symbol, and the palette) opens a dialog titledRename <name>, with aNew name:text field holding the current name, all of it selected.testTyping a new name and pressingCtrl+Enter(or the[ Rename ]button) renames the declaration and every reference to it; the same word in comments, strings and unrelated members is left alone.testEsc(or[ Cancel ]) closes the dialog and changes nothing.testWhen every changed file is open, there is no confirm: each tab shows the change, unsaved, andCtrl+Zin a tab takes back that tab's whole part of the rename in one step.screenWhen some changed files aren't open, a confirm first saysRename <old> to <new>? <n> changes in <m> files. <k> files aren't open and are saved straight away., with[ Rename ]and[ Cancel ], Cancel focused. Cancel changes nothing anywhere. Rename writes the closed files to disk, keeping their encoding and line endings, and edits the open tabs unsaved.screenAfter a rename, the sidebar's Usages tab showsRenamed <old> → <new> · <n> in <m> files, grouped by file, one row per changed line, andEnteron a row opens it there.screenAn empty or unchanged name keeps the dialog open, marks the field and says why at the dialog's foot; so does a name the server rejects, in the server's words.screenOn something that can't be renamed (a keyword, a type from a library, or with a server that doesn't support rename) the dialog doesn't open, and the status bar says why, in the server's words where it gives them.testWith no language server, or while it's loading, the command behaves as Go to definition does then, and the Edit menu item is dimmed.a-team try tuicode 698