@theia/editor 1.17.0-next.ff9e0507 → 1.18.0-next.0221c617
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/decorations/editor-decoration-style.js +20 -29
- package/lib/browser/decorations/editor-decoration-style.js.map +1 -1
- package/lib/browser/decorations/editor-decorator.js +12 -13
- package/lib/browser/decorations/editor-decorator.js.map +1 -1
- package/lib/browser/editor-command.js +180 -282
- package/lib/browser/editor-command.js.map +1 -1
- package/lib/browser/editor-contribution.js +84 -156
- package/lib/browser/editor-contribution.js.map +1 -1
- package/lib/browser/editor-frontend-module.js +21 -21
- package/lib/browser/editor-frontend-module.js.map +1 -1
- package/lib/browser/editor-keybinding-contexts.js +39 -59
- package/lib/browser/editor-keybinding-contexts.js.map +1 -1
- package/lib/browser/editor-keybinding.js +13 -16
- package/lib/browser/editor-keybinding.js.map +1 -1
- package/lib/browser/editor-manager.js +224 -371
- package/lib/browser/editor-manager.js.map +1 -1
- package/lib/browser/editor-menu.js +18 -41
- package/lib/browser/editor-menu.js.map +1 -1
- package/lib/browser/editor-navigation-contribution.js +183 -317
- package/lib/browser/editor-navigation-contribution.js.map +1 -1
- package/lib/browser/editor-preferences.js +12 -24
- package/lib/browser/editor-preferences.js.map +1 -1
- package/lib/browser/editor-variable-contribution.js +21 -25
- package/lib/browser/editor-variable-contribution.js.map +1 -1
- package/lib/browser/editor-widget-factory.js +52 -109
- package/lib/browser/editor-widget-factory.js.map +1 -1
- package/lib/browser/editor-widget.js +42 -66
- package/lib/browser/editor-widget.js.map +1 -1
- package/lib/browser/editor.js +3 -3
- package/lib/browser/editor.js.map +1 -1
- package/lib/browser/navigation/navigation-location-service.js +145 -262
- package/lib/browser/navigation/navigation-location-service.js.map +1 -1
- package/lib/browser/navigation/navigation-location-service.spec.js +84 -156
- package/lib/browser/navigation/navigation-location-service.spec.js.map +1 -1
- package/lib/browser/navigation/navigation-location-similarity.js +20 -24
- package/lib/browser/navigation/navigation-location-similarity.js.map +1 -1
- package/lib/browser/navigation/navigation-location-similarity.spec.js +8 -8
- package/lib/browser/navigation/navigation-location-similarity.spec.js.map +1 -1
- package/lib/browser/navigation/navigation-location-updater.js +52 -55
- package/lib/browser/navigation/navigation-location-updater.js.map +1 -1
- package/lib/browser/navigation/navigation-location-updater.spec.js +30 -46
- package/lib/browser/navigation/navigation-location-updater.spec.js.map +1 -1
- package/lib/browser/navigation/navigation-location.js +35 -35
- package/lib/browser/navigation/navigation-location.js.map +1 -1
- package/lib/browser/navigation/test/mock-navigation-location-updater.js +9 -32
- package/lib/browser/navigation/test/mock-navigation-location-updater.js.map +1 -1
- package/lib/browser/quick-editor-service.js +50 -78
- package/lib/browser/quick-editor-service.js.map +1 -1
- package/lib/package.spec.js +2 -2
- package/lib/package.spec.js.map +1 -1
- package/package.json +4 -4
|
@@ -16,38 +16,32 @@
|
|
|
16
16
|
********************************************************************************/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.EditorDecorationStyle = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
class EditorDecorationStyle {
|
|
20
|
+
constructor(selector, styleProvider) {
|
|
21
21
|
this.selector = selector;
|
|
22
22
|
EditorDecorationStyle.createRule(selector, styleProvider);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
enumerable: false,
|
|
29
|
-
configurable: true
|
|
30
|
-
});
|
|
31
|
-
EditorDecorationStyle.prototype.dispose = function () {
|
|
24
|
+
get className() {
|
|
25
|
+
return this.selector.split('::')[0];
|
|
26
|
+
}
|
|
27
|
+
dispose() {
|
|
32
28
|
EditorDecorationStyle.deleteRule(this.selector);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
36
31
|
exports.EditorDecorationStyle = EditorDecorationStyle;
|
|
37
32
|
(function (EditorDecorationStyle) {
|
|
38
33
|
function copyStyle(from, to) {
|
|
39
|
-
Object.keys(from).forEach(
|
|
34
|
+
Object.keys(from).forEach(key => {
|
|
40
35
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
36
|
to[key] = from[key];
|
|
42
37
|
});
|
|
43
38
|
}
|
|
44
39
|
EditorDecorationStyle.copyStyle = copyStyle;
|
|
45
|
-
function createStyleSheet(container) {
|
|
46
|
-
if (container === void 0) { container = document.getElementsByTagName('head')[0]; }
|
|
40
|
+
function createStyleSheet(container = document.getElementsByTagName('head')[0]) {
|
|
47
41
|
if (!container) {
|
|
48
42
|
return undefined;
|
|
49
43
|
}
|
|
50
|
-
|
|
44
|
+
const style = document.createElement('style');
|
|
51
45
|
style.id = 'editorDecorationsStyle';
|
|
52
46
|
style.type = 'text/css';
|
|
53
47
|
style.media = 'screen';
|
|
@@ -56,28 +50,26 @@ exports.EditorDecorationStyle = EditorDecorationStyle;
|
|
|
56
50
|
return style.sheet;
|
|
57
51
|
}
|
|
58
52
|
EditorDecorationStyle.createStyleSheet = createStyleSheet;
|
|
59
|
-
|
|
60
|
-
function createRule(selector, styleProvider, styleSheet) {
|
|
61
|
-
if (styleSheet === void 0) { styleSheet = editorDecorationsStyleSheet; }
|
|
53
|
+
const editorDecorationsStyleSheet = createStyleSheet();
|
|
54
|
+
function createRule(selector, styleProvider, styleSheet = editorDecorationsStyleSheet) {
|
|
62
55
|
if (!styleSheet) {
|
|
63
56
|
return;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
const index = styleSheet.insertRule('.' + selector + '{}', 0);
|
|
59
|
+
const rules = styleSheet.cssRules || styleSheet.rules;
|
|
60
|
+
const rule = rules[index];
|
|
68
61
|
if (rule && rule.type === CSSRule.STYLE_RULE) {
|
|
69
|
-
|
|
62
|
+
const styleRule = rule;
|
|
70
63
|
styleProvider(styleRule.style);
|
|
71
64
|
}
|
|
72
65
|
}
|
|
73
66
|
EditorDecorationStyle.createRule = createRule;
|
|
74
|
-
function deleteRule(selector, styleSheet) {
|
|
75
|
-
if (styleSheet === void 0) { styleSheet = editorDecorationsStyleSheet; }
|
|
67
|
+
function deleteRule(selector, styleSheet = editorDecorationsStyleSheet) {
|
|
76
68
|
if (!styleSheet) {
|
|
77
69
|
return;
|
|
78
70
|
}
|
|
79
|
-
|
|
80
|
-
for (
|
|
71
|
+
const rules = styleSheet.cssRules || styleSheet.rules;
|
|
72
|
+
for (let i = 0; i < rules.length; i++) {
|
|
81
73
|
if (rules[i].type === CSSRule.STYLE_RULE) {
|
|
82
74
|
if (rules[i].selectorText === selector) {
|
|
83
75
|
styleSheet.removeRule(i);
|
|
@@ -87,5 +79,4 @@ exports.EditorDecorationStyle = EditorDecorationStyle;
|
|
|
87
79
|
}
|
|
88
80
|
EditorDecorationStyle.deleteRule = deleteRule;
|
|
89
81
|
})(EditorDecorationStyle = exports.EditorDecorationStyle || (exports.EditorDecorationStyle = {}));
|
|
90
|
-
exports.EditorDecorationStyle = EditorDecorationStyle;
|
|
91
82
|
//# sourceMappingURL=editor-decoration-style.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-decoration-style.js","sourceRoot":"","sources":["../../../src/browser/decorations/editor-decoration-style.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAIlF;
|
|
1
|
+
{"version":3,"file":"editor-decoration-style.js","sourceRoot":"","sources":["../../../src/browser/decorations/editor-decoration-style.ts"],"names":[],"mappings":"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"}
|
|
@@ -22,24 +22,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.EditorDecorator = void 0;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
26
|
+
let EditorDecorator = class EditorDecorator {
|
|
27
|
+
constructor() {
|
|
28
28
|
this.appliedDecorations = new Map();
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
setDecorations(editor, newDecorations) {
|
|
31
|
+
const uri = editor.uri.toString();
|
|
32
|
+
const oldDecorations = this.appliedDecorations.get(uri) || [];
|
|
33
33
|
if (oldDecorations.length === 0 && newDecorations.length === 0) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
const decorationIds = editor.deltaDecorations({ oldDecorations, newDecorations });
|
|
37
37
|
this.appliedDecorations.set(uri, decorationIds);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}());
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
EditorDecorator = __decorate([
|
|
41
|
+
inversify_1.injectable()
|
|
42
|
+
], EditorDecorator);
|
|
44
43
|
exports.EditorDecorator = EditorDecorator;
|
|
45
44
|
//# sourceMappingURL=editor-decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-decorator.js","sourceRoot":"","sources":["../../../src/browser/decorations/editor-decorator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAElF,
|
|
1
|
+
{"version":3,"file":"editor-decorator.js","sourceRoot":"","sources":["../../../src/browser/decorations/editor-decorator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAElF,4DAA0D;AAK1D,IAAsB,eAAe,GAArC,MAAsB,eAAe;IAArC;QAEuB,uBAAkB,GAAG,IAAI,GAAG,EAAoB,CAAC;IAYxE,CAAC;IAVa,cAAc,CAAC,MAAkB,EAAE,cAAkC;QAC3E,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAClC,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9D,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5D,OAAO;SACV;QACD,MAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC,CAAC;QAClF,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACpD,CAAC;CAEJ,CAAA;AAdqB,eAAe;IADpC,sBAAU,EAAE;GACS,eAAe,CAcpC;AAdqB,0CAAe"}
|
|
@@ -23,76 +23,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
23
23
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
24
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
25
|
};
|
|
26
|
-
var
|
|
27
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
36
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
37
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
38
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
39
|
-
function step(op) {
|
|
40
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
41
|
-
while (_) try {
|
|
42
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
43
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
44
|
-
switch (op[0]) {
|
|
45
|
-
case 0: case 1: t = op; break;
|
|
46
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
47
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
48
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
49
|
-
default:
|
|
50
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
51
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
52
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
53
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
54
|
-
if (t[2]) _.ops.pop();
|
|
55
|
-
_.trys.pop(); continue;
|
|
56
|
-
}
|
|
57
|
-
op = body.call(thisArg, _);
|
|
58
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
59
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
63
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
64
|
-
if (!m) return o;
|
|
65
|
-
var i = m.call(o), r, ar = [], e;
|
|
66
|
-
try {
|
|
67
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
68
|
-
}
|
|
69
|
-
catch (error) { e = { error: error }; }
|
|
70
|
-
finally {
|
|
71
|
-
try {
|
|
72
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
73
|
-
}
|
|
74
|
-
finally { if (e) throw e.error; }
|
|
75
|
-
}
|
|
76
|
-
return ar;
|
|
77
|
-
};
|
|
78
|
-
var __spread = (this && this.__spread) || function () {
|
|
79
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
80
|
-
return ar;
|
|
81
|
-
};
|
|
26
|
+
var EditorCommandContribution_1;
|
|
82
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
28
|
exports.EditorCommandContribution = exports.EditorCommands = void 0;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
29
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
30
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
31
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
32
|
+
const editor_manager_1 = require("./editor-manager");
|
|
33
|
+
const editor_preferences_1 = require("./editor-preferences");
|
|
34
|
+
const core_1 = require("@theia/core");
|
|
35
|
+
const language_service_1 = require("@theia/core/lib/browser/language-service");
|
|
36
|
+
const supported_encodings_1 = require("@theia/core/lib/browser/supported-encodings");
|
|
92
37
|
var EditorCommands;
|
|
93
38
|
(function (EditorCommands) {
|
|
94
|
-
|
|
95
|
-
|
|
39
|
+
const EDITOR_CATEGORY = 'Editor';
|
|
40
|
+
const VIEW_CATEGORY = 'View';
|
|
96
41
|
/**
|
|
97
42
|
* Show editor references
|
|
98
43
|
*/
|
|
@@ -247,20 +192,15 @@ var EditorCommands;
|
|
|
247
192
|
label: 'Split Editor Orthogonal'
|
|
248
193
|
};
|
|
249
194
|
})(EditorCommands = exports.EditorCommands || (exports.EditorCommands = {}));
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
EditorCommandContribution_1 = EditorCommandContribution;
|
|
254
|
-
EditorCommandContribution.prototype.init = function () {
|
|
255
|
-
var _this = this;
|
|
256
|
-
this.editorPreferences.onPreferenceChanged(function (e) {
|
|
195
|
+
let EditorCommandContribution = EditorCommandContribution_1 = class EditorCommandContribution {
|
|
196
|
+
init() {
|
|
197
|
+
this.editorPreferences.onPreferenceChanged(e => {
|
|
257
198
|
if (e.preferenceName === 'editor.autoSave' && e.newValue === 'on') {
|
|
258
|
-
|
|
199
|
+
this.shell.saveAll();
|
|
259
200
|
}
|
|
260
201
|
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
var _this = this;
|
|
202
|
+
}
|
|
203
|
+
registerCommands(registry) {
|
|
264
204
|
registry.registerCommand(EditorCommands.SHOW_REFERENCES);
|
|
265
205
|
registry.registerCommand(EditorCommands.CONFIG_INDENTATION);
|
|
266
206
|
registry.registerCommand(EditorCommands.CONFIG_EOL);
|
|
@@ -268,14 +208,14 @@ var EditorCommandContribution = /** @class */ (function () {
|
|
|
268
208
|
registry.registerCommand(EditorCommands.INDENT_USING_TABS);
|
|
269
209
|
registry.registerCommand(EditorCommands.REVERT_AND_CLOSE);
|
|
270
210
|
registry.registerCommand(EditorCommands.CHANGE_LANGUAGE, {
|
|
271
|
-
isEnabled:
|
|
272
|
-
isVisible:
|
|
273
|
-
execute:
|
|
211
|
+
isEnabled: () => this.canConfigureLanguage(),
|
|
212
|
+
isVisible: () => this.canConfigureLanguage(),
|
|
213
|
+
execute: () => this.configureLanguage()
|
|
274
214
|
});
|
|
275
215
|
registry.registerCommand(EditorCommands.CHANGE_ENCODING, {
|
|
276
|
-
isEnabled:
|
|
277
|
-
isVisible:
|
|
278
|
-
execute:
|
|
216
|
+
isEnabled: () => this.canConfigureEncoding(),
|
|
217
|
+
isVisible: () => this.canConfigureEncoding(),
|
|
218
|
+
execute: () => this.configureEncoding()
|
|
279
219
|
});
|
|
280
220
|
registry.registerCommand(EditorCommands.GO_BACK);
|
|
281
221
|
registry.registerCommand(EditorCommands.GO_FORWARD);
|
|
@@ -286,221 +226,179 @@ var EditorCommandContribution = /** @class */ (function () {
|
|
|
286
226
|
registry.registerCommand(EditorCommands.TOGGLE_WORD_WRAP);
|
|
287
227
|
registry.registerCommand(EditorCommands.REOPEN_CLOSED_EDITOR);
|
|
288
228
|
registry.registerCommand(browser_1.CommonCommands.AUTO_SAVE, {
|
|
289
|
-
isToggled:
|
|
290
|
-
execute:
|
|
229
|
+
isToggled: () => this.isAutoSaveOn(),
|
|
230
|
+
execute: () => this.toggleAutoSave()
|
|
291
231
|
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
232
|
+
}
|
|
233
|
+
canConfigureLanguage() {
|
|
234
|
+
const widget = this.editorManager.currentEditor;
|
|
235
|
+
const editor = widget && widget.editor;
|
|
296
236
|
return !!editor && !!this.languages.languages;
|
|
297
|
-
}
|
|
298
|
-
|
|
237
|
+
}
|
|
238
|
+
async configureLanguage() {
|
|
299
239
|
var _a;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
editor.setLanguage(selectedMode.value.id);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return [2 /*return*/];
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
};
|
|
332
|
-
EditorCommandContribution.prototype.canConfigureEncoding = function () {
|
|
333
|
-
var widget = this.editorManager.currentEditor;
|
|
334
|
-
var editor = widget && widget.editor;
|
|
240
|
+
const widget = this.editorManager.currentEditor;
|
|
241
|
+
const editor = widget && widget.editor;
|
|
242
|
+
if (!editor || !this.languages.languages) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const current = editor.document.languageId;
|
|
246
|
+
const items = [
|
|
247
|
+
{ label: 'Auto Detect', value: 'autoDetect' },
|
|
248
|
+
{ type: 'separator', label: 'languages (identifier)' },
|
|
249
|
+
...(this.languages.languages.map(language => this.toQuickPickLanguage(language, current))).sort((e, e2) => e.label.localeCompare(e2.label))
|
|
250
|
+
];
|
|
251
|
+
const selectedMode = await ((_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(items, { placeholder: 'Select Language Mode' }));
|
|
252
|
+
if (selectedMode && ('value' in selectedMode)) {
|
|
253
|
+
if (selectedMode.value === 'autoDetect') {
|
|
254
|
+
editor.detectLanguage();
|
|
255
|
+
}
|
|
256
|
+
else if (selectedMode.value) {
|
|
257
|
+
editor.setLanguage(selectedMode.value.id);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
canConfigureEncoding() {
|
|
262
|
+
const widget = this.editorManager.currentEditor;
|
|
263
|
+
const editor = widget && widget.editor;
|
|
335
264
|
return !!editor;
|
|
336
|
-
}
|
|
337
|
-
|
|
265
|
+
}
|
|
266
|
+
async configureEncoding() {
|
|
338
267
|
var _a, _b;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
else if (k2 === configuredEncoding) {
|
|
383
|
-
return 1;
|
|
384
|
-
}
|
|
385
|
-
return supported_encodings_1.SUPPORTED_ENCODINGS[k1].order - supported_encodings_1.SUPPORTED_ENCODINGS[k2].order;
|
|
386
|
-
})
|
|
387
|
-
.filter(function (k) {
|
|
388
|
-
if (k === guessedEncoding && guessedEncoding !== configuredEncoding) {
|
|
389
|
-
return false; // do not show encoding if it is the guessed encoding that does not match the configured
|
|
390
|
-
}
|
|
391
|
-
return !isReopenWithEncoding || !supported_encodings_1.SUPPORTED_ENCODINGS[k].encodeOnly; // hide those that can only be used for encoding if we are about to decode
|
|
392
|
-
})
|
|
393
|
-
.map(function (key) { return ({ label: supported_encodings_1.SUPPORTED_ENCODINGS[key].labelLong, value: { id: key, description: key } }); });
|
|
394
|
-
// Insert guessed encoding
|
|
395
|
-
if (guessedEncoding && configuredEncoding !== guessedEncoding && supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding]) {
|
|
396
|
-
encodingItems.unshift({
|
|
397
|
-
label: "Guessed from content: " + supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding].labelLong,
|
|
398
|
-
value: { id: guessedEncoding, description: guessedEncoding }
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
return [4 /*yield*/, ((_b = this.quickInputService) === null || _b === void 0 ? void 0 : _b.showQuickPick(encodingItems, {
|
|
402
|
-
placeholder: isReopenWithEncoding ? 'Select File Encoding to Reopen File' : 'Select File Encoding to Save with'
|
|
403
|
-
}))];
|
|
404
|
-
case 6:
|
|
405
|
-
selectedFileEncoding = _d.sent();
|
|
406
|
-
if (!selectedFileEncoding) {
|
|
407
|
-
return [2 /*return*/];
|
|
408
|
-
}
|
|
409
|
-
if (editor.document.dirty && isReopenWithEncoding) {
|
|
410
|
-
this.messageService.info('The file is dirty. Please save it first before reopening it with another encoding.');
|
|
411
|
-
return [2 /*return*/];
|
|
412
|
-
}
|
|
413
|
-
else if (selectedFileEncoding.value) {
|
|
414
|
-
editor.setEncoding(selectedFileEncoding.value.id, isReopenWithEncoding ? 1 /* Decode */ : 0 /* Encode */);
|
|
415
|
-
}
|
|
416
|
-
return [2 /*return*/];
|
|
417
|
-
}
|
|
268
|
+
const widget = this.editorManager.currentEditor;
|
|
269
|
+
const editor = widget && widget.editor;
|
|
270
|
+
if (!editor) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const reopenWithEncodingPick = { label: 'Reopen with Encoding', value: 'reopen' };
|
|
274
|
+
const saveWithEncodingPick = { label: 'Save with Encoding', value: 'save' };
|
|
275
|
+
const actionItems = [
|
|
276
|
+
reopenWithEncodingPick,
|
|
277
|
+
saveWithEncodingPick
|
|
278
|
+
];
|
|
279
|
+
const selectedEncoding = await ((_a = this.quickInputService) === null || _a === void 0 ? void 0 : _a.showQuickPick(actionItems, { placeholder: 'Select Action' }));
|
|
280
|
+
if (!selectedEncoding) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const isReopenWithEncoding = (selectedEncoding.value === reopenWithEncodingPick.value);
|
|
284
|
+
const configuredEncoding = this.preferencesService.get('files.encoding', 'utf8', editor.uri.toString());
|
|
285
|
+
const resource = await this.resourceProvider(editor.uri);
|
|
286
|
+
const guessedEncoding = resource.guessEncoding ? await resource.guessEncoding() : undefined;
|
|
287
|
+
resource.dispose();
|
|
288
|
+
const encodingItems = Object.keys(supported_encodings_1.SUPPORTED_ENCODINGS)
|
|
289
|
+
.sort((k1, k2) => {
|
|
290
|
+
if (k1 === configuredEncoding) {
|
|
291
|
+
return -1;
|
|
292
|
+
}
|
|
293
|
+
else if (k2 === configuredEncoding) {
|
|
294
|
+
return 1;
|
|
295
|
+
}
|
|
296
|
+
return supported_encodings_1.SUPPORTED_ENCODINGS[k1].order - supported_encodings_1.SUPPORTED_ENCODINGS[k2].order;
|
|
297
|
+
})
|
|
298
|
+
.filter(k => {
|
|
299
|
+
if (k === guessedEncoding && guessedEncoding !== configuredEncoding) {
|
|
300
|
+
return false; // do not show encoding if it is the guessed encoding that does not match the configured
|
|
301
|
+
}
|
|
302
|
+
return !isReopenWithEncoding || !supported_encodings_1.SUPPORTED_ENCODINGS[k].encodeOnly; // hide those that can only be used for encoding if we are about to decode
|
|
303
|
+
})
|
|
304
|
+
.map(key => ({ label: supported_encodings_1.SUPPORTED_ENCODINGS[key].labelLong, value: { id: key, description: key } }));
|
|
305
|
+
// Insert guessed encoding
|
|
306
|
+
if (guessedEncoding && configuredEncoding !== guessedEncoding && supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding]) {
|
|
307
|
+
encodingItems.unshift({
|
|
308
|
+
label: `Guessed from content: ${supported_encodings_1.SUPPORTED_ENCODINGS[guessedEncoding].labelLong}`,
|
|
309
|
+
value: { id: guessedEncoding, description: guessedEncoding }
|
|
418
310
|
});
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
311
|
+
}
|
|
312
|
+
const selectedFileEncoding = await ((_b = this.quickInputService) === null || _b === void 0 ? void 0 : _b.showQuickPick(encodingItems, {
|
|
313
|
+
placeholder: isReopenWithEncoding ? 'Select File Encoding to Reopen File' : 'Select File Encoding to Save with'
|
|
314
|
+
}));
|
|
315
|
+
if (!selectedFileEncoding) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (editor.document.dirty && isReopenWithEncoding) {
|
|
319
|
+
this.messageService.info('The file is dirty. Please save it first before reopening it with another encoding.');
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
else if (selectedFileEncoding.value) {
|
|
323
|
+
editor.setEncoding(selectedFileEncoding.value.id, isReopenWithEncoding ? 1 /* Decode */ : 0 /* Encode */);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
toQuickPickLanguage(value, current) {
|
|
327
|
+
const languageUri = this.toLanguageUri(value);
|
|
328
|
+
const icon = this.labelProvider.getIcon(languageUri);
|
|
329
|
+
const iconClasses = icon !== '' ? [icon + ' file-icon'] : undefined;
|
|
425
330
|
return {
|
|
426
|
-
value
|
|
331
|
+
value,
|
|
427
332
|
label: value.name,
|
|
428
|
-
description:
|
|
429
|
-
iconClasses
|
|
333
|
+
description: `(${value.id})${current === value.id ? ' - Configured Language' : ''}`,
|
|
334
|
+
iconClasses
|
|
430
335
|
};
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
336
|
+
}
|
|
337
|
+
toLanguageUri(language) {
|
|
338
|
+
const extension = language.extensions.values().next();
|
|
434
339
|
if (extension.value) {
|
|
435
340
|
return new uri_1.default('file:///' + extension.value);
|
|
436
341
|
}
|
|
437
|
-
|
|
342
|
+
const filename = language.filenames.values().next();
|
|
438
343
|
if (filename.value) {
|
|
439
344
|
return new uri_1.default('file:///' + filename.value);
|
|
440
345
|
}
|
|
441
346
|
return new uri_1.default('file:///.txt');
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
347
|
+
}
|
|
348
|
+
isAutoSaveOn() {
|
|
349
|
+
const autoSave = this.preferencesService.get(EditorCommandContribution_1.AUTOSAVE_PREFERENCE);
|
|
445
350
|
return autoSave === 'on' || autoSave === undefined;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
__metadata("design:returntype", void 0)
|
|
499
|
-
], EditorCommandContribution.prototype, "init", null);
|
|
500
|
-
EditorCommandContribution = EditorCommandContribution_1 = __decorate([
|
|
501
|
-
inversify_1.injectable()
|
|
502
|
-
], EditorCommandContribution);
|
|
503
|
-
return EditorCommandContribution;
|
|
504
|
-
}());
|
|
351
|
+
}
|
|
352
|
+
async toggleAutoSave() {
|
|
353
|
+
this.preferencesService.updateValue(EditorCommandContribution_1.AUTOSAVE_PREFERENCE, this.isAutoSaveOn() ? 'off' : 'on');
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
EditorCommandContribution.AUTOSAVE_PREFERENCE = 'editor.autoSave';
|
|
357
|
+
__decorate([
|
|
358
|
+
inversify_1.inject(browser_1.ApplicationShell),
|
|
359
|
+
__metadata("design:type", browser_1.ApplicationShell)
|
|
360
|
+
], EditorCommandContribution.prototype, "shell", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
inversify_1.inject(browser_1.PreferenceService),
|
|
363
|
+
__metadata("design:type", Object)
|
|
364
|
+
], EditorCommandContribution.prototype, "preferencesService", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
inversify_1.inject(editor_preferences_1.EditorPreferences),
|
|
367
|
+
__metadata("design:type", Object)
|
|
368
|
+
], EditorCommandContribution.prototype, "editorPreferences", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
inversify_1.inject(browser_1.QuickInputService),
|
|
371
|
+
inversify_1.optional(),
|
|
372
|
+
__metadata("design:type", Object)
|
|
373
|
+
], EditorCommandContribution.prototype, "quickInputService", void 0);
|
|
374
|
+
__decorate([
|
|
375
|
+
inversify_1.inject(core_1.MessageService),
|
|
376
|
+
__metadata("design:type", core_1.MessageService)
|
|
377
|
+
], EditorCommandContribution.prototype, "messageService", void 0);
|
|
378
|
+
__decorate([
|
|
379
|
+
inversify_1.inject(browser_1.LabelProvider),
|
|
380
|
+
__metadata("design:type", browser_1.LabelProvider)
|
|
381
|
+
], EditorCommandContribution.prototype, "labelProvider", void 0);
|
|
382
|
+
__decorate([
|
|
383
|
+
inversify_1.inject(language_service_1.LanguageService),
|
|
384
|
+
__metadata("design:type", language_service_1.LanguageService)
|
|
385
|
+
], EditorCommandContribution.prototype, "languages", void 0);
|
|
386
|
+
__decorate([
|
|
387
|
+
inversify_1.inject(editor_manager_1.EditorManager),
|
|
388
|
+
__metadata("design:type", editor_manager_1.EditorManager)
|
|
389
|
+
], EditorCommandContribution.prototype, "editorManager", void 0);
|
|
390
|
+
__decorate([
|
|
391
|
+
inversify_1.inject(core_1.ResourceProvider),
|
|
392
|
+
__metadata("design:type", Function)
|
|
393
|
+
], EditorCommandContribution.prototype, "resourceProvider", void 0);
|
|
394
|
+
__decorate([
|
|
395
|
+
inversify_1.postConstruct(),
|
|
396
|
+
__metadata("design:type", Function),
|
|
397
|
+
__metadata("design:paramtypes", []),
|
|
398
|
+
__metadata("design:returntype", void 0)
|
|
399
|
+
], EditorCommandContribution.prototype, "init", null);
|
|
400
|
+
EditorCommandContribution = EditorCommandContribution_1 = __decorate([
|
|
401
|
+
inversify_1.injectable()
|
|
402
|
+
], EditorCommandContribution);
|
|
505
403
|
exports.EditorCommandContribution = EditorCommandContribution;
|
|
506
404
|
//# sourceMappingURL=editor-command.js.map
|