Skip to content

Commit

Permalink
Make editor on type bg color themeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Solorio authored and joaomoreno committed Jul 21, 2020
1 parent c4519c6 commit a4d952f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/vs/editor/contrib/rename/media/onTypeRename.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/

.monaco-editor .on-type-rename-decoration {
background: rgba(255, 0, 0, 0.3);
border-left: 1px solid rgba(255, 0, 0, 0.3);
border-left: 1px solid transparent;
/* So border can be transparent */
background-clip: padding-box;
}
10 changes: 10 additions & 0 deletions src/vs/editor/contrib/rename/onTypeRename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import { URI } from 'vs/base/common/uri';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { onUnexpectedError, onUnexpectedExternalError } from 'vs/base/common/errors';
import * as strings from 'vs/base/common/strings';
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { Color } from 'vs/base/common/color';

export const CONTEXT_ONTYPE_RENAME_INPUT_VISIBLE = new RawContextKey<boolean>('onTypeRenameInputVisible', false);

Expand Down Expand Up @@ -360,6 +363,13 @@ export function getOnTypeRenameRanges(model: ITextModel, position: Position, tok
}), result => !!result && arrays.isNonEmptyArray(result?.ranges));
}

export const editorOnTypeRenameBackground = registerColor('editor.onTypeRenameBackground', { dark: Color.fromHex('#f00').transparent(0.3), light: Color.fromHex('#f00').transparent(0.3), hc: Color.fromHex('#f00').transparent(0.3) }, nls.localize('editorOnTypeRenameBackground', 'Background color when the editor auto renames on type.'));
registerThemingParticipant((theme, collector) => {
const editorOnTypeRenameBackgroundColor = theme.getColor(editorOnTypeRenameBackground);
if (editorOnTypeRenameBackgroundColor) {
collector.addRule(`.monaco-editor .on-type-rename-decoration { background: ${editorOnTypeRenameBackgroundColor}; border-left-color: ${editorOnTypeRenameBackgroundColor}; }`);
}
});

registerModelAndPositionCommand('_executeRenameOnTypeProvider', (model, position) => getOnTypeRenameRanges(model, position, CancellationToken.None));

Expand Down

0 comments on commit a4d952f

Please sign in to comment.