Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update monaco editor to 0.12.x #1681

Merged
merged 6 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ env:
global:
- secure: es511klr3A8rLVIQ+ZxWkYl2/OLaZYzHpLH94O0EqFDC05t7sk76WOD+9fVT0jkINUKt7sK4Nozv19GmNYxFVXKaWwAH9jt7sHKYgbfCr+vTg58z9jyposMZSGEgsGPSbFn5DxPS7KdWbfQDEjxX18yiKMKN9k+7XwkC8p+WSgy4I30M5Y4YXffQooEwjqJpTdkpOm6p+o6t99mp3ufaxG5VOLtSwsZ0r3cKJo0rbqKxJGA62eNYLYksQ7PsFHDE2stQ8IDxFNXOrXB6ocwwd7KGphJIofU/t1UCXjpsGn0Ozr4LYvSpvl9nKQBmA3prKuAOnygLZh0YfYACIoIpBFa0/igxdX7j7INgp50Q+6CHRWwCb+YqZPgJ297EZi5mVKYNlAh0OeKKTo0NanunWR2pnzj29MGzR40wJqPVhQBRQvaKannwpoY5opK8MWi9jnDDY3xpzgZ8na3yOkw9wQ+a2nUm13BZnWmMDODGnaf9vy9eQ7bB26eiU2VSHlNWeniqDMY81sjqBlst22bHR4IgsI4qkh5UXMyyvMKbXltUIXERdCv1yK/Faa/VJ0Qrs+mk+G23bkT8/1f6cHBhjiVJX5HhXLcN3lHxImi+K9NkuCn8g+okX+SfD2lT5OPpRYHS8Jb51frNUIDWqWqRcjCioNjcuup2o6nbTlJaFb0=
- CXX=g++-4.8
- NODE_OPTIONS="--max_old_space_size=4096"
addons:
apt:
sources:
Expand All @@ -63,7 +64,7 @@ before_script:
- export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start ;
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost \& ;
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.2.1
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.6.0
- export PATH=$HOME/.yarn/bin:$PATH ;
install: yarn
script: travis_retry yarn test ;
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ branches:

