Skip to content

Commit

Permalink
Merge branch 'master' into electron-4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed May 13, 2019
2 parents 4fbe0d6 + d13f01b commit 291cc2d
Show file tree
Hide file tree
Showing 97 changed files with 2,505 additions and 1,851 deletions.
6 changes: 3 additions & 3 deletions extensions/javascript/syntaxes/JavaScript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/a4c4dafb226a4c1d037a52434aa1154d9dabad8b",
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3508c88a4ac6112934e0c34de7942c67682b2321",
"name": "JavaScript (with React support)",
"scopeName": "source.js",
"patterns": [
Expand Down Expand Up @@ -2416,7 +2416,7 @@
"patterns": [
{
"begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bif\\s*(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))\\s*(?!\\{))",
"end": "(?=;|$)",
"end": "(?=;|$|\\})",
"patterns": [
{
"include": "#comment"
Expand Down Expand Up @@ -4529,7 +4529,7 @@
},
{
"name": "string.regexp.js",
"begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"begin": "((?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)|((?<=^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case))\\s*)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/a4c4dafb226a4c1d037a52434aa1154d9dabad8b",
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3508c88a4ac6112934e0c34de7942c67682b2321",
"name": "JavaScript (with React support)",
"scopeName": "source.js.jsx",
"patterns": [
Expand Down Expand Up @@ -2416,7 +2416,7 @@
"patterns": [
{
"begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bif\\s*(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))\\s*(?!\\{))",
"end": "(?=;|$)",
"end": "(?=;|$|\\})",
"patterns": [
{
"include": "#comment"
Expand Down Expand Up @@ -4529,7 +4529,7 @@
},
{
"name": "string.regexp.js.jsx",
"begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"begin": "((?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)|((?<=^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case))\\s*)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.js.jsx"
Expand Down
25 changes: 21 additions & 4 deletions extensions/markdown-language-features/src/features/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ interface PreviewStyleLoadErrorMessage extends WebviewMessage {
};
}

export class PreviewDocumentVersion {
public constructor(
public readonly resource: vscode.Uri,
public readonly version: number,
) { }

public equals(other: PreviewDocumentVersion): boolean {
return this.resource.fsPath === other.resource.fsPath
&& this.version === other.version;
}
}

export class MarkdownPreview extends Disposable {

public static viewType = 'markdown.preview';
Expand All @@ -71,7 +83,7 @@ export class MarkdownPreview extends Disposable {
private throttleTimer: any;
private line: number | undefined = undefined;
private firstUpdate = true;
private currentVersion?: { resource: vscode.Uri, version: number };
private currentVersion?: PreviewDocumentVersion;
private forceUpdate = false;
private isScrolling = false;
private _disposed: boolean = false;
Expand Down Expand Up @@ -389,18 +401,23 @@ export class MarkdownPreview extends Disposable {
return;
}

if (!this.forceUpdate && this.currentVersion && this.currentVersion.resource.fsPath === resource.fsPath && this.currentVersion.version === document.version) {
const pendingVersion = new PreviewDocumentVersion(resource, document.version);
if (!this.forceUpdate && this.currentVersion && this.currentVersion.equals(pendingVersion)) {
if (this.line) {
this.updateForView(resource, this.line);
}
return;
}
this.forceUpdate = false;

this.currentVersion = { resource, version: document.version };
this.currentVersion = pendingVersion;
if (this._resource === resource) {
const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state);
this.setContent(content);
// Another call to `doUpdate` may have happened.
// Make sure we are still updating for the correct document
if (this.currentVersion && this.currentVersion.equals(pendingVersion)) {
this.setContent(content);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/typescript-basics/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"git": {
"name": "TypeScript-TmLanguage",
"repositoryUrl": "https://github.com/Microsoft/TypeScript-TmLanguage",
"commitHash": "a4c4dafb226a4c1d037a52434aa1154d9dabad8b"
"commitHash": "3508c88a4ac6112934e0c34de7942c67682b2321"
}
},
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/a4c4dafb226a4c1d037a52434aa1154d9dabad8b",
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3508c88a4ac6112934e0c34de7942c67682b2321",
"name": "TypeScript",
"scopeName": "source.ts",
"patterns": [
Expand Down Expand Up @@ -2413,7 +2413,7 @@
"patterns": [
{
"begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bif\\s*(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))\\s*(?!\\{))",
"end": "(?=;|$)",
"end": "(?=;|$|\\})",
"patterns": [
{
"include": "#comment"
Expand Down Expand Up @@ -4578,7 +4578,7 @@
},
{
"name": "string.regexp.ts",
"begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"begin": "((?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)|((?<=^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case))\\s*)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/a4c4dafb226a4c1d037a52434aa1154d9dabad8b",
"version": "https://github.com/Microsoft/TypeScript-TmLanguage/commit/3508c88a4ac6112934e0c34de7942c67682b2321",
"name": "TypeScriptReact",
"scopeName": "source.tsx",
"patterns": [
Expand Down Expand Up @@ -2416,7 +2416,7 @@
"patterns": [
{
"begin": "(?<![_$[:alnum:]])(?:(?<=\\.\\.\\.)|(?<!\\.))(?=\\bif\\s*(\\(([^\\(\\)]|(\\([^\\(\\)]*\\)))*\\))\\s*(?!\\{))",
"end": "(?=;|$)",
"end": "(?=;|$|\\})",
"patterns": [
{
"include": "#comment"
Expand Down Expand Up @@ -4529,7 +4529,7 @@
},
{
"name": "string.regexp.tsx",
"begin": "(?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"begin": "((?<![_$[:alnum:])\\]]|\\+\\+|--|}|\\*\\/)|((?<=^return|[^\\._$[:alnum:]]return|^case|[^\\._$[:alnum:]]case))\\s*)\\/(?![\\/*])(?=(?:[^\\/\\\\\\[]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\])+\\/[gimsuy]*(?!\\s*[a-zA-Z0-9_$]))",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.tsx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as assert from 'assert';
import 'mocha';
import * as vscode from 'vscode';
import { snippetForFunctionCall } from "../utils/snippetForFunctionCall";
import { snippetForFunctionCall } from '../utils/snippetForFunctionCall';

suite('typescript function call snippets', () => {
test('Should use label as function name', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,30 @@ suite('workspace-namespace', () => {
});
});

test('events: onDidSaveTextDocument fires even for non dirty file when saved', () => {
return createRandomFile().then(file => {
let disposables: vscode.Disposable[] = [];

let onDidSaveTextDocument = false;
disposables.push(vscode.workspace.onDidSaveTextDocument(e => {
assert.ok(pathEquals(e.uri.fsPath, file.fsPath));
onDidSaveTextDocument = true;
}));

return vscode.workspace.openTextDocument(file).then(doc => {
return vscode.window.showTextDocument(doc).then(() => {
return vscode.commands.executeCommand('workbench.action.files.save').then(() => {
assert.ok(onDidSaveTextDocument);

disposeAll(disposables);

return deleteFile(file);
});
});
});
});
});

test('openTextDocument, with selection', function () {
return createRandomFile('foo\nbar\nbar').then(file => {
return vscode.workspace.openTextDocument(file).then(doc => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-oss-dev",
"version": "1.34.0",
"version": "1.35.0",
"distro": "b9fb31b7caa6d9f506aa458342ab71183bc90b52",
"author": {
"name": "Microsoft Corporation"
Expand Down
2 changes: 2 additions & 0 deletions src/typings/vscode-xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,5 +813,7 @@ declare module 'vscode-xterm' {
* @return Whether a result was found.
*/
findPrevious(term: string, findOptions: ISearchOptions): boolean;

addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable;
}
}
11 changes: 8 additions & 3 deletions src/vs/base/common/mime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ function guessMimeTypeByFirstline(firstLine: string): string | null {
}

if (firstLine.length > 0) {
for (const association of registeredAssociations) {

// We want to prioritize associations based on the order they are registered so that the last registered
// association wins over all other. This is for https://github.com/Microsoft/vscode/issues/20074
for (let i = registeredAssociations.length - 1; i >= 0; i--) {
const association = registeredAssociations[i];
if (!association.firstline) {
continue;
}
Expand Down Expand Up @@ -230,10 +234,11 @@ export function isUnspecific(mime: string[] | string): boolean {
* 2. Otherwise, if there are other extensions, suggest the first one.
* 3. Otherwise, suggest the prefix.
*/
export function suggestFilename(langId: string | null, prefix: string): string {
export function suggestFilename(mode: string | undefined, prefix: string): string {
const extensions = registeredAssociations
.filter(assoc => !assoc.userConfigured && assoc.extension && assoc.id === langId)
.filter(assoc => !assoc.userConfigured && assoc.extension && assoc.id === mode)
.map(assoc => assoc.extension);

const extensionsWithDotFirst = coalesce(extensions)
.filter(assoc => startsWith(assoc, '.'));

Expand Down
6 changes: 6 additions & 0 deletions src/vs/base/test/common/mime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as assert from 'assert';
import { guessMimeTypes, registerTextMime, suggestFilename } from 'vs/base/common/mime';

suite('Mime', () => {

test('Dynamically Register Text Mime', () => {
let guess = guessMimeTypes('foo.monaco');
assert.deepEqual(guess, ['application/unknown']);
Expand Down Expand Up @@ -56,6 +57,11 @@ suite('Mime', () => {
registerTextMime({ id: 'docker', filepattern: 'dockerfile*', mime: 'text/looser' });
guess = guessMimeTypes('dockerfile');
assert.deepEqual(guess, ['text/winner', 'text/plain']);

registerTextMime({ id: 'azure-looser', mime: 'text/azure-looser', firstline: /azure/ });
registerTextMime({ id: 'azure-winner', mime: 'text/azure-winner', firstline: /azure/ });
guess = guessMimeTypes('azure', 'azure');
assert.deepEqual(guess, ['text/azure-winner', 'text/plain']);
});

test('Specificity priority 1', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/code/electron-browser/workbench/workbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ function showPartsSplash(configuration) {
const style = document.createElement('style');
style.className = 'initialShellColors';
document.head.appendChild(style);
document.body.className = `monaco-shell ${baseTheme}`;
style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`;
document.body.className = baseTheme;
style.innerHTML = `body { background-color: ${shellBackground}; color: ${shellForeground}; }`;

if (data && data.layoutInfo) {
// restore parts if possible (we might not always store layout info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
</head>
<body class="monaco-shell vs-dark" aria-label="">
<body class="vs-dark" aria-label="">
</body>

<!-- Startup via workbench.nodeless.js -->
Expand Down
62 changes: 40 additions & 22 deletions src/vs/code/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import { IStateService } from 'vs/platform/state/common/state';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage } from 'electron';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display } from 'electron';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
Expand Down Expand Up @@ -740,32 +740,30 @@ export class CodeWindow extends Disposable implements ICodeWindow {

// Single Monitor: be strict about x/y positioning
if (displays.length === 1) {
const displayBounds = displays[0].bounds;

// Careful with maximized: in that mode x/y can well be negative!
if (state.mode !== WindowMode.Maximized && displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) {
if (state.x < displayBounds.x) {
state.x = displayBounds.x; // prevent window from falling out of the screen to the left
const displayWorkingArea = this.getWorkingArea(displays[0]);
if (state.mode !== WindowMode.Maximized && displayWorkingArea) {
if (state.x < displayWorkingArea.x) {
state.x = displayWorkingArea.x; // prevent window from falling out of the screen to the left
}

if (state.y < displayBounds.y) {
state.y = displayBounds.y; // prevent window from falling out of the screen to the top
if (state.y < displayWorkingArea.y) {
state.y = displayWorkingArea.y; // prevent window from falling out of the screen to the top
}

if (state.x > (displayBounds.x + displayBounds.width)) {
state.x = displayBounds.x; // prevent window from falling out of the screen to the right
if (state.x > (displayWorkingArea.x + displayWorkingArea.width)) {
state.x = displayWorkingArea.x; // prevent window from falling out of the screen to the right
}

if (state.y > (displayBounds.y + displayBounds.height)) {
state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom
if (state.y > (displayWorkingArea.y + displayWorkingArea.height)) {
state.y = displayWorkingArea.y; // prevent window from falling out of the screen to the bottom
}

if (state.width > displayBounds.width) {
state.width = displayBounds.width; // prevent window from exceeding display bounds width
if (state.width > displayWorkingArea.width) {
state.width = displayWorkingArea.width; // prevent window from exceeding display bounds width
}

if (state.height > displayBounds.height) {
state.height = displayBounds.height; // prevent window from exceeding display bounds height
if (state.height > displayWorkingArea.height) {
state.height = displayWorkingArea.height; // prevent window from exceeding display bounds height
}
}

Expand All @@ -791,12 +789,14 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// Multi Monitor (non-fullscreen): be less strict because metrics can be crazy
const bounds = { x: state.x, y: state.y, width: state.width, height: state.height };
const display = screen.getDisplayMatching(bounds);
const displayWorkingArea = this.getWorkingArea(display);
if (
display && // we have a display matching the desired bounds
bounds.x < display.bounds.x + display.bounds.width && // prevent window from falling out of the screen to the right
bounds.y < display.bounds.y + display.bounds.height && // prevent window from falling out of the screen to the bottom
bounds.x + bounds.width > display.bounds.x && // prevent window from falling out of the screen to the left
bounds.y + bounds.height > display.bounds.y // prevent window from falling out of the scree nto the top
display && // we have a display matching the desired bounds
displayWorkingArea && // we have valid working area bounds
bounds.x < displayWorkingArea.x + displayWorkingArea.width && // prevent window from falling out of the screen to the right
bounds.y < displayWorkingArea.y + displayWorkingArea.height && // prevent window from falling out of the screen to the bottom
bounds.x + bounds.width > displayWorkingArea.x && // prevent window from falling out of the screen to the left
bounds.y + bounds.height > displayWorkingArea.y // prevent window from falling out of the scree nto the top
) {
if (state.mode === WindowMode.Maximized) {
const defaults = defaultWindowState(WindowMode.Maximized); // when maximized, make sure we have good values when the user restores the window
Expand All @@ -812,6 +812,24 @@ export class CodeWindow extends Disposable implements ICodeWindow {
return null;
}

private getWorkingArea(display: Display): Rectangle | undefined {

// Prefer the working area of the display to account for taskbars on the
// desktop being positioned somewhere (https://github.com/Microsoft/vscode/issues/50830).
//
// Linux X11 sessions sometimes report wrong display bounds, so we validate
// the reported sizes are positive.
if (display.workArea.width > 0 && display.workArea.height > 0) {
return display.workArea;
}

if (display.bounds.width > 0 && display.bounds.height > 0) {
return display.bounds;
}

return undefined;
}

getBounds(): Electron.Rectangle {
const pos = this._win.getPosition();
const dimension = this._win.getSize();
Expand Down
Loading

0 comments on commit 291cc2d

Please sign in to comment.