Repository navigation
Closed
Labels
api-finalizationeditor-synced-regionIssues related to synced region functionality in editorfeature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code Insidersverification-neededVerification of issue is requestedverifiedVerification succeeded
Milestone
Description
The OnTypeRenameProvider allows the editor to apply a rename to a symbol automatically to other ranges as well.
The feature can be seen in action in HTML, where modifications to an open tag is automatically applied to the close tag (and vice versa). (Requires settings: "editor.renameOnType": true)
/**
* The 'on type' rename provider interface defines the contract between extensions and
* the 'on type' rename feature.
*/
export interface OnTypeRenameProvider {
/**
* For a given position in a document, returns the range of the symbol at the position and all ranges
* that have the same content and can be renamed together. Optionally a result specific word pattern can be returned as well
* that describes valid contents. A rename to one of the ranges can be applied to all other ranges if the new content
* matches the word pattern.
* If no result-specific word pattern is provided, the word pattern defined when registering the provider is used.
*
* @param document The document in which the provider was invoked.
* @param position The position at which the provider was invoked.
* @param token A cancellation token.
* @return A list of ranges that can be renamed together. The ranges must have
* identical length and contain identical text content. The ranges cannot overlap. Optionally a word pattern
* that overrides the word pattern defined when registering the provider can be provided.
*/
provideOnTypeRenameRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<{ ranges: Range[]; wordPattern?: RegExp; }>;
}
namespace languages {
/**
* Register a 'on type' rename provider.
*
* Multiple providers can be registered for a language. In that case providers are sorted
* by their [score](#languages.match) and the best-matching provider that has a result is used. Failure
* of the selected provider will cause a failure of the whole operation.
*
* @param selector A selector that defines the documents this provider is applicable to.
* @param provider An 'on type' rename provider.
* @param wordPattern A word pattern to describes valid contents of renamed ranges.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerOnTypeRenameProvider(selector: DocumentSelector, provider: OnTypeRenameProvider, wordPattern?: RegExp): Disposable;
}Metadata
Metadata
Assignees
Labels
api-finalizationeditor-synced-regionIssues related to synced region functionality in editorfeature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code Insidersverification-neededVerification of issue is requestedverifiedVerification succeeded
Activity
[-]Finalize OnTypeRenameProvider[/-][+][rename on type] finalize OnTypeRenameProvider[/+]jrieken commentedon Nov 10, 2020
adopt feedback for #109923
aeschli commentedon Nov 11, 2020
Adopted feedback: New state:
jrieken commentedon Nov 16, 2020
/Naming nit/ - In the past we haven't been super consistent but when the function is called
provideOnTypeRenameRanges(which I like) than the provider should be calledOnTypeRenameRangeProvider= today is missesRangetho it is rename ranges that it providesgjsjohnmurray commentedon Nov 16, 2020
Johannes Rieken (@jrieken) why
Rangeand notRanges?jrieken commentedon Nov 16, 2020
Actually unsure but that's the majority of cases. I'd say the logic is that a provider can provide a thing and then there is call to provide many - and in some case a call to resolve one.
rename to OnTypeRenameRangeProvider. For #109923
aeschli commentedon Nov 16, 2020
Makes sense. I made the rename to OnTypeRenameRangeProvider
adopt feedback for #109923
11 remaining items
aeschli commentedon Dec 1, 2020
Moved to public vscode.d.ts.
To verify, please create a small extension, install it like a regular extension and verify it works (no more proposedAPI checks)
johnsoncodehk commentedon Dec 9, 2020
I found this registerOnTypeRenameProvider is work to
html-language-featuresin VSCode v0.15.1, but it not working when I try to followinghtml-language-featuresto addedclient.registerProposedFeatures()and"enableProposedApi": true.It should be work? or use proposed API in non Insiders VSCode is built-in package's privilege?
supplement: It working for VSCode Insiders
aeschli commentedon Dec 9, 2020
Yes, built-in extensions are allowed to use proposed API also in stable.
But the new API is now public in 1.52:
languages.registerLinkedEditingRangeProviderfeat: prepare linked editing feature
johnsoncodehk commentedon Dec 10, 2020
Martin Aeschlimann (@aeschli) can't wait for it! :) can turn
editor.linkedEditingdefault on? otherwise 99% of users will miss it.Squashed 'lib/vscode/' changes from e5a624b..ea3859d
Squashed 'lib/vscode/' changes from e5a624b..ea3859d
Squashed 'lib/vscode/' changes from e5a624b..3e344b17b7
Ares9323 commentedon Jan 7, 2021
Can you please explain how to use this setting?
I have version 1.52.1 and settings.json says "Unknown Configuration Settings"
I have read the documentation for both "editor.renameOnType" and "editor.linkedEditing" but it looks like there's nothing there.
I'd like to have an example of the syntax of this setting too, I tried several but none of them matched.
An extension I use to beautify files only supports html, js and css and I managed to make it work with "blade" and "php" files as they were .html with this setting:
"beautify.language": {"html": ["htm","html","php","blade",]},Do I have to do something similar or do I just need to type the extension in a particular way?
Thanks in advance, have a nice day