Skip to content

Commit

Permalink
rename OnTypeRename -> LinkedEditing (for #109923)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Nov 27, 2020
1 parent f137206 commit 627ad0b
Show file tree
Hide file tree
Showing 19 changed files with 286 additions and 269 deletions.
18 changes: 9 additions & 9 deletions extensions/html-language-features/client/src/htmlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace CustomDataChangedNotification {
namespace TagCloseRequest {
export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('html/tag');
}
namespace OnTypeRenameRequest {
export const type: RequestType<TextDocumentPositionParams, LspRange[] | null, any, any> = new RequestType('html/onTypeRename');
namespace LinkedEditingRequest {
export const type: RequestType<TextDocumentPositionParams, LspRange[] | null, any, any> = new RequestType('html/linkedEditing');
}

// experimental: semantic tokens
Expand All @@ -44,7 +44,7 @@ namespace SemanticTokenLegendRequest {
}

namespace SettingIds {
export const renameOnType = 'editor.renameOnType';
export const linkedRename = 'editor.linkedRename';
export const formatEnable = 'html.format.enable';

}
Expand Down Expand Up @@ -169,10 +169,10 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
}
});

disposable = languages.registerOnTypeRenameRangeProvider(documentSelector, {
async provideOnTypeRenameRanges(document, position) {
disposable = languages.registerLinkedEditingRangeProvider(documentSelector, {
async provideLinkedEditingRanges(document, position) {
const param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
return client.sendRequest(OnTypeRenameRequest.type, param).then(response => {
return client.sendRequest(LinkedEditingRequest.type, param).then(response => {
if (response) {
return {
ranges: response.map(r => client.protocol2CodeConverter.asRange(r))
Expand Down Expand Up @@ -301,17 +301,17 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
const promptForTypeOnRenameKey = 'html.promptForTypeOnRename';
const promptForTypeOnRename = extensions.getExtension('formulahendry.auto-rename-tag') !== undefined &&
(context.globalState.get(promptForTypeOnRenameKey) !== false) &&
!workspace.getConfiguration('editor', { languageId: 'html' }).get('renameOnType');
!workspace.getConfiguration('editor', { languageId: 'html' }).get('linkedRename');

if (promptForTypeOnRename) {
const activeEditorListener = window.onDidChangeActiveTextEditor(async e => {
if (e && documentSelector.indexOf(e.document.languageId) !== -1) {
context.globalState.update(promptForTypeOnRenameKey, false);
activeEditorListener.dispose();
const configure = localize('configureButton', 'Configure');
const res = await window.showInformationMessage(localize('renameOnTypeQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
const res = await window.showInformationMessage(localize('linkedRenameQuestion', 'VS Code now has built-in support for auto-renaming tags. Do you want to enable it?'), configure);
if (res === configure) {
commands.executeCommand('workbench.action.openSettings', SettingIds.renameOnType);
commands.executeCommand('workbench.action.openSettings', SettingIds.linkedRename);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion extensions/html-language-features/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.",
"html.autoClosingTags": "Enable/disable autoclosing of HTML tags.",
"html.mirrorCursorOnMatchingTag": "Enable/disable mirroring cursor on matching HTML tag.",
"html.mirrorCursorOnMatchingTagDeprecationMessage": "Deprecated in favor of `editor.renameOnType`"
"html.mirrorCursorOnMatchingTagDeprecationMessage": "Deprecated in favor of `editor.linkedEditing`"
}
10 changes: 5 additions & 5 deletions extensions/html-language-features/server/src/htmlServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace CustomDataChangedNotification {
namespace TagCloseRequest {
export const type: RequestType<TextDocumentPositionParams, string | null, any, any> = new RequestType('html/tag');
}
namespace OnTypeRenameRequest {
export const type: RequestType<TextDocumentPositionParams, Range[] | null, any, any> = new RequestType('html/onTypeRename');
namespace LinkedEditingRequest {
export const type: RequestType<TextDocumentPositionParams, Range[] | null, any, any> = new RequestType('html/linkedEditing');
}

// experimental: semantic tokens
Expand Down Expand Up @@ -508,15 +508,15 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}, null, `Error while computing rename for ${params.textDocument.uri}`, token);
});

connection.onRequest(OnTypeRenameRequest.type, (params, token) => {
connection.onRequest(LinkedEditingRequest.type, (params, token) => {
return runSafe(async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const pos = params.position;
if (pos.character > 0) {
const mode = languageModes.getModeAtPosition(document, Position.create(pos.line, pos.character - 1));
if (mode && mode.doOnTypeRename) {
return mode.doOnTypeRename(document, pos);
if (mode && mode.doLinkedEditing) {
return mode.doLinkedEditing(document, pos);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace:
const htmlDocument = htmlDocuments.get(document);
return htmlLanguageService.findMatchingTagPosition(document, position, htmlDocument);
},
async doOnTypeRename(document: TextDocument, position: Position) {
async doLinkedEditing(document: TextDocument, position: Position) {
const htmlDocument = htmlDocuments.get(document);
return htmlLanguageService.findOnTypeRenameRanges(document, position, htmlDocument);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface LanguageMode {
doHover?: (document: TextDocument, position: Position) => Promise<Hover | null>;
doSignatureHelp?: (document: TextDocument, position: Position) => Promise<SignatureHelp | null>;
doRename?: (document: TextDocument, position: Position, newName: string) => Promise<WorkspaceEdit | null>;
doOnTypeRename?: (document: TextDocument, position: Position) => Promise<Range[] | null>;
doLinkedEditing?: (document: TextDocument, position: Position) => Promise<Range[] | null>;
findDocumentHighlight?: (document: TextDocument, position: Position) => Promise<DocumentHighlight[]>;
findDocumentSymbols?: (document: TextDocument) => Promise<SymbolInformation[]>;
findDocumentLinks?: (document: TextDocument, documentContext: DocumentContext) => Promise<DocumentLink[]>;
Expand Down
13 changes: 11 additions & 2 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ export interface IEditorOptions {
*/
readOnly?: boolean;
/**
* Rename matching regions on type.
* Enable linked editing.
* Defaults to false.
*/
linkedEditing?: boolean;
/**
* deprecated, use linkedEditing instead
*/
renameOnType?: boolean;
/**
* Should the editor render validation decorations.
Expand Down Expand Up @@ -3682,6 +3686,7 @@ export const enum EditorOption {
lineHeight,
lineNumbers,
lineNumbersMinChars,
linkedEditing,
links,
matchBrackets,
minimap,
Expand Down Expand Up @@ -4033,6 +4038,10 @@ export const EditorOptions = {
EditorOption.lineNumbersMinChars, 'lineNumbersMinChars',
5, 1, 300
)),
linkedEditing: register(new EditorBooleanOption(
EditorOption.linkedEditing, 'linkedEditing', false,
{ description: nls.localize('linkedEditing', "Controls whether the editor has linked editing enabled. Depending on the language, related symbols, e.g. HTML tags, are updated while editing.") }
)),
links: register(new EditorBooleanOption(
EditorOption.links, 'links', true,
{ description: nls.localize('links', "Controls whether the editor should detect links and make them clickable.") }
Expand Down Expand Up @@ -4134,7 +4143,7 @@ export const EditorOptions = {
)),
renameOnType: register(new EditorBooleanOption(
EditorOption.renameOnType, 'renameOnType', false,
{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type.") }
{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type."), markdownDeprecationMessage: nls.localize('renameOnTypeDeprecate', "Deprecated, use `editor.linkedEditing` instead.") }
)),
renderControlCharacters: register(new EditorBooleanOption(
EditorOption.renderControlCharacters, 'renderControlCharacters', false,
Expand Down
20 changes: 10 additions & 10 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,24 +819,24 @@ export interface DocumentHighlightProvider {
}

/**
* The rename range provider interface defines the contract between extensions and
* the live-rename feature.
* The linked editing range provider interface defines the contract between extensions and
* the linked editing feature.
*/
export interface OnTypeRenameRangeProvider {
export interface LinkedEditingRangeProvider {

/**
* Provide a list of ranges that can be live-renamed together.
* Provide a list of ranges that can be edited together.
*/
provideOnTypeRenameRanges(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<OnTypeRenameRanges>;
provideLinkedEditingRanges(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
}

/**
* Represents a list of ranges that can be renamed together along with a word pattern to describe valid range contents.
* Represents a list of ranges that can be edited together along with a word pattern to describe valid contents.
*/
export interface OnTypeRenameRanges {
export interface LinkedEditingRanges {
/**
* A list of ranges that can be renamed together. The ranges must have
* identical length and contain identical text content. The ranges cannot overlap
* A list of ranges that can be edited together. The ranges must have
* identical length and text content. The ranges cannot overlap
*/
ranges: IRange[];

Expand Down Expand Up @@ -1737,7 +1737,7 @@ export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry<Doc
/**
* @internal
*/
export const OnTypeRenameRangeProviderRegistry = new LanguageFeatureRegistry<OnTypeRenameRangeProvider>();
export const LinkedEditingRangeProviderRegistry = new LanguageFeatureRegistry<LinkedEditingRangeProvider>();

/**
* @internal
Expand Down
133 changes: 67 additions & 66 deletions src/vs/editor/common/standalone/standaloneEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,72 +224,73 @@ export enum EditorOption {
lineHeight = 54,
lineNumbers = 55,
lineNumbersMinChars = 56,
links = 57,
matchBrackets = 58,
minimap = 59,
mouseStyle = 60,
mouseWheelScrollSensitivity = 61,
mouseWheelZoom = 62,
multiCursorMergeOverlapping = 63,
multiCursorModifier = 64,
multiCursorPaste = 65,
occurrencesHighlight = 66,
overviewRulerBorder = 67,
overviewRulerLanes = 68,
padding = 69,
parameterHints = 70,
peekWidgetDefaultFocus = 71,
definitionLinkOpensInPeek = 72,
quickSuggestions = 73,
quickSuggestionsDelay = 74,
readOnly = 75,
renameOnType = 76,
renderControlCharacters = 77,
renderIndentGuides = 78,
renderFinalNewline = 79,
renderLineHighlight = 80,
renderLineHighlightOnlyWhenFocus = 81,
renderValidationDecorations = 82,
renderWhitespace = 83,
revealHorizontalRightPadding = 84,
roundedSelection = 85,
rulers = 86,
scrollbar = 87,
scrollBeyondLastColumn = 88,
scrollBeyondLastLine = 89,
scrollPredominantAxis = 90,
selectionClipboard = 91,
selectionHighlight = 92,
selectOnLineNumbers = 93,
showFoldingControls = 94,
showUnused = 95,
snippetSuggestions = 96,
smartSelect = 97,
smoothScrolling = 98,
stopRenderingLineAfter = 99,
suggest = 100,
suggestFontSize = 101,
suggestLineHeight = 102,
suggestOnTriggerCharacters = 103,
suggestSelection = 104,
tabCompletion = 105,
tabIndex = 106,
unusualLineTerminators = 107,
useTabStops = 108,
wordSeparators = 109,
wordWrap = 110,
wordWrapBreakAfterCharacters = 111,
wordWrapBreakBeforeCharacters = 112,
wordWrapColumn = 113,
wordWrapMinified = 114,
wrappingIndent = 115,
wrappingStrategy = 116,
showDeprecated = 117,
editorClassName = 118,
pixelRatio = 119,
tabFocusMode = 120,
layoutInfo = 121,
wrappingInfo = 122
linkedEditing = 57,
links = 58,
matchBrackets = 59,
minimap = 60,
mouseStyle = 61,
mouseWheelScrollSensitivity = 62,
mouseWheelZoom = 63,
multiCursorMergeOverlapping = 64,
multiCursorModifier = 65,
multiCursorPaste = 66,
occurrencesHighlight = 67,
overviewRulerBorder = 68,
overviewRulerLanes = 69,
padding = 70,
parameterHints = 71,
peekWidgetDefaultFocus = 72,
definitionLinkOpensInPeek = 73,
quickSuggestions = 74,
quickSuggestionsDelay = 75,
readOnly = 76,
renameOnType = 77,
renderControlCharacters = 78,
renderIndentGuides = 79,
renderFinalNewline = 80,
renderLineHighlight = 81,
renderLineHighlightOnlyWhenFocus = 82,
renderValidationDecorations = 83,
renderWhitespace = 84,
revealHorizontalRightPadding = 85,
roundedSelection = 86,
rulers = 87,
scrollbar = 88,
scrollBeyondLastColumn = 89,
scrollBeyondLastLine = 90,
scrollPredominantAxis = 91,
selectionClipboard = 92,
selectionHighlight = 93,
selectOnLineNumbers = 94,
showFoldingControls = 95,
showUnused = 96,
snippetSuggestions = 97,
smartSelect = 98,
smoothScrolling = 99,
stopRenderingLineAfter = 100,
suggest = 101,
suggestFontSize = 102,
suggestLineHeight = 103,
suggestOnTriggerCharacters = 104,
suggestSelection = 105,
tabCompletion = 106,
tabIndex = 107,
unusualLineTerminators = 108,
useTabStops = 109,
wordSeparators = 110,
wordWrap = 111,
wordWrapBreakAfterCharacters = 112,
wordWrapBreakBeforeCharacters = 113,
wordWrapColumn = 114,
wordWrapMinified = 115,
wrappingIndent = 116,
wrappingStrategy = 117,
showDeprecated = 118,
editorClassName = 119,
pixelRatio = 120,
tabFocusMode = 121,
layoutInfo = 122,
wrappingInfo = 123
}

/**
Expand Down
Loading

0 comments on commit 627ad0b

Please sign in to comment.