code editor - move untitled hint contribution

上级 7bec90ca
......@@ -15,7 +15,6 @@ import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/u
import { TextResourceEditorInput } from 'vs/workbench/common/editor/textResourceEditorInput';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor';
import { UntitledHintContribution } from 'vs/workbench/browser/parts/editor/untitledHint';
import { BinaryResourceDiffEditor } from 'vs/workbench/browser/parts/editor/binaryDiffEditor';
import { ChangeEncodingAction, ChangeEOLAction, ChangeModeAction, EditorStatus } from 'vs/workbench/browser/parts/editor/editorStatus';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions, CATEGORIES } from 'vs/workbench/common/actions';
......@@ -118,7 +117,7 @@ interface ISerializedUntitledTextEditorInput {
encoding: string | undefined;
}
// Register Editor Input Serializer
// Register Untitled Text Editor Input Serializer
class UntitledTextEditorInputSerializer implements IEditorInputSerializer {
constructor(
......@@ -282,9 +281,6 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
// Register Editor Auto Save
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(EditorAutoSave, LifecyclePhase.Ready);
// Register Untitled Hint
registerEditorContribution(UntitledHintContribution.ID, UntitledHintContribution);
// Register Status Actions
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
registry.registerWorkbenchAction(SyncActionDescriptor.from(ChangeModeAction, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyCode.KEY_M) }), 'Change Language Mode', undefined, ContextKeyExpr.not('notebookEditorFocused'));
......@@ -605,7 +601,6 @@ const previousChangeIcon = registerIcon('diff-editor-previous-change', Codicon.a
const nextChangeIcon = registerIcon('diff-editor-next-change', Codicon.arrowDown, localize('nextChangeIcon', 'Icon for the next change action in the diff editor.'));
const toggleWhitespace = registerIcon('diff-editor-toggle-whitespace', Codicon.whitespace, localize('toggleWhitespace', 'Icon for the toggle whitespace action in the diff editor.'));
// Diff Editor Title Menu: Previous Change
appendEditorToolItem(
{
......
......@@ -18,4 +18,5 @@ import './toggleMultiCursorModifier';
import './toggleRenderControlCharacter';
import './toggleRenderWhitespace';
import './toggleWordWrap';
import './untitledEditorHint';
import './workbenchReferenceSearch';
......@@ -17,18 +17,19 @@ import { Schemas } from 'vs/base/common/network';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITASExperimentService } from 'vs/workbench/services/experiment/common/experimentService';
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
const $ = dom.$;
const untitledHintSetting = 'workbench.editor.untitled.hint';
export class UntitledHintContribution implements IEditorContribution {
const untitledEditorHintSetting = 'workbench.editor.untitled.hint';
export class UntitledEditorHintContribution implements IEditorContribution {
public static readonly ID = 'editor.contrib.untitledHint';
private toDispose: IDisposable[];
private untitledHintContentWidget: UntitledHintContentWidget | undefined;
private untitledHintContentWidget: UntitledEditorHintContentWidget | undefined;
private experimentTreatment: 'text' | 'hidden' | undefined;
constructor(
private editor: ICodeEditor,
@ICommandService private readonly commandService: ICommandService,
......@@ -40,7 +41,7 @@ export class UntitledHintContribution implements IEditorContribution {
this.toDispose.push(this.editor.onDidChangeModel(() => this.update()));
this.toDispose.push(this.editor.onDidChangeModelLanguage(() => this.update()));
this.toDispose.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(untitledHintSetting)) {
if (e.affectsConfiguration(untitledEditorHintSetting)) {
this.update();
}
}));
......@@ -52,13 +53,13 @@ export class UntitledHintContribution implements IEditorContribution {
private update(): void {
this.untitledHintContentWidget?.dispose();
const configValue = this.configurationService.getValue<'text' | 'hidden' | 'default'>(untitledHintSetting);
const configValue = this.configurationService.getValue<'text' | 'hidden' | 'default'>(untitledEditorHintSetting);
const untitledHintMode = configValue === 'default' ? (this.experimentTreatment || 'text') : configValue;
const model = this.editor.getModel();
if (model && model.uri.scheme === Schemas.untitled && model.getModeId() === PLAINTEXT_MODE_ID && untitledHintMode === 'text') {
this.untitledHintContentWidget = new UntitledHintContentWidget(this.editor, this.commandService, this.configurationService);
this.untitledHintContentWidget = new UntitledEditorHintContentWidget(this.editor, this.commandService, this.configurationService);
}
}
......@@ -68,7 +69,7 @@ export class UntitledHintContribution implements IEditorContribution {
}
}
class UntitledHintContentWidget implements IContentWidget {
class UntitledEditorHintContentWidget implements IContentWidget {
private static readonly ID = 'editor.widget.untitledHint';
......@@ -99,7 +100,7 @@ class UntitledHintContentWidget implements IContentWidget {
}
getId(): string {
return UntitledHintContentWidget.ID;
return UntitledEditorHintContentWidget.ID;
}
// Select a language to get started. Start typing to dismiss, or don't show this again.
......@@ -133,7 +134,7 @@ class UntitledHintContentWidget implements IContentWidget {
}));
this.toDispose.push(dom.addDisposableListener(dontShow, 'click', () => {
this.configurationService.updateValue(untitledHintSetting, 'hidden');
this.configurationService.updateValue(untitledEditorHintSetting, 'hidden');
this.dispose();
this.editor.focus();
}));
......@@ -173,3 +174,5 @@ registerThemingParticipant((theme, collector) => {
collector.addRule(`.monaco-editor .contentWidgets .untitled-hint a { color: ${textLinkForegroundColor}; }`);
}
});
registerEditorContribution(UntitledEditorHintContribution.ID, UntitledEditorHintContribution);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册