Skip to content

Commit

Permalink
Merge pull request #92597 from microsoft/octref/live-rename
Browse files Browse the repository at this point in the history
On Type Rename for #88424
  • Loading branch information
octref authored Mar 18, 2020
2 parents 1c2c8ba + 196562b commit f76ca9f
Show file tree
Hide file tree
Showing 14 changed files with 1,064 additions and 83 deletions.
10 changes: 10 additions & 0 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ export interface IEditorOptions {
* Defaults to false.
*/
readOnly?: boolean;
/**
* Rename matching regions on type.
* Defaults to false.
*/
renameOnType?: boolean;
/**
* Should the editor render validation decorations.
* Defaults to editable.
Expand Down Expand Up @@ -3374,6 +3379,7 @@ export const enum EditorOption {
quickSuggestions,
quickSuggestionsDelay,
readOnly,
renameOnType,
renderControlCharacters,
renderIndentGuides,
renderFinalNewline,
Expand Down Expand Up @@ -3790,6 +3796,10 @@ export const EditorOptions = {
readOnly: register(new EditorBooleanOption(
EditorOption.readOnly, 'readOnly', false,
)),
renameOnType: register(new EditorBooleanOption(
EditorOption.renameOnType, 'renameOnType', false,
{ description: nls.localize('renameOnType', "Controls whether the editor auto renames on type.") }
)),
renderControlCharacters: register(new EditorBooleanOption(
EditorOption.renderControlCharacters, 'renderControlCharacters', false,
{ description: nls.localize('renderControlCharacters', "Controls whether the editor should render control characters.") }
Expand Down
19 changes: 19 additions & 0 deletions src/vs/editor/common/modes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,20 @@ export interface DocumentHighlightProvider {
provideDocumentHighlights(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
}

/**
* The rename provider interface defines the contract between extensions and
* the live-rename feature.
*/
export interface OnTypeRenameProvider {

stopPattern?: RegExp;

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

/**
* Value-object that contains additional information when
* requesting references.
Expand Down Expand Up @@ -1642,6 +1656,11 @@ export const DocumentSymbolProviderRegistry = new LanguageFeatureRegistry<Docume
*/
export const DocumentHighlightProviderRegistry = new LanguageFeatureRegistry<DocumentHighlightProvider>();

/**
* @internal
*/
export const OnTypeRenameProviderRegistry = new LanguageFeatureRegistry<OnTypeRenameProvider>();

/**
* @internal
*/
Expand Down
83 changes: 42 additions & 41 deletions src/vs/editor/common/standalone/standaloneEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,47 +238,48 @@ export enum EditorOption {
quickSuggestions = 70,
quickSuggestionsDelay = 71,
readOnly = 72,
renderControlCharacters = 73,
renderIndentGuides = 74,
renderFinalNewline = 75,
renderLineHighlight = 76,
renderValidationDecorations = 77,
renderWhitespace = 78,
revealHorizontalRightPadding = 79,
roundedSelection = 80,
rulers = 81,
scrollbar = 82,
scrollBeyondLastColumn = 83,
scrollBeyondLastLine = 84,
scrollPredominantAxis = 85,
selectionClipboard = 86,
selectionHighlight = 87,
selectOnLineNumbers = 88,
showFoldingControls = 89,
showUnused = 90,
snippetSuggestions = 91,
smoothScrolling = 92,
stopRenderingLineAfter = 93,
suggest = 94,
suggestFontSize = 95,
suggestLineHeight = 96,
suggestOnTriggerCharacters = 97,
suggestSelection = 98,
tabCompletion = 99,
useTabStops = 100,
wordSeparators = 101,
wordWrap = 102,
wordWrapBreakAfterCharacters = 103,
wordWrapBreakBeforeCharacters = 104,
wordWrapColumn = 105,
wordWrapMinified = 106,
wrappingIndent = 107,
wrappingStrategy = 108,
editorClassName = 109,
pixelRatio = 110,
tabFocusMode = 111,
layoutInfo = 112,
wrappingInfo = 113
renameOnType = 73,
renderControlCharacters = 74,
renderIndentGuides = 75,
renderFinalNewline = 76,
renderLineHighlight = 77,
renderValidationDecorations = 78,
renderWhitespace = 79,
revealHorizontalRightPadding = 80,
roundedSelection = 81,
rulers = 82,
scrollbar = 83,
scrollBeyondLastColumn = 84,
scrollBeyondLastLine = 85,
scrollPredominantAxis = 86,
selectionClipboard = 87,
selectionHighlight = 88,
selectOnLineNumbers = 89,
showFoldingControls = 90,
showUnused = 91,
snippetSuggestions = 92,
smoothScrolling = 93,
stopRenderingLineAfter = 94,
suggest = 95,
suggestFontSize = 96,
suggestLineHeight = 97,
suggestOnTriggerCharacters = 98,
suggestSelection = 99,
tabCompletion = 100,
useTabStops = 101,
wordSeparators = 102,
wordWrap = 103,
wordWrapBreakAfterCharacters = 104,
wordWrapBreakBeforeCharacters = 105,
wordWrapColumn = 106,
wordWrapMinified = 107,
wrappingIndent = 108,
wrappingStrategy = 109,
editorClassName = 110,
pixelRatio = 111,
tabFocusMode = 112,
layoutInfo = 113,
wrappingInfo = 114
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/vs/editor/contrib/rename/media/onTypeRename.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

.monaco-editor .on-type-rename-decoration {
background: rgba(255, 0, 0, 0.3);
border-left: 1px solid rgba(255, 0, 0, 0.3);
/* So border can be transparent */
background-clip: padding-box;
}
Loading

0 comments on commit f76ca9f

Please sign in to comment.