diff --git a/packages/core-browser/src/core-preferences.ts b/packages/core-browser/src/core-preferences.ts
index c1bf37f5ab..e5fdcc69a0 100644
--- a/packages/core-browser/src/core-preferences.ts
+++ b/packages/core-browser/src/core-preferences.ts
@@ -197,6 +197,18 @@ export const corePreferenceSchema: PreferenceSchema = {
enum: ['\n', '\r\n', 'auto'],
default: 'auto',
},
+ 'files.trimFinalNewlines': {
+ type: 'boolean',
+ default: false,
+ },
+ 'files.trimTrailingWhitespace': {
+ type: 'boolean',
+ default: false,
+ },
+ 'files.insertFinalNewline': {
+ type: 'boolean',
+ default: false,
+ },
'files.autoGuessEncoding': {
type: 'boolean',
default: false,
diff --git a/packages/core-browser/src/preferences/settings.ts b/packages/core-browser/src/preferences/settings.ts
index 743fab5035..f68a75b68f 100644
--- a/packages/core-browser/src/preferences/settings.ts
+++ b/packages/core-browser/src/preferences/settings.ts
@@ -33,7 +33,11 @@ export interface ISettingGroup {
export interface IPreferenceViewDesc {
id: string;
- localized: string;
+ /**
+ * 为空会根据 id 来生成展示的名字
+ * 如:`enablePreview` -> `Enable Preview`
+ */
+ localized?: string;
/**
* 在指定 scope 下不展示
*/
diff --git a/packages/editor/src/browser/preference/converter.ts b/packages/editor/src/browser/preference/converter.ts
index 431fab3cc6..73be963840 100644
--- a/packages/editor/src/browser/preference/converter.ts
+++ b/packages/editor/src/browser/preference/converter.ts
@@ -4,7 +4,6 @@ import { IConfigurationService } from '@opensumi/monaco-editor-core/esm/vs/platf
import { IConvertedMonacoOptions } from '../types';
-
/**
* 计算由ConfigurationService设置值带来的monaco编辑器的属性
* @param configurationService IConfigurationService
diff --git a/packages/editor/src/browser/preference/schema.ts b/packages/editor/src/browser/preference/schema.ts
index 92d390dd92..7c8ab8cefd 100644
--- a/packages/editor/src/browser/preference/schema.ts
+++ b/packages/editor/src/browser/preference/schema.ts
@@ -1659,6 +1659,7 @@ const customEditorSchema: PreferenceSchemaProperties = {
'editor.previewMode': {
type: 'boolean',
default: true,
+ description: '%editor.configuration.previewMode%',
},
'editor.wrapTab': {
type: 'boolean',
diff --git a/packages/i18n/src/common/en-US.lang.ts b/packages/i18n/src/common/en-US.lang.ts
index 944f9ffbb3..493da62536 100644
--- a/packages/i18n/src/common/en-US.lang.ts
+++ b/packages/i18n/src/common/en-US.lang.ts
@@ -502,13 +502,12 @@ export const localizationBundle = {
'preference.editor.largeFile': 'Large File Size',
'preference.editor.formatOnPaste': 'Format On Paste',
'preference.files.eol': 'Files EOL',
+
'keymaps.tab.name': 'Keyboard Shortcuts',
'preference.editor.wrapTab': 'Wrap Editor Tabs',
- 'preference.editor.enablePreviewFromCodeNavigation':
- 'Controls whether editors remain in preview when a code navigation is started from them. Preview editors do not keep open and are reused until explicitly set to be kept open (e.g. via double click or editing). This value is ignored when `#workbench.editor.enablePreview#` is disabled.',
'preference.editor.preferredFormatter': 'Default Formatter',
- 'preference.editor.previewMode': 'Preview Mode',
+ 'editor.configuration.previewMode': 'Enable Preview Mode',
'preference.editor.fontFamily': 'Font Family',
'preference.editor.minimap': 'minimap',
'preference.editor.forceReadOnly': 'readOnly',
@@ -522,6 +521,8 @@ export const localizationBundle = {
'preference.item.notValid': '{0} is not a valid option',
+ 'editor.configuration.enablePreviewFromCodeNavigation':
+ 'Controls whether editors remain in preview when a code navigation is started from them. Preview editors do not keep open and are reused until explicitly set to be kept open (e.g. via double click or editing). This value is ignored when `#workbench.editor.enablePreview#` is disabled.',
'editor.configuration.wrapTab':
'Controls whether to wrap editor tabs instead of scroll mode when tabs are beyond the visible area.',
'editor.configuration.askIfDiff': 'When saving files, throw error if the file on disk has a newer version.',
diff --git a/packages/i18n/src/common/zh-CN.lang.ts b/packages/i18n/src/common/zh-CN.lang.ts
index 2deb95e53e..8d325befd2 100644
--- a/packages/i18n/src/common/zh-CN.lang.ts
+++ b/packages/i18n/src/common/zh-CN.lang.ts
@@ -432,7 +432,7 @@ export const localizationBundle = {
'preference.workbench.refactoringChanges.showPreviewStrategy.title': '重构确认方式',
'preference.editor.wrapTab': '编辑器 Tab 自动换行',
- 'preference.editor.previewMode': '使用预览模式打开',
+ 'editor.configuration.previewMode': '使用预览模式打开',
'preference.editor.fontFamily': '字体',
'preference.editor.minimap': '显示 Minimap',
'preference.editor.forceReadOnly': '只读模式',
diff --git a/packages/preferences/src/browser/preference-contribution.ts b/packages/preferences/src/browser/preference-contribution.ts
index 70ac38a731..9e2463353d 100644
--- a/packages/preferences/src/browser/preference-contribution.ts
+++ b/packages/preferences/src/browser/preference-contribution.ts
@@ -47,7 +47,6 @@ import { PreferenceView } from './preferences.view';
import { USER_PREFERENCE_URI } from './user-preference-provider';
import { WorkspacePreferenceProvider } from './workspace-preference-provider';
-
const PREF_PREVIEW_COMPONENT_ID = 'pref-preview';
@Injectable()
diff --git a/packages/preferences/src/browser/preference-settings.service.ts b/packages/preferences/src/browser/preference-settings.service.ts
index 0f2dbec387..19783cffd8 100644
--- a/packages/preferences/src/browser/preference-settings.service.ts
+++ b/packages/preferences/src/browser/preference-settings.service.ts
@@ -27,7 +27,7 @@ import {
} from '@opensumi/ide-core-browser';
import { IFileServiceClient } from '@opensumi/ide-file-service';
-import { toPreferenceReadableName, PreferenceSettingId } from '../common';
+import { toPreferenceReadableName, PreferenceSettingId, getPreferenceItemLabel } from '../common';
import { PREFERENCE_COMMANDS } from './preference-contribution';
@@ -231,7 +231,7 @@ export class PreferenceSettingsService implements IPreferenceSettingsService {
const prefId = typeof pref === 'string' ? pref : pref.id;
const schema = this.schemaProvider.getPreferenceProperty(prefId);
- const prefLabel = typeof pref === 'string' ? toPreferenceReadableName(pref) : localize(pref.localized);
+ const prefLabel = typeof pref === 'string' ? toPreferenceReadableName(pref) : getPreferenceItemLabel(pref);
const description = schema && replaceLocalizePlaceholder(schema.description);
return (
this.isContainSearchValue(prefId, search) ||
@@ -407,10 +407,9 @@ export const defaultSettingSections: {
{
preferences: [
// 预览模式
- { id: 'editor.previewMode', localized: 'preference.editor.previewMode' },
+ { id: 'editor.previewMode' },
{
id: 'editor.enablePreviewFromCodeNavigation',
- localized: 'preference.editor.enablePreviewFromCodeNavigation',
},
// 自动保存
{ id: 'editor.autoSave', localized: 'preference.editor.autoSave' },
@@ -427,46 +426,44 @@ export const defaultSettingSections: {
{ id: 'editor.fontWeight', localized: 'preference.editor.fontWeight' },
{ id: 'editor.fontFamily', localized: 'preference.editor.fontFamily' },
{ id: 'editor.lineHeight', localized: 'preference.editor.lineHeight' },
+ { id: 'editor.trimAutoWhitespace' },
// 补全
- { id: 'editor.suggest.insertMode', localized: 'preference.editor.suggest.insertMode' },
- { id: 'editor.suggest.filterGraceful', localized: 'preference.editor.suggest.filterGraceful' },
- { id: 'editor.suggest.localityBonus', localized: 'preference.editor.suggest.localityBonus' },
- { id: 'editor.suggest.shareSuggestSelections', localized: 'preference.editor.suggest.shareSuggestSelections' },
- {
- id: 'editor.suggest.snippetsPreventQuickSuggestions',
- localized: 'preference.editor.suggest.snippetsPreventQuickSuggestions',
- },
- { id: 'editor.suggest.showIcons', localized: 'preference.editor.suggest.showIcons' },
- { id: 'editor.suggest.maxVisibleSuggestions', localized: 'preference.editor.suggest.maxVisibleSuggestions' },
- { id: 'editor.suggest.showMethods', localized: 'preference.editor.suggest.showMethods' },
- { id: 'editor.suggest.showFunctions', localized: 'preference.editor.suggest.showFunctions' },
- { id: 'editor.suggest.showConstructors', localized: 'preference.editor.suggest.showConstructors' },
- { id: 'editor.suggest.showFields', localized: 'preference.editor.suggest.showFields' },
- { id: 'editor.suggest.showVariables', localized: 'preference.editor.suggest.showVariables' },
- { id: 'editor.suggest.showClasses', localized: 'preference.editor.suggest.showClasses' },
- { id: 'editor.suggest.showStructs', localized: 'preference.editor.suggest.showStructs' },
- { id: 'editor.suggest.showInterfaces', localized: 'preference.editor.suggest.showInterfaces' },
- { id: 'editor.suggest.showModules', localized: 'preference.editor.suggest.showModules' },
- { id: 'editor.suggest.showProperties', localized: 'preference.editor.suggest.showProperties' },
- { id: 'editor.suggest.showEvents', localized: 'preference.editor.suggest.showEvents' },
- { id: 'editor.suggest.showOperators', localized: 'preference.editor.suggest.showOperators' },
- { id: 'editor.suggest.showUnits', localized: 'preference.editor.suggest.showUnits' },
- { id: 'editor.suggest.showValues', localized: 'preference.editor.suggest.showValues' },
- { id: 'editor.suggest.showConstants', localized: 'preference.editor.suggest.showConstants' },
- { id: 'editor.suggest.showEnums', localized: 'preference.editor.suggest.showEnums' },
- { id: 'editor.suggest.showEnumMembers', localized: 'preference.editor.suggest.showEnumMembers' },
- { id: 'editor.suggest.showKeywords', localized: 'preference.editor.suggest.showKeywords' },
- { id: 'editor.suggest.showWords', localized: 'preference.editor.suggest.showWords' },
- { id: 'editor.suggest.showColors', localized: 'preference.editor.suggest.showColors' },
- { id: 'editor.suggest.showFiles', localized: 'preference.editor.suggest.showFiles' },
- { id: 'editor.suggest.showReferences', localized: 'preference.editor.suggest.showReferences' },
- { id: 'editor.suggest.showCustomcolors', localized: 'preference.editor.suggest.showCustomcolors' },
- { id: 'editor.suggest.showFolders', localized: 'preference.editor.suggest.showFolders' },
- { id: 'editor.suggest.showTypeParameters', localized: 'preference.editor.suggest.showTypeParameters' },
- { id: 'editor.suggest.showSnippets', localized: 'preference.editor.suggest.showSnippets' },
- { id: 'editor.suggest.showUsers', localized: 'preference.editor.suggest.showUsers' },
- { id: 'editor.suggest.showIssues', localized: 'preference.editor.suggest.showIssues' },
- { id: 'editor.suggest.preview', localized: 'preference.editor.suggest.preview' },
+ { id: 'editor.suggest.insertMode' },
+ { id: 'editor.suggest.filterGraceful' },
+ { id: 'editor.suggest.localityBonus' },
+ { id: 'editor.suggest.shareSuggestSelections' },
+ { id: 'editor.suggest.snippetsPreventQuickSuggestions' },
+ { id: 'editor.suggest.showIcons' },
+ { id: 'editor.suggest.maxVisibleSuggestions' },
+ { id: 'editor.suggest.showMethods' },
+ { id: 'editor.suggest.showFunctions' },
+ { id: 'editor.suggest.showConstructors' },
+ { id: 'editor.suggest.showFields' },
+ { id: 'editor.suggest.showVariables' },
+ { id: 'editor.suggest.showClasses' },
+ { id: 'editor.suggest.showStructs' },
+ { id: 'editor.suggest.showInterfaces' },
+ { id: 'editor.suggest.showModules' },
+ { id: 'editor.suggest.showProperties' },
+ { id: 'editor.suggest.showEvents' },
+ { id: 'editor.suggest.showOperators' },
+ { id: 'editor.suggest.showUnits' },
+ { id: 'editor.suggest.showValues' },
+ { id: 'editor.suggest.showConstants' },
+ { id: 'editor.suggest.showEnums' },
+ { id: 'editor.suggest.showEnumMembers' },
+ { id: 'editor.suggest.showKeywords' },
+ { id: 'editor.suggest.showWords' },
+ { id: 'editor.suggest.showColors' },
+ { id: 'editor.suggest.showFiles' },
+ { id: 'editor.suggest.showReferences' },
+ { id: 'editor.suggest.showCustomcolors' },
+ { id: 'editor.suggest.showFolders' },
+ { id: 'editor.suggest.showTypeParameters' },
+ { id: 'editor.suggest.showSnippets' },
+ { id: 'editor.suggest.showUsers' },
+ { id: 'editor.suggest.showIssues' },
+ { id: 'editor.suggest.preview' },
// Guides
{ id: 'editor.guides.bracketPairs', localized: 'preference.editor.guides.bracketPairs' },
@@ -502,6 +499,9 @@ export const defaultSettingSections: {
{ id: 'files.autoGuessEncoding', localized: 'preference.files.autoGuessEncoding.title' },
{ id: 'files.encoding', localized: 'preference.files.encoding.title' },
{ id: 'files.eol', localized: 'preference.files.eol' },
+ { id: 'files.trimFinalNewlines' },
+ { id: 'files.trimTrailingWhitespace' },
+ { id: 'files.insertFinalNewline' },
{ id: 'editor.readonlyFiles', localized: 'preference.editor.readonlyFiles' },
{ id: 'files.exclude', localized: 'preference.files.exclude.title' },
{ id: 'files.watcherExclude', localized: 'preference.files.watcherExclude.title' },
diff --git a/packages/preferences/src/browser/preferenceItem.view.tsx b/packages/preferences/src/browser/preferenceItem.view.tsx
index 5a78c367d4..047bb6d8c3 100644
--- a/packages/preferences/src/browser/preferenceItem.view.tsx
+++ b/packages/preferences/src/browser/preferenceItem.view.tsx
@@ -17,12 +17,11 @@ import {
formatLocalize,
} from '@opensumi/ide-core-browser';
-import { toPreferenceReadableName } from '../common';
+import { toPreferenceReadableName, getPreferenceItemLabel } from '../common';
import { PreferenceSettingsService } from './preference-settings.service';
import styles from './preferences.module.less';
-
interface IPreferenceItemProps {
preferenceName: string;
localizedName?: string;
@@ -175,7 +174,7 @@ const renderDescriptionExpression = (des: string) => {
const { 0: expression, 1: preferenceId } = match;
const preference = preferenceSettingService.getSectionByPreferenceId(preferenceId);
if (preference) {
- const preferenceTitle = localize(preference.localized);
+ const preferenceTitle = getPreferenceItemLabel(preference);
const others: any[] = description
.split(expression)
.map((des: string, index: number) => {des});
diff --git a/packages/preferences/src/browser/preferences.view.tsx b/packages/preferences/src/browser/preferences.view.tsx
index c2b4fd1bc0..a60270d501 100644
--- a/packages/preferences/src/browser/preferences.view.tsx
+++ b/packages/preferences/src/browser/preferences.view.tsx
@@ -252,7 +252,7 @@ export const PreferenceItem = ({ data, index }: { data: ISectionItemData; index:
);
diff --git a/packages/preferences/src/common/preference.ts b/packages/preferences/src/common/preference.ts
index a52c923caf..df6db80541 100644
--- a/packages/preferences/src/common/preference.ts
+++ b/packages/preferences/src/common/preference.ts
@@ -1,6 +1,8 @@
+import { IPreferenceViewDesc, localize } from '@opensumi/ide-core-browser';
+
export const PREF_SCHEME = 'pref';
-export function toPreferenceReadableName(name) {
+export function toPreferenceReadableName(name: string) {
const parts = name.split('.');
let result = toNormalCase(parts[0]);
if (parts[1]) {
@@ -12,6 +14,13 @@ export function toPreferenceReadableName(name) {
return result;
}
+export function getPreferenceItemLabel(pref: IPreferenceViewDesc) {
+ if (pref.localized) {
+ return localize(pref.localized);
+ }
+ return toPreferenceReadableName(pref.id);
+}
+
export function toNormalCase(str: string) {
return str.substr(0, 1).toUpperCase() + str.substr(1).replace(/([^A-Z])([A-Z])/g, '$1 $2');
}