install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install [email protected] -g
- netsh advfirewall firewall add rule name="SeleniumIn" dir=in action=allow protocol=TCP localport=4444
- netsh advfirewall firewall add rule name="SeleniumOut" dir=out action=allow protocol=TCP localport=4444

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"umd-compat-loader": "^2.1.1",
"url-loader": "^1.0.1",
"webpack": "^4.0.0",
"webpack-cli": "^2.0.12"
"webpack-cli": "2.0.12"
},
"devDependencies": {
"@theia/ext-scripts": "^0.3.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const { mode } = yargs.option('mode', {
const development = mode === 'development';${this.ifMonaco(() => `

const monacoEditorPath = development ? '${this.resolve('monaco-editor-core', 'dev/vs')}' : '${this.resolve('monaco-editor-core', 'min/vs')}';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to take a look at #1542 and the referenced microsoft/monaco-editor#18. Basically, this means we no longer need to copy all the monaco files separately, but bundle it into our main artefact.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it is out of the scope of this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How out of scope? This is only available on Monaco 0.11+ and we should do it upon the upgrade. I'm aware that this is not a blocker, but this is not out of scope either.

Copy link
Member

@akosyakov akosyakov Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do it with another PR, there are things to consider before switching from AMD to ESM, like the build speed. We had bad experience in monaco-languageclient. We want to consider it separately without blocking usage of the latest Monaco.

const monacoLanguagesPath = '${this.resolve('monaco-languages', 'release')}';
const monacoLanguagesPath = '${this.resolve('monaco-languages', 'release/min')}';
const monacoCssLanguagePath = '${this.resolve('monaco-css', 'release/min')}';
const monacoJsonLanguagePath = '${this.resolve('monaco-json', 'release/min')}';
const monacoHtmlLanguagePath = '${this.resolve('monaco-html', 'release/min')}';`)}
Expand Down
14 changes: 13 additions & 1 deletion examples/browser/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@ exports.config = {
services: ['selenium-standalone'],
seleniumArgs: {
seleniumArgs: ["-port", "4444"],
javaArgs: ["-Xmx1024m", "-Djna.nosys=true"]
javaArgs: ["-Xmx1024m", "-Djna.nosys=true"],
drivers: {
chrome: {
version: '2.33'
}
}
},
seleniumInstallArgs: {
drivers: {
chrome: {
version: '2.33'
}
}
},
//
// Framework you want to run your specs with.
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"chai": "^4.1.0",
"chai-string": "^1.4.0",
"concurrently": "^3.5.0",
"electron-mocha": "^3.5.0",
"electron-mocha": "~3.5.0",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.0",
"jsdom": "^11.5.1",
Expand All @@ -27,7 +27,6 @@
"nyc": "^11.0.3",
"remap-istanbul": "^0.9.5",
"rimraf": "^2.6.1",
"selenium-standalone": "^6.2.0",
"sinon": "^3.3.0",
"temp": "^0.8.3",
"ts-node": "^3.2.0",
Expand All @@ -36,19 +35,19 @@
"typedoc": "^0.8",
"typescript": "^2.7.2",
"uuid": "^3.1.0",
"wdio-mocha-framework": "^0.5.9",
"wdio-phantomjs-service": "^0.2.2",
"wdio-mocha-framework": "0.5.9",
"wdio-phantomjs-service": "0.2.2",
"wdio-selenium-standalone-service": "0.0.8",
"wdio-spec-reporter": "^0.1.0",
"webdriverio": "^4.6.2"
"wdio-spec-reporter": "0.1.0",
"webdriverio": "4.9.2"
},
"scripts": {
"prepare": "yarn rebuild:clean && yarn build:clean",
"build": "run build",
"build:clean": "run prepare",
"docs": "run docs \"@theia/!(example-)*\"",
"test": "yarn test:theia && yarn test:electron && yarn test:browser",
"test:theia": "run test \"@theia/!(example-)*\" --parallel",
"test:theia": "run test \"@theia/!(example-)*\" --stream --concurrency==1",
"test:browser": "yarn rebuild:browser && run test \"@theia/example-browser\"",
"test:electron": "yarn rebuild:electron && run test \"@theia/example-electron\"",
"rebuild:clean": "rimraf .browser_modules",
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/browser/editor-decorations-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export namespace EditorDecorationStyle {
const index = styleSheet.insertRule('.' + selector + '{}', 0);
const rules = styleSheet.cssRules || styleSheet.rules;
const rule = rules.item(index);
if (rule.type === CSSRule.STYLE_RULE) {
if (rule && rule.type === CSSRule.STYLE_RULE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your tsc --version? Is this related: #1621?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's 2.7.2, but code-insiders is ahead and sometimes it fails to pick ts from node_modules. that change would still be ok with 2.7.x, I'll check that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, and please, ignore me; I was curious. Thanks!

const styleRule = rule as CSSStyleRule;
styleProvider(styleRule.style);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ export class EditorconfigDocumentManager {

if (line.length !== trimmedLine.length) {
edits.push({
identifier: undefined!,
forceMoveMarkers: false,
range: new monaco.Range(i, trimmedLine.length + 1, i, line.length + 1),
text: ""
Expand Down Expand Up @@ -268,7 +267,6 @@ export class EditorconfigDocumentManager {

if ("" !== lineContent) {
return {
identifier: undefined!,
forceMoveMarkers: false,
range: new monaco.Range(lines, lineContent.length + 1, lines, lineContent.length + 1),
text: lineEnding
Expand Down
2 changes: 1 addition & 1 deletion packages/languages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@theia/core": "^0.3.8",
"@theia/output": "^0.3.8",
"@theia/process": "^0.3.8",
"vscode-base-languageclient": "^0.0.1-alpha.3",
"vscode-base-languageclient": "^0.0.1-alpha.5",
"vscode-languageserver-protocol": "^3.6.0"
},
"publishConfig": {
Expand Down
10 changes: 5 additions & 5 deletions packages/monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"@theia/markers": "^0.3.8",
"@theia/outline-view": "^0.3.8",
"@theia/workspace": "^0.3.8",
"monaco-css": "^1.3.3",
"monaco-html": "^1.3.2",
"monaco-json": "^1.3.2",
"monaco-languageclient": "^0.4.0",
"monaco-languages": "^0.9.0"
"monaco-css": "^2.0.1",
"monaco-html": "^2.0.2",
"monaco-json": "^2.0.1",
"monaco-languageclient": "0.6.3",
"monaco-languages": "^1.0.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export namespace MonacoCommands {
iconClasses.set(menuItem.command.id, menuItem.command.iconClass);
}
}
for (const command of monaco.editorCommonExtensions.CommonEditorRegistry.getEditorActions()) {
for (const command of monaco.editorExtensions.EditorExtensionsRegistry.getEditorActions()) {
const id = command.id;
if (!EXCLUDE_ACTIONS.has(id)) {
const label = command.label;
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-diff-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class MonacoDiffEditor extends MonacoEditor {
}

isActionSupported(id: string): boolean {
const action = this._diffEditor.getActions().find(a => a.id === id);
const action = this._diffEditor.getSupportedActions().find(a => a.id === id);
return !!action && action.isSupported() && super.isActionSupported(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class MonacoDiffNavigatorFactory {
const navigator = monaco.editor.createDiffNavigator(editor, options);
const ensureInitialized = (fwd: boolean) => {
if (navigator.nextIdx < -1) {
navigator.initIdx(fwd);
navigator._initIdx(fwd);
}
};
return <DiffNavigator>{
Expand Down
10 changes: 6 additions & 4 deletions packages/monaco/src/browser/monaco-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class MonacoEditor implements TextEditor, IEditorReference {
protected create(options?: IEditorConstructionOptions, override?: monaco.editor.IEditorOverrideServices): Disposable {
return this.editor = monaco.editor.create(this.node, {
...options,
lightbulb: { enabled: true },
fixedOverflowWidgets: true,
scrollbar: {
useShadows: false,
Expand Down Expand Up @@ -149,14 +150,14 @@ export class MonacoEditor implements TextEditor, IEditorReference {
return this.onSelectionChangedEmitter.event;
}

revealPosition(raw: Position, options: RevealPositionOptions = { vertical: 'center', horizontal: true }): void {
revealPosition(raw: Position, options: RevealPositionOptions = { vertical: 'center' }): void {
const position = this.p2m.asPosition(raw);
switch (options.vertical) {
case 'auto':
this.editor.revealPosition(position, false, options.horizontal);
this.editor.revealPosition(position);
break;
case 'center':
this.editor.revealPosition(position, true, options.horizontal);
this.editor.revealPositionInCenter(position);
break;
case 'centerIfOutsideViewport':
this.editor.revealPositionInCenterIfOutsideViewport(position);
Expand Down Expand Up @@ -204,7 +205,8 @@ export class MonacoEditor implements TextEditor, IEditorReference {
* `true` if the suggest widget is visible in the editor. Otherwise, `false`.
*/
isSuggestWidgetVisible(): boolean {
return this.editor.getContribution<SuggestController>('editor.contrib.suggestController')._widget.suggestWidgetVisible.get();
const widget = this.editor.getContribution<SuggestController>('editor.contrib.suggestController')._widget;
return widget ? widget.suggestWidgetVisible.get() : false;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions packages/monaco/src/browser/monaco-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function loadMonaco(vsRequire: any): Promise<void> {
return new Promise<void>(resolve => {
vsRequire(["vs/editor/editor.main"], () => {
vsRequire([
'vs/basic-languages/src/monaco.contribution',
'vs/basic-languages/monaco.contribution',
'vs/language/css/monaco.contribution',
'vs/language/html/monaco.contribution',
'vs/language/json/monaco.contribution',
Expand All @@ -45,7 +45,7 @@ export function loadMonaco(vsRequire: any): Promise<void> {
'vs/platform/keybinding/common/keybindingResolver',
'vs/platform/keybinding/common/usLayoutResolvedKeybinding',
'vs/base/common/keyCodes',
'vs/editor/common/editorCommonExtensions',
'vs/editor/browser/editorExtensions',
'vs/editor/standalone/browser/simpleServices',
'vs/editor/standalone/browser/standaloneServices',
'vs/base/parts/quickopen/common/quickOpen',
Expand All @@ -56,11 +56,11 @@ export function loadMonaco(vsRequire: any): Promise<void> {
'vs/base/common/platform',
'vs/editor/common/modes',
'vs/base/common/cancellation',
'vs/editor/contrib/suggest/browser/suggestController',
'vs/editor/contrib/find/common/findController',
'vs/editor/contrib/rename/browser/rename',
'vs/editor/contrib/suggest/suggestController',
'vs/editor/contrib/find/findController',
'vs/editor/contrib/rename/rename',
], (basic: any, css: any, html: any, json: any, commands: any, actions: any, registry: any, resolver: any, resolvedKeybinding: any,
keyCodes: any, editorCommonExtensions: any, simpleServices: any, standaloneServices: any, quickOpen: any, quickOpenWidget: any, quickOpenModel: any,
keyCodes: any, editorExtensions: any, simpleServices: any, standaloneServices: any, quickOpen: any, quickOpenWidget: any, quickOpenModel: any,
filters: any, styler: any, platform: any, modes: any, cancellation: any, suggestController: any, findController: any, rename: any) => {
const global: any = self;
global.monaco.commands = commands;
Expand All @@ -71,7 +71,7 @@ export function loadMonaco(vsRequire: any): Promise<void> {
global.monaco.filters = filters;
global.monaco.theme = styler;
global.monaco.platform = platform;
global.monaco.editorCommonExtensions = editorCommonExtensions;
global.monaco.editorExtensions = editorExtensions;
global.monaco.modes = modes;
global.monaco.cancellation = cancellation;
global.monaco.suggestController = suggestController;
Expand Down
2 changes: 0 additions & 2 deletions packages/monaco/src/browser/monaco-status-bar-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { injectable, inject } from 'inversify';
import { DisposableCollection } from '@theia/core';
import { FrontendApplicationContribution, FrontendApplication, StatusBar, StatusBarAlignment } from '@theia/core/lib/browser';
import { EditorCommands, EditorManager, EditorWidget } from '@theia/editor/lib/browser';
import { OutlineViewService } from '@theia/outline-view/lib/browser/outline-view-service';
import { MonacoEditor } from './monaco-editor';

@injectable()
Expand All @@ -18,7 +17,6 @@ export class MonacoStatusBarContribution implements FrontendApplicationContribut
protected readonly toDispose = new DisposableCollection();

constructor(
@inject(OutlineViewService) protected readonly outlineViewService: OutlineViewService,
@inject(EditorManager) protected readonly editorManager: EditorManager,
@inject(StatusBar) protected readonly statusBar: StatusBar
) { }
Expand Down
9 changes: 5 additions & 4 deletions packages/monaco/src/browser/monaco-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class MonacoWorkspace implements lang.Workspace {
identifier: undefined!,
forceMoveMarkers: false,
range: new monaco.Range(edit.range.startLineNumber, edit.range.startColumn, edit.range.endLineNumber, edit.range.endColumn),
text: edit.newText
text: edit.text
}));
// start a fresh operation
model.pushStackElement();
Expand All @@ -226,11 +226,12 @@ export class MonacoWorkspace implements lang.Workspace {
}

protected groupEdits(workspaceEdit: monaco.languages.WorkspaceEdit) {
const result = new Map<string, monaco.languages.IResourceEdit[]>();
const result = new Map<string, monaco.languages.TextEdit[]>();
for (const edit of workspaceEdit.edits) {
const uri = edit.resource.toString();
const resourceTextEdit = edit as monaco.languages.ResourceTextEdit;
const uri = resourceTextEdit.resource.toString();
const edits = result.get(uri) || [];
edits.push(edit);
edits.push(...resourceTextEdit.edits);
result.set(uri, edits);
}
return result;
Expand Down
33 changes: 23 additions & 10 deletions packages/monaco/src/typings/monaco/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2018 TypeFox and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

/// <reference types='monaco-editor-core/monaco'/>

declare module monaco.instantiation {
Expand All @@ -10,14 +17,18 @@ declare module monaco.editor {
export interface IDiffNavigator {
readonly ranges: IDiffRange[];
readonly nextIdx: number;
initIdx(fwd: boolean): void;
readonly revealFirst: boolean;
_initIdx(fwd: boolean): void;
}

export interface IDiffRange {
readonly range: Range;
}

export interface ICommonCodeEditor {
export interface IStandaloneCodeEditor extends CommonCodeEditor {
}

export interface CommonCodeEditor {
readonly _commandService: monaco.commands.ICommandService;
readonly _instantiationService: monaco.instantiation.IInstantiationService;
readonly _contributions: {
Expand Down Expand Up @@ -62,7 +73,7 @@ declare module monaco.editor {
}

export interface IEditorReference {
getControl(): monaco.editor.ICommonCodeEditor;
getControl(): monaco.editor.CommonCodeEditor;
}

export interface IEditorInput {
Expand Down Expand Up @@ -547,15 +558,15 @@ declare module monaco.filters {
export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching?: boolean): IMatch[] | undefined;
}

declare module monaco.editorCommonExtensions {
declare module monaco.editorExtensions {

export interface EditorAction {
id: string;
label: string;
alias: string;
}

export module CommonEditorRegistry {
export module EditorExtensionsRegistry {
export function getEditorActions(): EditorAction[];
}
}
Expand Down Expand Up @@ -621,6 +632,12 @@ declare module monaco.cancellation {

declare module monaco.suggestController {

export class SuggestWidget {
suggestWidgetVisible: {
get(): boolean;
};
}

export class SuggestController {

getId(): string;
Expand All @@ -629,11 +646,7 @@ declare module monaco.suggestController {
/**
* This is a hack. The widget has a `private` visibility in the VSCode source.
*/
readonly _widget: {
suggestWidgetVisible: {
get(): boolean;
};
};
readonly _widget: SuggestWidget | undefined;

}

Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@theia/core": "^0.3.8",
"@theia/languages": "^0.3.8",
"@theia/monaco": "^0.3.8",
"monaco-typescript": "^2.3.0",
"monaco-typescript": "^3.0.2",
"typescript-language-server": "^0.1.11"
},
"publishConfig": {
Expand Down
Loading