val-town / codemirror-ts

lint, hover, and autocomplete extensions for CodeMirror + TypeScript
https://val-town.github.io/codemirror-ts/
ISC License
105 stars 6 forks source link

Implement symbol renaming #6

Open tmcw opened 7 months ago

tmcw commented 7 months ago

CleanShot 2023-11-17 at 17 09 04@2x

This is supported by monaco and should be available to CodeMirror users. It doesn't seem like TypeScript itself has a method to just "give you a document with a symbol renamed" - it's a matter of finding all instances of the symbol and renaming them there. Closest I can find to a source reference:

https://github.com/microsoft/monaco-editor/blob/091550e89857bd926d2b66e100dc3c2094475783/src/language/typescript/languageFeatures.ts#L1191C48-L1191C48

peterje commented 4 months ago

What's the expected API here? I guess this is an overarching question for the library as a whole. Should codemirror-ts ship with a default context menu, similar to what Monaco provides? The alternative is to ship some minimal

renameSymbol({offset: number, newSymbolName: string, ...opts})

From my experience, the codemirror ecosystem seems to promote the latter.