Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -2,4 +2,6 @@ out/test/**
src/**
.gitignore
tsconfig.json
InstallSsmsMin.bat
InstallSsmsMin.bat
cgmanifest.json
.vscode

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": { "vscode": "*" },
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js mmims/language-batchfile grammars/batchfile.cson ./syntaxes/batchfile.tmLanguage.json"

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "^1.0.0"
},
@@ -108,6 +109,6 @@
]
},
"devDependencies": {
"@types/node": "^10.12.21"
"@types/node": "^10.14.8"
}
}

View File

@@ -5,6 +5,7 @@
"type": "object",
"definitions": {
"devContainerCommon": {
"type": "object",
"properties": {
"name": {
"type": "string",
@@ -18,11 +19,14 @@
}
},
"settings": {
"type": "object",
"$ref": "vscode://schemas/settings/machine",
"description": "Machine specific settings that should be copied into the container."
},
"postCreateCommand": {
"type": ["string", "array"],
"type": [
"string",
"array"
],
"description": "A command to run after creating the container. If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell.",
"items": {
"type": "string"
@@ -35,12 +39,20 @@
}
},
"nonComposeBase": {
"type": "object",
"properties": {
"appPort": {
"type": ["integer", "string", "array"],
"type": [
"integer",
"string",
"array"
],
"description": "Application ports that are exposed by the container. This can be a single port or an array of ports. Each port can be a number or a string. A number is mapped to the same port on the host. A string is passed to Docker unchanged and can be used to map ports differently, e.g. \"8000:8010\".",
"items": {
"type": ["integer", "string"]
"type": [
"integer",
"string"
]
}
},
"runArgs": {
@@ -52,7 +64,10 @@
},
"shutdownAction": {
"type": "string",
"enum": ["none", "stopContainer"],
"enum": [
"none",
"stopContainer"
],
"description": "Action to take when VS Code is shutting down. The default is to stop the container."
},
"overrideCommand": {
@@ -70,6 +85,7 @@
}
},
"dockerFileContainer": {
"type": "object",
"properties": {
"dockerFile": {
"type": "string",
@@ -80,21 +96,30 @@
"description": "The location of the context folder for building the Docker image. The path is relative to the folder containing the `devcontainer.json` file."
}
},
"required": ["dockerFile"]
"required": [
"dockerFile"
]
},
"imageContainer": {
"type": "object",
"properties": {
"image": {
"type": "string",
"description": "The docker image that will be used to create the container."
}
},
"required": ["image"]
"required": [
"image"
]
},
"composeContainer": {
"type": "object",
"properties": {
"dockerComposeFile": {
"type": ["string", "array"],
"type": [
"string",
"array"
],
"description": "The name of the docker-compose file(s) used to start the services.",
"items": {
"type": "string"
@@ -110,11 +135,18 @@
},
"shutdownAction": {
"type": "string",
"enum": ["none", "stopCompose"],
"enum": [
"none",
"stopCompose"
],
"description": "Action to take when VS Code is shutting down. The default is to stop the containers."
}
},
"required": ["dockerComposeFile", "service", "workspaceFolder"]
"required": [
"dockerComposeFile",
"service",
"workspaceFolder"
]
}
},
"allOf": [

View File

@@ -2,10 +2,10 @@
# yarn lockfile v1
"@types/node@^10.12.21":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
integrity sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
jsonc-parser@2.0.2:
version "2.0.2"

View File

@@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'mocha';
import * as assert from 'assert';
import Uri from 'vscode-uri';
import { resolve } from 'path';
import { TextDocument, DocumentLink } from 'vscode-languageserver-types';
import { WorkspaceFolder } from 'vscode-languageserver-protocol';
import { getCSSLanguageService } from 'vscode-css-languageservice';
import { getDocumentContext } from '../utils/documentContext';
export interface ItemDescription {
offset: number;
value: string;
target: string;
}
suite('Links', () => {
const cssLanguageService = getCSSLanguageService();
let assertLink = function (links: DocumentLink[], expected: ItemDescription, document: TextDocument) {
let matches = links.filter(link => {
return document.offsetAt(link.range.start) === expected.offset;
});
assert.equal(matches.length, 1, `${expected.offset} should only existing once: Actual: ${links.map(l => document.offsetAt(l.range.start)).join(', ')}`);
let match = matches[0];
assert.equal(document.getText(match.range), expected.value);
assert.equal(match.target, expected.target);
};
function assertLinks(value: string, expected: ItemDescription[], testUri: string, workspaceFolders?: WorkspaceFolder[], lang: string = 'css'): void {
const offset = value.indexOf('|');
value = value.substr(0, offset) + value.substr(offset + 1);
const document = TextDocument.create(testUri, lang, 0, value);
if (!workspaceFolders) {
workspaceFolders = [{ name: 'x', uri: testUri.substr(0, testUri.lastIndexOf('/')) }];
}
const context = getDocumentContext(testUri, workspaceFolders);
const stylesheet = cssLanguageService.parseStylesheet(document);
let links = cssLanguageService.findDocumentLinks(document, stylesheet, context)!;
assert.equal(links.length, expected.length);
for (let item of expected) {
assertLink(links, item, document);
}
}
function getTestResource(path: string) {
return Uri.file(resolve(__dirname, '../../test/linksTestFixtures', path)).toString();
}
test('url links', function () {
let testUri = getTestResource('about.css');
let folders = [{ name: 'x', uri: getTestResource('') }];
assertLinks('html { background-image: url("hello.html|")',
[{ offset: 29, value: '"hello.html"', target: getTestResource('hello.html') }], testUri, folders
);
});
test('node module resolving', function () {
let testUri = getTestResource('about.css');
let folders = [{ name: 'x', uri: getTestResource('') }];
assertLinks('html { background-image: url("~foo/hello.html|")',
[{ offset: 29, value: '"~foo/hello.html"', target: getTestResource('node_modules/foo/hello.html') }], testUri, folders
);
});
});

View File

@@ -0,0 +1 @@
!/node_modules

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": { "vscode": "*" },
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js moby/moby contrib/syntax/textmate/Docker.tmbundle/Syntaxes/Dockerfile.tmLanguage ./syntaxes/docker.tmLanguage.json"

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "^1.4.0"
},
@@ -53,6 +54,6 @@
},
"devDependencies": {
"@types/markdown-it": "0.0.2",
"@types/node": "^10.12.21"
"@types/node": "^10.14.8"
}
}

View File

@@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.2.tgz#5d9ad19e6e6508cdd2f2596df86fd0aade598660"
integrity sha1-XZrRnm5lCM3S8llt+G/Qqt5ZhmA=
"@types/node@^10.12.21":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
integrity sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
"@types/node@^6.0.46":
version "6.0.78"

View File

@@ -0,0 +1,8 @@
src/**
test/**
out/**
tsconfig.json
build/**
extension.webpack.config.js
cgmanifest.json
yarn.lock

View File

@@ -0,0 +1,7 @@
# Git UI integration for Visual Studio Code
**Notice:** This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled.
## Features
See [Git support in VS Code](https://code.visualstudio.com/docs/editor/versioncontrol#_git-support) to learn about the features of this extension.

View File

@@ -0,0 +1,4 @@
{
"registrations": [],
"version": 1
}

View File

@@ -0,0 +1,17 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
entry: {
main: './src/main.ts'
}
});

View File

@@ -0,0 +1,28 @@
{
"name": "git-ui",
"displayName": "%displayName%",
"description": "%description%",
"publisher": "vscode",
"version": "1.0.0",
"engines": {
"vscode": "^1.5.0"
},
"extensionKind": "ui",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"enableProposedApi": true,
"categories": [
"Other"
],
"activationEvents": [
"onCommand:git.credential"
],
"main": "./out/main",
"icon": "resources/icons/git.png",
"scripts": {
"compile": "gulp compile-extension:git-ui",
"watch": "gulp watch-extension:git-ui"
},
"devDependencies": {
"@types/node": "^10.14.8"
}
}

View File

@@ -0,0 +1,4 @@
{
"displayName": "Git UI",
"description": "Git SCM UI Integration"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,57 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext, commands } from 'vscode';
import * as cp from 'child_process';
export async function deactivate(): Promise<any> {
}
export async function activate(context: ExtensionContext): Promise<void> {
context.subscriptions.push(commands.registerCommand('git.credential', async (data: any) => {
try {
const { stdout, stderr } = await exec(`git credential ${data.command}`, {
stdin: data.stdin,
env: Object.assign(process.env, { GIT_TERMINAL_PROMPT: '0' })
});
return { stdout, stderr, code: 0 };
} catch ({ stdout, stderr, error }) {
const code = error.code || 0;
if (stderr.indexOf('terminal prompts disabled') !== -1) {
stderr = '';
}
return { stdout, stderr, code };
}
}));
}
export interface ExecResult {
error: Error | null;
stdout: string;
stderr: string;
}
export function exec(command: string, options: cp.ExecOptions & { stdin?: string } = {}) {
return new Promise<ExecResult>((resolve, reject) => {
const child = cp.exec(command, options, (error, stdout, stderr) => {
(error ? reject : resolve)({ error, stdout, stderr });
});
if (options.stdin) {
child.stdin.write(options.stdin, (err: any) => {
if (err) {
reject(err);
return;
}
child.stdin.end((err: any) => {
if (err) {
reject(err);
}
});
});
}
});
}

View File

@@ -0,0 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
/// <reference types='@types/node'/>

View File

@@ -0,0 +1,13 @@
{
"extends": "../shared.tsconfig.json",
"compilerOptions": {
"outDir": "./out",
"experimentalDecorators": true,
"typeRoots": [
"./node_modules/@types"
]
},
"include": [
"src/**/*"
]
}

View File

@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==

View File

@@ -6,7 +6,7 @@
"git": {
"name": "textmate/git.tmbundle",
"repositoryUrl": "https://github.com/textmate/git.tmbundle",
"commitHash": "3f6ad2138200db14b57a090ecb2d2e733275ca3e"
"commitHash": "5870cf3f8abad3a6637bdf69250b5d2ded427dc4"
}
},
"licenseDetail": [

View File

@@ -3,6 +3,7 @@
"displayName": "%displayName%",
"description": "%description%",
"publisher": "vscode",
"license": "MIT",
"version": "1.0.0",
"engines": {
"vscode": "^1.5.0"
@@ -20,7 +21,8 @@
"scripts": {
"compile": "gulp compile-extension:git",
"watch": "gulp watch-extension:git",
"update-grammar": "node ./build/update-grammars.js"
"update-grammar": "node ./build/update-grammars.js",
"test": "mocha"
},
"contributes": {
"commands": [
@@ -80,8 +82,8 @@
"title": "%command.openFile%",
"category": "Git",
"icon": {
"light": "resources/icons/light/open-file-mono.svg",
"dark": "resources/icons/dark/open-file-mono.svg"
"light": "resources/icons/light/open-file.svg",
"dark": "resources/icons/dark/open-file.svg"
}
},
{
@@ -317,12 +319,12 @@
},
{
"command": "git.pushWithTags",
"title": "%command.pushWithTags%",
"title": "%command.pushFollowTags%",
"category": "Git"
},
{
"command": "git.pushWithTagsForce",
"title": "%command.pushWithTagsForce%",
"title": "%command.pushFollowTagsForce%",
"category": "Git"
},
{
@@ -1458,13 +1460,14 @@
"jschardet": "^1.6.0",
"vscode-extension-telemetry": "0.1.1",
"vscode-nls": "^4.0.0",
"vscode-uri": "^2.0.0",
"which": "^1.3.0"
},
"devDependencies": {
"@types/byline": "4.2.31",
"@types/file-type": "^5.2.1",
"@types/mocha": "2.2.43",
"@types/node": "^10.12.21",
"@types/node": "^10.14.8",
"@types/which": "^1.0.28",
"mocha": "^3.2.0"
}

View File

@@ -47,8 +47,8 @@
"command.pushForce": "Push (Force)",
"command.pushTo": "Push to...",
"command.pushToForce": "Push to... (Force)",
"command.pushWithTags": "Push With Tags",
"command.pushWithTagsForce": "Push With Tags (Force)",
"command.pushFollowTags": "Push (Follow Tags)",
"command.pushFollowTagsForce": "Push (Follow Tags, Force)",
"command.addRemote": "Add Remote",
"command.removeRemote": "Remove Remote",
"command.sync": "Sync",

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="-2 -2 16 16" enable-background="new -2 -2 16 16"><polygon fill="#C5C5C5" points="9,0 4.5,9 3,6 0,6 3,12 6,12 12,0"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 3.76345L5.80687 11.9351L5.08584 11.8927L1 7.29614L1.76345 6.61752L5.50997 10.8324L14.3214 3L15 3.76345Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 278 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="-0.994 0 16 16" enable-background="new -0.994 0 16 16"><path fill="#C5C5C5" d="M13 6c0 1.461-.636 2.846-1.746 3.797l-5.584 4.951-1.324-1.496 5.595-4.962c.678-.582 1.061-1.413 1.061-2.29 0-1.654-1.345-3-2.997-3-.71 0-1.399.253-1.938.713l-1.521 1.287h2.448l-1.998 2h-3.996v-4l1.998-2v2.692l1.775-1.504c.899-.766 2.047-1.188 3.232-1.188 2.754 0 4.995 2.243 4.995 5z"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 2V5.5L4 6H7.5V5H4.979L5.92041 4.05869C7.30762 2.67157 9.55664 2.67157 10.9434 4.05869C12.3306 5.4458 12.3306 7.69476 10.9434 9.08188L5.74561 14.2799L6.46582 14.9999L11.6636 9.80194C13.4482 8.01715 13.4482 5.12341 11.6636 3.33859C9.87891 1.5538 6.98486 1.5538 5.2002 3.33859L4.5 4.03882V2H3.5Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 468 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path d="M27.459 14.902l-10.439-10.439c-.296-.294-.672-.452-1.089-.452-.417 0-.793.157-1.089.452l-2.248 2.247 2.549 2.549c.249-.112.522-.177.813-.177 1.106 0 2.002.896 2.002 2.002 0 .291-.064.565-.176.814l2.311 2.336c.25-.111.633-.234.923-.234 1.106 0 2 .911 2 2.016s-.894 1.969-2 1.969c-1.105-.001-2.016-.751-2.016-1.985 0-.28.016-.462.119-.704l-2.373-2.374-.023.007v6.274c.747.295 1.277 1.026 1.277 1.875 0 1.105-.878 2.016-1.984 2.016-1.104 0-2.031-.926-2.031-2.031 0-.846.535-1.564 1.28-1.857l.001-6.25c-.762-.282-1.309-1.009-1.309-1.871 0-.28.059-.546.162-.788l-2.555-2.557-7.115 7.114c-.599.601-.601 1.576.001 2.178l10.44 10.518c.296.295.671.45 1.089.45.415 0 .796-.159 1.089-.45l10.391-10.471c.601-.599.599-1.576 0-2.177z" fill="#fff"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 7V8H8V14H7V8H1V7H7V1H8V7H14Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 163 B

View File

@@ -1 +1,3 @@
<svg fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="m6 12h-1c-.27-.02-.48-.11-.69-.31s-.3-.42-.31-.69v-6.28c.59-.34 1-.98 1-1.72 0-1.11-.89-2-2-2s-2 .89-2 2c0 .73.41 1.38 1 1.72v6.28c.03.78.34 1.47.94 2.06s1.28.91 2.06.94c0 0 1.02 0 1 0v2l3-3-3-3zm-3-10.2c.66 0 1.2.55 1.2 1.2s-.55 1.2-1.2 1.2-1.2-.55-1.2-1.2.55-1.2 1.2-1.2zm11 9.48c0-1.73 0-6.28 0-6.28-.03-.78-.34-1.47-.94-2.06s-1.28-.91-2.06-.94h-1v-2l-3 3 3 3v-2h1c.27.02.48.11.69.31s.3.42.31.69v6.28c-.59.34-1 .98-1 1.72 0 1.11.89 2 2 2s2-.89 2-2c0-.73-.41-1.38-1-1.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2s.55-1.2 1.2-1.2 1.2.55 1.2 1.2-.55 1.2-1.2 1.2z" fill="#c5c5c5" fill-rule="evenodd"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.88465 1.69445L8.57246 3H11.346C11.5656 3 11.783 3.04327 11.9858 3.12734C12.1886 3.2114 12.3729 3.33461 12.5281 3.48993C12.6833 3.64525 12.8063 3.82963 12.8902 4.03253C12.9741 4.23543 13.0172 4.45287 13.017 4.67243L12.517 4.672H13.017V4.67243V10.4539C13.8823 10.6794 14.521 11.4661 14.521 12.402C14.521 13.5138 13.6198 14.415 12.508 14.415C11.3963 14.415 10.495 13.5138 10.495 12.402C10.495 11.4596 11.1426 10.6685 12.017 10.4493V4.672V4.67158C12.0171 4.58341 11.9998 4.4961 11.9661 4.41462C11.9324 4.33314 11.883 4.25911 11.8207 4.19674C11.7584 4.13437 11.6844 4.08489 11.6029 4.05114C11.5215 4.01738 11.4342 4 11.346 4H8.53857L9.83833 5.34332L9.11967 6.03868L7.00067 3.84868L7.00735 3.14655L9.17935 0.98555L9.88465 1.69445ZM11.495 12.402C11.495 11.8425 11.9485 11.389 12.508 11.389C13.0675 11.389 13.521 11.8425 13.521 12.402C13.521 12.9615 13.0675 13.415 12.508 13.415C11.9485 13.415 11.495 12.9615 11.495 12.402ZM2.499 3.513C2.499 2.95354 2.95254 2.5 3.512 2.5C4.07147 2.5 4.525 2.95354 4.525 3.513C4.525 4.07247 4.07147 4.526 3.512 4.526C2.95254 4.526 2.499 4.07247 2.499 3.513ZM3.512 1.5C2.40025 1.5 1.499 2.40125 1.499 3.513C1.499 4.44783 2.13622 5.23382 3 5.46031V11.307C3 11.7502 3.17605 12.1752 3.48942 12.4886C3.8028 12.802 4.22782 12.978 4.671 12.978H7.44813L6.13543 14.2835L6.84057 14.9925L9.01257 12.8325L9.01941 12.1304L6.90041 9.93939L6.18159 10.6346L7.48086 11.978H4.671C4.49304 11.978 4.32237 11.9073 4.19653 11.7815C4.07069 11.6556 4 11.485 4 11.307V5.46645C4.87595 5.24833 5.525 4.45646 5.525 3.513C5.525 2.40125 4.62375 1.5 3.512 1.5Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 720 B

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#C5C5C5" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#C5C5C5" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>

Before

Width:  |  Height:  |  Size: 262 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#C5C5C5" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#75BEFF" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.06065 3.85356L5.91421 6L5.2071 5.29289L6.49999 4H3.5C3.10218 4 2.72064 4.15804 2.43934 4.43934C2.15804 4.72065 2 5.10218 2 5.5C2 5.89783 2.15804 6.27936 2.43934 6.56066C2.72064 6.84197 3.10218 7 3.5 7H4V8H3.5C2.83696 8 2.20107 7.73661 1.73223 7.26777C1.26339 6.79893 1 6.16305 1 5.5C1 4.83696 1.26339 4.20108 1.73223 3.73224C2.20107 3.2634 2.83696 3 3.5 3H6.49999L6.49999 3H6.49996L6 2.50004V2.50001L5.2071 1.70711L5.91421 1L8.06065 3.14645L8.06065 3.85356ZM5 6.50003L5.91421 7.41424L6 7.32845V14H14V7H10V3H9.06065V2.73227L8.32838 2H11.2L11.5 2.1L14.9 5.6L15 6V14.5L14.5 15H5.5L5 14.5V9.00003V6.50003ZM11 3V6H13.9032L11 3Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 796 B

View File

@@ -1 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#2D2D30"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#C5C5C5"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.56253 2.51577C3.46348 3.4501 2 5.55414 2 7.99999C2 11.3137 4.68629 14 8 14C11.3137 14 14 11.3137 14 7.99999C14 5.32519 12.2497 3.05919 9.83199 2.28482L9.52968 3.23832C11.5429 3.88454 13 5.7721 13 7.99999C13 10.7614 10.7614 13 8 13C5.23858 13 3 10.7614 3 7.99999C3 6.31104 3.83742 4.81767 5.11969 3.91245L5.56253 2.51577Z" fill="#C5C5C5"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 3H2V2H5.5L6 2.5V6H5V3Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 986 B

After

Width:  |  Height:  |  Size: 587 B

View File

@@ -1 +1,3 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><title>Layer 1</title><rect height="11" width="3" y="3" x="7" fill="#C5C5C5"/><rect height="3" width="11" y="7" x="3" fill="#C5C5C5"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 7V8H8V14H7V8H1V7H7V1H8V7H14Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 163 B

View File

@@ -1 +1,3 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><title>Layer 1</title><rect height="3" width="11" y="7" x="3" fill="#C5C5C5"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 8H1V7H15V8Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 146 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="-2 -2 16 16" enable-background="new -2 -2 16 16"><polygon fill="#424242" points="9,0 4.5,9 3,6 0,6 3,12 6,12 12,0"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M15 3.76345L5.80687 11.9351L5.08584 11.8927L1 7.29614L1.76345 6.61752L5.50997 10.8324L14.3214 3L15 3.76345Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 278 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="-0.994 0 16 16" enable-background="new -0.994 0 16 16"><path fill="#424242" d="M13 6c0 1.461-.636 2.846-1.746 3.797l-5.584 4.951-1.324-1.496 5.595-4.962c.678-.582 1.061-1.413 1.061-2.29 0-1.654-1.345-3-2.997-3-.71 0-1.399.253-1.938.713l-1.521 1.287h2.448l-1.998 2h-3.996v-4l1.998-2v2.692l1.775-1.504c.899-.766 2.047-1.188 3.232-1.188 2.754 0 4.995 2.243 4.995 5z"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 2V5.5L4 6H7.5V5H4.979L5.92041 4.05869C7.30762 2.67157 9.55664 2.67157 10.9434 4.05869C12.3306 5.4458 12.3306 7.69476 10.9434 9.08188L5.74561 14.2799L6.46582 14.9999L11.6636 9.80194C13.4482 8.01715 13.4482 5.12341 11.6636 3.33859C9.87891 1.5538 6.98486 1.5538 5.2002 3.33859L4.5 4.03882V2H3.5Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 468 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><defs><clipPath><path d="M.06 91.886h91.828v-91.886h-91.828v91.886z"/></clipPath><clipPath id="a"><path d="M0 0h92v92h-92v-92z"/></clipPath></defs><path d="M28.497 14.84l-11.354-11.353c-.653-.654-1.714-.654-2.368 0l-2.357 2.358 2.99 2.991c.695-.235 1.492-.077 2.046.477.557.558.713 1.361.473 2.059l2.882 2.882c.698-.241 1.502-.085 2.059.473.778.778.778 2.039 0 2.818-.779.779-2.04.779-2.819 0-.586-.586-.73-1.446-.434-2.167l-2.688-2.688v7.074c.19.094.369.219.527.377.778.778.778 2.039 0 2.819-.778.778-2.04.778-2.818 0-.778-.779-.778-2.04 0-2.819.192-.192.415-.338.653-.435v-7.14c-.237-.097-.46-.241-.653-.435-.589-.589-.731-1.455-.429-2.179l-2.948-2.949-7.785 7.785c-.654.655-.654 1.715 0 2.369l11.354 11.353c.654.654 1.714.654 2.369 0l11.3-11.301c.654-.654.654-1.715 0-2.369" fill="#424242" clip-path="url(#a)"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 7V8H8V14H7V8H1V7H7V1H8V7H14Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 883 B

After

Width:  |  Height:  |  Size: 163 B

View File

@@ -1 +1,3 @@
<svg fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="m6 12h-1c-.27-.02-.48-.11-.69-.31s-.3-.42-.31-.69v-6.28c.59-.34 1-.98 1-1.72 0-1.11-.89-2-2-2s-2 .89-2 2c0 .73.41 1.38 1 1.72v6.28c.03.78.34 1.47.94 2.06s1.28.91 2.06.94c0 0 1.02 0 1 0v2l3-3-3-3zm-3-10.2c.66 0 1.2.55 1.2 1.2s-.55 1.2-1.2 1.2-1.2-.55-1.2-1.2.55-1.2 1.2-1.2zm11 9.48c0-1.73 0-6.28 0-6.28-.03-.78-.34-1.47-.94-2.06s-1.28-.91-2.06-.94h-1v-2l-3 3 3 3v-2h1c.27.02.48.11.69.31s.3.42.31.69v6.28c-.59.34-1 .98-1 1.72 0 1.11.89 2 2 2s2-.89 2-2c0-.73-.41-1.38-1-1.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2s.55-1.2 1.2-1.2 1.2.55 1.2 1.2-.55 1.2-1.2 1.2z" fill="#424242" fill-rule="evenodd"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.88465 1.69445L8.57246 3H11.346C11.5656 3 11.783 3.04327 11.9858 3.12734C12.1886 3.2114 12.3729 3.33461 12.5281 3.48993C12.6833 3.64525 12.8063 3.82963 12.8902 4.03253C12.9741 4.23543 13.0172 4.45287 13.017 4.67243L12.517 4.672H13.017V4.67243V10.4539C13.8823 10.6794 14.521 11.4661 14.521 12.402C14.521 13.5138 13.6198 14.415 12.508 14.415C11.3963 14.415 10.495 13.5138 10.495 12.402C10.495 11.4596 11.1426 10.6685 12.017 10.4493V4.672V4.67158C12.0171 4.58341 11.9998 4.4961 11.9661 4.41462C11.9324 4.33314 11.883 4.25911 11.8207 4.19674C11.7584 4.13437 11.6844 4.08489 11.6029 4.05114C11.5215 4.01738 11.4342 4 11.346 4H8.53857L9.83833 5.34332L9.11967 6.03868L7.00067 3.84868L7.00735 3.14655L9.17935 0.98555L9.88465 1.69445ZM11.495 12.402C11.495 11.8425 11.9485 11.389 12.508 11.389C13.0675 11.389 13.521 11.8425 13.521 12.402C13.521 12.9615 13.0675 13.415 12.508 13.415C11.9485 13.415 11.495 12.9615 11.495 12.402ZM2.499 3.513C2.499 2.95354 2.95254 2.5 3.512 2.5C4.07147 2.5 4.525 2.95354 4.525 3.513C4.525 4.07247 4.07147 4.526 3.512 4.526C2.95254 4.526 2.499 4.07247 2.499 3.513ZM3.512 1.5C2.40025 1.5 1.499 2.40125 1.499 3.513C1.499 4.44783 2.13622 5.23382 3 5.46031V11.307C3 11.7502 3.17605 12.1752 3.48942 12.4886C3.8028 12.802 4.22782 12.978 4.671 12.978H7.44813L6.13543 14.2835L6.84057 14.9925L9.01257 12.8325L9.01941 12.1304L6.90041 9.93939L6.18159 10.6346L7.48086 11.978H4.671C4.49304 11.978 4.32237 11.9073 4.19653 11.7815C4.07069 11.6556 4 11.485 4 11.307V5.46645C4.87595 5.24833 5.525 4.45646 5.525 3.513C5.525 2.40125 4.62375 1.5 3.512 1.5Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 720 B

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#424242" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#424242" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>

Before

Width:  |  Height:  |  Size: 262 B

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#656565" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#00539C" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.06065 3.85356L5.91421 6L5.2071 5.29289L6.49999 4H3.5C3.10218 4 2.72064 4.15804 2.43934 4.43934C2.15804 4.72065 2 5.10218 2 5.5C2 5.89783 2.15804 6.27936 2.43934 6.56066C2.72064 6.84197 3.10218 7 3.5 7H4V8H3.5C2.83696 8 2.20107 7.73661 1.73223 7.26777C1.26339 6.79893 1 6.16305 1 5.5C1 4.83696 1.26339 4.20108 1.73223 3.73224C2.20107 3.2634 2.83696 3 3.5 3H6.49999L6.49999 3H6.49996L6 2.50004V2.50001L5.2071 1.70711L5.91421 1L8.06065 3.14645L8.06065 3.85356ZM5 6.50003L5.91421 7.41424L6 7.32845V14H14V7H10V3H9.06065V2.73227L8.32838 2H11.2L11.5 2.1L14.9 5.6L15 6V14.5L14.5 15H5.5L5 14.5V9.00003V6.50003ZM11 3V6H13.9032L11 3Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 796 B

View File

@@ -1 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#F6F6F6"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#424242"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.56253 2.51577C3.46348 3.4501 2 5.55414 2 7.99999C2 11.3137 4.68629 14 8 14C11.3137 14 14 11.3137 14 7.99999C14 5.32519 12.2497 3.05919 9.83199 2.28482L9.52968 3.23832C11.5429 3.88454 13 5.7721 13 7.99999C13 10.7614 10.7614 13 8 13C5.23858 13 3 10.7614 3 7.99999C3 6.31104 3.83742 4.81767 5.11969 3.91245L5.56253 2.51577Z" fill="#424242"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 3H2V2H5.5L6 2.5V6H5V3Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 986 B

After

Width:  |  Height:  |  Size: 587 B

View File

@@ -1 +1,3 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><title>Layer 1</title><rect height="11" width="3" y="3" x="7" fill="#424242"/><rect height="3" width="11" y="7" x="3" fill="#424242"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 7V8H8V14H7V8H1V7H7V1H8V7H14Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 163 B

View File

@@ -1 +1,3 @@
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><title>Layer 1</title><rect height="3" width="11" y="7" x="3" fill="#424242"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 8H1V7H15V8Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 146 B

View File

@@ -235,4 +235,4 @@ export const enum GitErrorCodes {
CantRebaseMultipleBranches = 'CantRebaseMultipleBranches',
PatchDoesNotApply = 'PatchDoesNotApply',
NoPathFound = 'NoPathFound'
}
}

View File

@@ -56,7 +56,13 @@ class CheckoutRemoteHeadItem extends CheckoutItem {
return;
}
await repository.checkoutTracking(this.ref.name);
const branches = await repository.findTrackingBranches(this.ref.name);
if (branches.length > 0) {
await repository.checkout(branches[0].name!);
} else {
await repository.checkoutTracking(this.ref.name);
}
}
}
@@ -196,7 +202,7 @@ function createCheckoutItems(repository: Repository): CheckoutItem[] {
enum PushType {
Push,
PushTo,
PushTags,
PushFollowTags,
}
interface PushOptions {
@@ -481,10 +487,10 @@ export class CommandCenter {
(_, token) => this.git.clone(url!, parentPath, token)
);
const choices = [];
let message = localize('proposeopen', "Would you like to open the cloned repository?");
const open = localize('openrepo', "Open Repository");
choices.push(open);
const open = localize('openrepo', "Open");
const openNewWindow = localize('openreponew', "Open in New Window");
const choices = [open, openNewWindow];
const addToWorkspace = localize('add', "Add to Workspace");
if (workspace.workspaceFolders) {
@@ -509,6 +515,8 @@ export class CommandCenter {
commands.executeCommand('vscode.openFolder', uri);
} else if (result === addToWorkspace) {
workspace.updateWorkspaceFolders(workspace.workspaceFolders!.length, 0, { uri });
} else if (result === openNewWindow) {
commands.executeCommand('vscode.openFolder', uri, true);
}
} catch (err) {
if (/already exists and is not an empty directory/.test(err && err.stderr || '')) {
@@ -593,10 +601,10 @@ export class CommandCenter {
await this.git.init(repositoryPath);
const choices = [];
let message = localize('proposeopen init', "Would you like to open the initialized repository?");
const open = localize('openrepo', "Open Repository");
choices.push(open);
const open = localize('openrepo', "Open");
const openNewWindow = localize('openreponew', "Open in New Window");
const choices = [open, openNewWindow];
if (!askToOpen) {
return;
@@ -615,6 +623,8 @@ export class CommandCenter {
commands.executeCommand('vscode.openFolder', uri);
} else if (result === addToWorkspace) {
workspace.updateWorkspaceFolders(workspace.workspaceFolders!.length, 0, { uri });
} else if (result === openNewWindow) {
commands.executeCommand('vscode.openFolder', uri, true);
} else {
await this.model.openRepository(repositoryPath);
}
@@ -663,7 +673,6 @@ export class CommandCenter {
if (!(resource instanceof Resource)) {
// can happen when called from a keybinding
console.log('WHAT');
resource = this.getSCMResource();
}
@@ -728,6 +737,8 @@ export class CommandCenter {
}
const HEAD = await this.getLeftResource(resource);
const basename = path.basename(resource.resourceUri.fsPath);
const title = `${basename} (HEAD)`;
if (!HEAD) {
window.showWarningMessage(localize('HEAD not available', "HEAD version of '{0}' is not available.", path.basename(resource.resourceUri.fsPath)));
@@ -738,7 +749,7 @@ export class CommandCenter {
preview
};
return await commands.executeCommand<void>('vscode.open', HEAD, opts);
return await commands.executeCommand<void>('vscode.open', HEAD, opts, title);
}
@command('git.openChange')
@@ -1560,8 +1571,11 @@ export class CommandCenter {
@command('git.renameBranch', { repository: true })
async renameBranch(repository: Repository): Promise<void> {
const placeHolder = localize('provide branch name', "Please provide a branch name");
const name = await window.showInputBox({ placeHolder });
const name = await window.showInputBox({
placeHolder: localize('branch name', "Branch name"),
prompt: localize('provide branch name', "Please provide a branch name"),
value: repository.HEAD && repository.HEAD.name
});
if (!name || name.trim().length === 0) {
return;
@@ -1753,10 +1767,8 @@ export class CommandCenter {
}
}
if (pushOptions.pushType === PushType.PushTags) {
await repository.pushTags(undefined, forcePushMode);
window.showInformationMessage(localize('push with tags success', "Successfully pushed with tags."));
if (pushOptions.pushType === PushType.PushFollowTags) {
await repository.pushFollowTags(undefined, forcePushMode);
return;
}
@@ -1813,13 +1825,13 @@ export class CommandCenter {
}
@command('git.pushWithTags', { repository: true })
async pushWithTags(repository: Repository): Promise<void> {
await this._push(repository, { pushType: PushType.PushTags });
async pushFollowTags(repository: Repository): Promise<void> {
await this._push(repository, { pushType: PushType.PushFollowTags });
}
@command('git.pushWithTagsForce', { repository: true })
async pushWithTagsForce(repository: Repository): Promise<void> {
await this._push(repository, { pushType: PushType.PushTags, forcePush: true });
async pushFollowTagsForce(repository: Repository): Promise<void> {
await this._push(repository, { pushType: PushType.PushFollowTags, forcePush: true });
}
@command('git.pushTo', { repository: true })

View File

@@ -12,7 +12,8 @@ import { EventEmitter } from 'events';
import iconv = require('iconv-lite');
import * as filetype from 'file-type';
import { assign, groupBy, denodeify, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent } from './util';
import { CancellationToken, Uri, workspace } from 'vscode';
import { CancellationToken } from 'vscode';
import { URI } from 'vscode-uri';
import { detectEncoding } from './encoding';
import { Ref, RefType, Branch, Remote, GitErrorCodes, LogOptions, Change, Status } from './api/git';
@@ -328,8 +329,8 @@ export class Git {
this.env = options.env || {};
}
open(repository: string): Repository {
return new Repository(this, repository);
open(repository: string, dotGit: string): Repository {
return new Repository(this, repository, dotGit);
}
async init(repository: string): Promise<void> {
@@ -338,7 +339,7 @@ export class Git {
}
async clone(url: string, parentPath: string, cancellationToken?: CancellationToken): Promise<string> {
let baseFolderName = decodeURI(url).replace(/^.*\//, '').replace(/\.git$/, '') || 'repository';
let baseFolderName = decodeURI(url).replace(/[\/]+$/, '').replace(/^.*\//, '').replace(/\.git$/, '') || 'repository';
let folderName = baseFolderName;
let folderPath = path.join(parentPath, folderName);
let count = 1;
@@ -369,6 +370,17 @@ export class Git {
return path.normalize(result.stdout.trim());
}
async getRepositoryDotGit(repositoryPath: string): Promise<string> {
const result = await this.exec(repositoryPath, ['rev-parse', '--git-dir']);
let dotGitPath = result.stdout.trim();
if (!path.isAbsolute(dotGitPath)) {
dotGitPath = path.join(repositoryPath, dotGitPath);
}
return path.normalize(dotGitPath);
}
async exec(cwd: string, args: string[], options: SpawnOptions = {}): Promise<IExecutionResult<string>> {
options = assign({ cwd }, options || {});
return await this._exec(args, options);
@@ -557,7 +569,7 @@ export function parseGitmodules(raw: string): Submodule[] {
return;
}
const propertyMatch = /^\s*(\w+) = (.*)$/.exec(line);
const propertyMatch = /^\s*(\w+)\s+=\s+(.*)$/.exec(line);
if (!propertyMatch) {
return;
@@ -636,6 +648,7 @@ export interface CommitOptions {
export interface PullOptions {
unshallow?: boolean;
tags?: boolean;
}
export enum ForcePushMode {
@@ -647,7 +660,8 @@ export class Repository {
constructor(
private _git: Git,
private repositoryRoot: string
private repositoryRoot: string,
readonly dotGit: string
) { }
get git(): Git {
@@ -995,7 +1009,7 @@ export class Repository {
break;
}
const originalUri = Uri.file(path.isAbsolute(resourcePath) ? resourcePath : path.join(this.repositoryRoot, resourcePath));
const originalUri = URI.file(path.isAbsolute(resourcePath) ? resourcePath : path.join(this.repositoryRoot, resourcePath));
let status: Status = Status.UNTRACKED;
// Copy or Rename status comes with a number, e.g. 'R100'. We don't need the number, so we use only first character of the status.
@@ -1023,7 +1037,7 @@ export class Repository {
break;
}
const uri = Uri.file(path.isAbsolute(newPath) ? newPath : path.join(this.repositoryRoot, newPath));
const uri = URI.file(path.isAbsolute(newPath) ? newPath : path.join(this.repositoryRoot, newPath));
result.push({
uri,
renameUri: uri,
@@ -1363,9 +1377,8 @@ export class Repository {
async pull(rebase?: boolean, remote?: string, branch?: string, options: PullOptions = {}): Promise<void> {
const args = ['pull'];
const config = workspace.getConfiguration('git', Uri.file(this.root));
if (config.get<boolean>('pullTags')) {
if (options.tags) {
args.push('--tags');
}
@@ -1418,7 +1431,7 @@ export class Repository {
}
if (tags) {
args.push('--tags');
args.push('--follow-tags');
}
if (remote) {
@@ -1578,6 +1591,14 @@ export class Repository {
}
}
async findTrackingBranches(upstreamBranch: string): Promise<Branch[]> {
const result = await this.run(['for-each-ref', '--format', '%(refname:short)%00%(upstream:short)', 'refs/heads']);
return result.stdout.trim().split('\n')
.map(line => line.trim().split('\0'))
.filter(([_, upstream]) => upstream === upstreamBranch)
.map(([ref]) => ({ name: ref, type: RefType.Head } as Branch));
}
async getRefs(): Promise<Ref[]> {
const result = await this.run(['for-each-ref', '--format', '%(refname) %(objectname)', '--sort', '-committerdate']);

View File

@@ -78,7 +78,7 @@ export class Model {
this.disposables.push(fsWatcher);
const onWorkspaceChange = anyEvent(fsWatcher.onDidChange, fsWatcher.onDidCreate, fsWatcher.onDidDelete);
const onGitRepositoryChange = filterEvent(onWorkspaceChange, uri => /\/\.git\//.test(uri.path));
const onGitRepositoryChange = filterEvent(onWorkspaceChange, uri => /\/\.git/.test(uri.path));
const onPossibleGitRepositoryChange = filterEvent(onGitRepositoryChange, uri => !this.getRepository(uri));
onPossibleGitRepositoryChange(this.onPossibleGitRepositoryChange, this, this.disposables);
@@ -232,7 +232,8 @@ export class Model {
return;
}
const repository = new Repository(this.git.open(repositoryRoot), this.globalState);
const dotGit = await this.git.getRepositoryDotGit(repositoryRoot);
const repository = new Repository(this.git.open(repositoryRoot, dotGit), this.globalState, this.outputChannel);
this.open(repository);
} catch (err) {

View File

@@ -3,9 +3,9 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType } from 'vscode';
import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env } from 'vscode';
import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions, ForcePushMode } from './git';
import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent } from './util';
import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent, combinedDisposable, watch, IFileWatcher } from './util';
import { memoize, throttle, debounce } from './decorators';
import { toGitUri } from './uri';
import { AutoFetcher } from './autofetch';
@@ -299,6 +299,7 @@ export const enum Operation {
GetObjectDetails = 'GetObjectDetails',
SubmoduleUpdate = 'SubmoduleUpdate',
RebaseContinue = 'RebaseContinue',
FindTrackingBranches = 'GetTracking',
Apply = 'Apply',
Blame = 'Blame',
Log = 'Log',
@@ -446,6 +447,91 @@ class ProgressManager {
}
}
class FileEventLogger {
private eventDisposable: IDisposable = EmptyDisposable;
private logLevelDisposable: IDisposable = EmptyDisposable;
constructor(
private onWorkspaceWorkingTreeFileChange: Event<Uri>,
private onDotGitFileChange: Event<Uri>,
private outputChannel: OutputChannel
) {
this.logLevelDisposable = env.onDidChangeLogLevel(this.onDidChangeLogLevel, this);
this.onDidChangeLogLevel(env.logLevel);
}
private onDidChangeLogLevel(level: LogLevel): void {
this.eventDisposable.dispose();
if (level > LogLevel.Debug) {
return;
}
this.eventDisposable = combinedDisposable([
this.onWorkspaceWorkingTreeFileChange(uri => this.outputChannel.appendLine(`[debug] [wt] Change: ${uri.fsPath}`)),
this.onDotGitFileChange(uri => this.outputChannel.appendLine(`[debug] [.git] Change: ${uri.fsPath}`))
]);
}
dispose(): void {
this.eventDisposable.dispose();
this.logLevelDisposable.dispose();
}
}
class DotGitWatcher implements IFileWatcher {
readonly event: Event<Uri>;
private emitter = new EventEmitter<Uri>();
private transientDisposables: IDisposable[] = [];
private disposables: IDisposable[] = [];
constructor(
private repository: Repository,
private outputChannel: OutputChannel
) {
const rootWatcher = watch(repository.dotGit);
this.disposables.push(rootWatcher);
const filteredRootWatcher = filterEvent(rootWatcher.event, uri => !/\/\.git(\/index\.lock)?$/.test(uri.path));
this.event = anyEvent(filteredRootWatcher, this.emitter.event);
repository.onDidRunGitStatus(this.updateTransientWatchers, this, this.disposables);
this.updateTransientWatchers();
}
private updateTransientWatchers() {
this.transientDisposables = dispose(this.transientDisposables);
if (!this.repository.HEAD || !this.repository.HEAD.upstream) {
return;
}
this.transientDisposables = dispose(this.transientDisposables);
const { name, remote } = this.repository.HEAD.upstream;
const upstreamPath = path.join(this.repository.dotGit, 'refs', 'remotes', remote, name);
try {
const upstreamWatcher = watch(upstreamPath);
this.transientDisposables.push(upstreamWatcher);
upstreamWatcher.event(this.emitter.fire, this.emitter, this.transientDisposables);
} catch (err) {
if (env.logLevel <= LogLevel.Info) {
this.outputChannel.appendLine(`Failed to watch ref '${upstreamPath}'. Ref is most likely packed.`);
}
}
}
dispose() {
this.emitter.dispose();
this.transientDisposables = dispose(this.transientDisposables);
this.disposables = dispose(this.disposables);
}
}
export class Repository implements Disposable {
private _onDidChangeRepository = new EventEmitter<Uri>();
@@ -543,36 +629,41 @@ export class Repository implements Disposable {
return this.repository.root;
}
get dotGit(): string {
return this.repository.dotGit;
}
private isRepositoryHuge = false;
private didWarnAboutLimit = false;
private isFreshRepository: boolean | undefined = undefined;
private disposables: Disposable[] = [];
constructor(
private readonly repository: BaseRepository,
globalState: Memento
globalState: Memento,
outputChannel: OutputChannel
) {
const fsWatcher = workspace.createFileSystemWatcher('**');
this.disposables.push(fsWatcher);
const workspaceWatcher = workspace.createFileSystemWatcher('**');
this.disposables.push(workspaceWatcher);
const workspaceFilter = (uri: Uri) => isDescendant(repository.root, uri.fsPath);
const onWorkspaceDelete = filterEvent(fsWatcher.onDidDelete, workspaceFilter);
const onWorkspaceChange = filterEvent(anyEvent(fsWatcher.onDidChange, fsWatcher.onDidCreate), workspaceFilter);
const onRepositoryDotGitDelete = filterEvent(onWorkspaceDelete, uri => /\/\.git$/.test(uri.path));
const onRepositoryChange = anyEvent(onWorkspaceDelete, onWorkspaceChange);
const onWorkspaceFileChange = anyEvent(workspaceWatcher.onDidChange, workspaceWatcher.onDidCreate, workspaceWatcher.onDidDelete);
const onWorkspaceRepositoryFileChange = filterEvent(onWorkspaceFileChange, uri => isDescendant(repository.root, uri.fsPath));
const onWorkspaceWorkingTreeFileChange = filterEvent(onWorkspaceRepositoryFileChange, uri => !/\/\.git($|\/)/.test(uri.path));
// relevant repository changes are:
// - DELETE .git folder
// - ANY CHANGE within .git folder except .git itself and .git/index.lock
const onRelevantRepositoryChange = anyEvent(
onRepositoryDotGitDelete,
filterEvent(onRepositoryChange, uri => !/\/\.git(\/index\.lock)?$/.test(uri.path))
);
const dotGitFileWatcher = new DotGitWatcher(this, outputChannel);
this.disposables.push(dotGitFileWatcher);
onRelevantRepositoryChange(this.onFSChange, this, this.disposables);
// FS changes should trigger `git status`:
// - any change inside the repository working tree
// - any change whithin the first level of the `.git` folder, except the folder itself and `index.lock`
const onFileChange = anyEvent(onWorkspaceWorkingTreeFileChange, dotGitFileWatcher.event);
onFileChange(this.onFileChange, this, this.disposables);
const onRelevantGitChange = filterEvent(onRelevantRepositoryChange, uri => /\/\.git\//.test(uri.path));
onRelevantGitChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, this.disposables);
// Relevate repository changes should trigger virtual document change events
dotGitFileWatcher.event(this._onDidChangeRepository.fire, this._onDidChangeRepository, this.disposables);
this.disposables.push(new FileEventLogger(onWorkspaceWorkingTreeFileChange, dotGitFileWatcher.event, outputChannel));
const root = Uri.file(repository.root);
this._sourceControl = scm.createSourceControl('git', 'Git', root);
@@ -582,9 +673,9 @@ export class Repository implements Disposable {
this._sourceControl.inputBox.validateInput = this.validateInput.bind(this);
this.disposables.push(this._sourceControl);
this._mergeGroup = this._sourceControl.createResourceGroup('merge', localize('merge changes', "Merge Changes"));
this._indexGroup = this._sourceControl.createResourceGroup('index', localize('staged changes', "Staged Changes"));
this._workingTreeGroup = this._sourceControl.createResourceGroup('workingTree', localize('changes', "Changes"));
this._mergeGroup = this._sourceControl.createResourceGroup('merge', localize('merge changes', "MERGE CHANGES"));
this._indexGroup = this._sourceControl.createResourceGroup('index', localize('staged changes', "STAGED CHANGES"));
this._workingTreeGroup = this._sourceControl.createResourceGroup('workingTree', localize('changes', "CHANGES"));
const updateIndexGroupVisibility = () => {
const config = workspace.getConfiguration('git', root);
@@ -909,6 +1000,10 @@ export class Repository implements Disposable {
await this.run(Operation.CheckoutTracking, () => this.repository.checkout(treeish, [], { track: true }));
}
async findTrackingBranches(upstreamRef: string): Promise<Branch[]> {
return await this.run(Operation.FindTrackingBranches, () => this.repository.findTrackingBranches(upstreamRef));
}
async getCommit(ref: string): Promise<Commit> {
return await this.repository.getCommit(ref);
}
@@ -979,11 +1074,12 @@ export class Repository implements Disposable {
await this.maybeAutoStash(async () => {
const config = workspace.getConfiguration('git', Uri.file(this.root));
const fetchOnPull = config.get<boolean>('fetchOnPull');
const tags = config.get<boolean>('pullTags');
if (fetchOnPull) {
await this.repository.pull(rebase, undefined, undefined, { unshallow });
await this.repository.pull(rebase, undefined, undefined, { unshallow, tags });
} else {
await this.repository.pull(rebase, remote, branch, { unshallow });
await this.repository.pull(rebase, remote, branch, { unshallow, tags });
}
});
});
@@ -1006,7 +1102,7 @@ export class Repository implements Disposable {
await this.run(Operation.Push, () => this.repository.push(remote, name, setUpstream, undefined, forcePushMode));
}
async pushTags(remote?: string, forcePushMode?: ForcePushMode): Promise<void> {
async pushFollowTags(remote?: string, forcePushMode?: ForcePushMode): Promise<void> {
await this.run(Operation.Push, () => this.repository.push(remote, undefined, false, true, forcePushMode));
}
@@ -1039,11 +1135,12 @@ export class Repository implements Disposable {
await this.maybeAutoStash(async () => {
const config = workspace.getConfiguration('git', Uri.file(this.root));
const fetchOnPull = config.get<boolean>('fetchOnPull');
const tags = config.get<boolean>('pullTags');
if (fetchOnPull) {
await this.repository.pull(rebase);
await this.repository.pull(rebase, undefined, undefined, { tags });
} else {
await this.repository.pull(rebase, remoteName, pullBranch);
await this.repository.pull(rebase, remoteName, pullBranch, { tags });
}
const remote = this.remotes.find(r => r.name === remoteName);
@@ -1156,7 +1253,7 @@ export class Repository implements Disposable {
}
// https://git-scm.com/docs/git-check-ignore#git-check-ignore--z
const child = this.repository.stream(['check-ignore', '-z', '--stdin'], { stdio: [null, null, null] });
const child = this.repository.stream(['check-ignore', '-v', '-z', '--stdin'], { stdio: [null, null, null] });
child.stdin.end(filePaths.join('\0'), 'utf8');
const onExit = (exitCode: number) => {
@@ -1164,8 +1261,7 @@ export class Repository implements Disposable {
// nothing ignored
resolve(new Set<string>());
} else if (exitCode === 0) {
// paths are separated by the null-character
resolve(new Set<string>(data.split('\0')));
resolve(new Set<string>(this.parseIgnoreCheck(data)));
} else {
if (/ is in submodule /.test(stderr)) {
reject(new GitError({ stdout: data, stderr, exitCode, gitErrorCode: GitErrorCodes.IsInSubmodule }));
@@ -1193,6 +1289,23 @@ export class Repository implements Disposable {
});
}
// Parses output of `git check-ignore -v -z` and returns only those paths
// that are actually ignored by git.
// Matches to a negative pattern (starting with '!') are filtered out.
// See also https://git-scm.com/docs/git-check-ignore#_output.
private parseIgnoreCheck(raw: string): string[] {
const ignored = [];
const elements = raw.split('\0');
for (let i = 0; i < elements.length; i += 4) {
const pattern = elements[i + 2];
const path = elements[i + 3];
if (pattern && !pattern.startsWith('!')) {
ignored.push(path);
}
}
return ignored;
}
private async run<T>(operation: Operation, runOperation: () => Promise<T> = () => Promise.resolve<any>(null)): Promise<T> {
if (this.state !== RepositoryState.Idle) {
throw new Error('Repository not initialized');
@@ -1430,7 +1543,7 @@ export class Repository implements Disposable {
return result;
}
private onFSChange(_uri: Uri): void {
private onFileChange(_uri: Uri): void {
const config = workspace.getConfiguration('git');
const autorefresh = config.get<boolean>('autorefresh');

View File

@@ -172,6 +172,17 @@ suite('git', () => {
{ name: 'deps/spdlog4', path: 'deps/spdlog4', url: 'https://github.com/gabime/spdlog4.git' }
]);
});
test('whitespace #74844', () => {
const sample = `[submodule "deps/spdlog"]
path = deps/spdlog
url = https://github.com/gabime/spdlog.git
`;
assert.deepEqual(parseGitmodules(sample), [
{ name: 'deps/spdlog', path: 'deps/spdlog', url: 'https://github.com/gabime/spdlog.git' }
]);
});
});
suite('parseGitCommit', () => {

View File

@@ -3,8 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vscode';
import { dirname, sep } from 'path';
import { Event, EventEmitter, Uri } from 'vscode';
import { dirname, sep, join } from 'path';
import { Readable } from 'stream';
import * as fs from 'fs';
import * as byline from 'byline';
@@ -343,4 +343,20 @@ export function pathEquals(a: string, b: string): boolean {
}
return a === b;
}
}
export interface IFileWatcher extends IDisposable {
readonly event: Event<Uri>;
}
export function watch(location: string): IFileWatcher {
const dotGitWatcher = fs.watch(location);
const onDotGitFileChangeEmitter = new EventEmitter<Uri>();
dotGitWatcher.on('change', (_, e) => onDotGitFileChangeEmitter.fire(Uri.file(join(location, e as string))));
dotGitWatcher.on('error', err => console.error(err));
return new class implements IFileWatcher {
event = onDotGitFileChangeEmitter.event;
dispose() { dotGitWatcher.close(); }
};
}

View File

@@ -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/textmate/git.tmbundle/commit/3f6ad2138200db14b57a090ecb2d2e733275ca3e",
"version": "https://github.com/textmate/git.tmbundle/commit/5870cf3f8abad3a6637bdf69250b5d2ded427dc4",
"name": "Git Rebase Message",
"scopeName": "text.git-rebase",
"patterns": [
@@ -47,6 +47,15 @@
},
"match": "^\\s*(exec|x)\\s+(.*)$",
"name": "meta.commit-command.git-rebase"
},
{
"captures": {
"1": {
"name": "support.function.git-rebase"
}
},
"match": "^\\s*(break|b)\\s*$",
"name": "meta.commit-command.git-rebase"
}
]
}

View File

@@ -26,10 +26,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.51.tgz#b31d716fb8d58eeb95c068a039b9b6292817d5fb"
integrity sha512-El3+WJk2D/ppWNd2X05aiP5l2k4EwF7KwheknQZls+I26eSICoWRhRIJ56jGgw2dqNGQ5LtNajmBU2ajS28EvQ==
"@types/node@^10.12.21":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
integrity sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
"@types/which@^1.0.28":
version "1.0.28"
@@ -325,6 +325,11 @@ vscode-nls@^4.0.0:
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
vscode-uri@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.0.0.tgz#2df704222f72b8a71ff266ba0830ed6c51ac1542"
integrity sha512-lWXWofDSYD8r/TIyu64MdwB4FaSirQ608PP/TzUyslyOeHGwQ0eTHUZeJrK1ILOmwUHaJtV693m2JoUYroUDpw==
which@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"

View File

@@ -11,7 +11,7 @@ import { xhr, XHRResponse, getErrorStatusDescription } from 'request-light';
const localize = nls.loadMessageBundle();
import { workspace, window, languages, commands, ExtensionContext, extensions, Uri, LanguageConfiguration, Diagnostic, StatusBarAlignment, TextEditor, TextDocument, Position, SelectionRange } from 'vscode';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification, HandleDiagnosticsSignature } from 'vscode-languageclient';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification, HandleDiagnosticsSignature, ResponseError } from 'vscode-languageclient';
import TelemetryReporter from 'vscode-extension-telemetry';
import { hash } from './utils/hash';
@@ -83,7 +83,12 @@ export function activate(context: ExtensionContext) {
let documentSelector = ['json', 'jsonc'];
let schemaResolutionErrorStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Right, 0);
let schemaResolutionErrorStatusBarItem = window.createStatusBarItem({
id: 'status.json.resolveError',
name: localize('json.resolveError', "JSON: Schema Resolution Error"),
alignment: StatusBarAlignment.Right,
priority: 0
});
schemaResolutionErrorStatusBarItem.command = '_json.retryResolveSchema';
schemaResolutionErrorStatusBarItem.tooltip = localize('json.schemaResolutionErrorMessage', 'Unable to resolve schema.') + ' ' + localize('json.clickToRetry', 'Click to retry.');
schemaResolutionErrorStatusBarItem.text = '$(alert)';
@@ -154,7 +159,7 @@ export function activate(context: ExtensionContext) {
return xhr({ url: uriPath, followRedirects: 5, headers }).then(response => {
return response.responseText;
}, (error: XHRResponse) => {
return Promise.reject(error.responseText || getErrorStatusDescription(error.status) || error.toString());
return Promise.reject(new ResponseError(error.status, error.responseText || getErrorStatusDescription(error.status) || error.toString()));
});
}
});

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"engines": {
"vscode": "0.10.x"
@@ -101,12 +102,12 @@
}
},
"dependencies": {
"request-light": "^0.2.4",
"vscode-extension-telemetry": "0.1.1",
"vscode-languageclient": "^5.2.1",
"vscode-nls": "^4.0.0",
"request-light": "^0.2.4"
"vscode-languageclient": "^5.3.0-next.6",
"vscode-nls": "^4.1.1"
},
"devDependencies": {
"@types/node": "^10.12.21"
"@types/node": "^10.14.8"
}
}

View File

@@ -154,7 +154,8 @@ To connect to the server from NodeJS, see Remy Suen's great write-up on [how to
## Participate
The source code of the JSON language server can be found [VSCode repository](https://github.com/Microsoft/vscode) at [extensions/json-language-features/server](https://github.com/Microsoft/vscode/tree/master/extensions/json-language-features/server).
The source code of the JSON language server can be found in the [VSCode repository](https://github.com/Microsoft/vscode) at [extensions/json-language-features/server](https://github.com/Microsoft/vscode/tree/master/extensions/json-language-features/server).
File issues and pull requests in the [VSCode GitHub Issues](https://github.com/Microsoft/vscode/issues). See the document [How to Contribute](https://github.com/Microsoft/vscode/wiki/How-to-Contribute) on how to build and run from source.
Most of the functionality of the server is located in libraries:
@@ -164,10 +165,12 @@ Most of the functionality of the server is located in libraries:
Help on any of these projects is very welcome.
Please see also our [Code of Conduct](CODE_OF_CONDUCT.md).
## Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## License
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the [MIT](LICENSE.txt) License.
Licensed under the [MIT](https://github.com/microsoft/vscode/blob/master/LICENSE.txt) License.

View File

@@ -12,16 +12,16 @@
},
"main": "./out/jsonServerMain",
"dependencies": {
"jsonc-parser": "^2.0.3",
"jsonc-parser": "^2.1.0",
"request-light": "^0.2.4",
"vscode-json-languageservice": "^3.3.0-next.7",
"vscode-languageserver": "^5.3.0-next.2",
"vscode-nls": "^4.0.0",
"vscode-uri": "^1.0.6"
"vscode-json-languageservice": "^3.3.0",
"vscode-languageserver": "^5.3.0-next.8",
"vscode-nls": "^4.1.1",
"vscode-uri": "^2.0.1"
},
"devDependencies": {
"@types/mocha": "2.2.33",
"@types/node": "^10.12.21"
"@types/node": "^10.14.8"
},
"scripts": {
"prepublishOnly": "npm run clean && npm run test",

View File

@@ -11,7 +11,7 @@ import {
import { xhr, XHRResponse, configure as configureHttpRequests, getErrorStatusDescription } from 'request-light';
import * as fs from 'fs';
import URI from 'vscode-uri';
import { URI } from 'vscode-uri';
import * as URL from 'url';
import { formatError, runSafe, runSafeAsync } from './utils/runner';
import { JSONDocument, JSONSchema, getLanguageService, DocumentLanguageSettings, SchemaConfiguration } from 'vscode-json-languageservice';
@@ -105,9 +105,9 @@ let languageService = getLanguageService({
contributions: [],
});
// Create a simple text document manager. The text document manager
// supports full document sync only
// Create a text document manager.
const documents: TextDocuments = new TextDocuments();
// Make the text document manager listen on the connection
// for open, change and close text document events
documents.listen(connection);

View File

@@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.33.tgz#d79a0061ec270379f4d9e225f4096fb436669def"
integrity sha1-15oAYewnA3n02eIl9AlvtDZmne8=
"@types/node@^10.12.21":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
integrity sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
agent-base@4, agent-base@^4.1.0:
version "4.1.2"
@@ -54,10 +54,10 @@ https-proxy-agent@^2.2.1:
agent-base "^4.1.0"
debug "^3.1.0"
jsonc-parser@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.0.3.tgz#6d4199ccab7f21ff5d2a4225050c54e981fb21a2"
integrity sha512-WJi9y9ABL01C8CxTKxRRQkkSpY/x2bo4Gy0WuiZGrInxQqgxQpvkBCLNcDYcHOSdhx4ODgbFcgAvfL49C+PHgQ==
jsonc-parser@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.1.0.tgz#eb0d0c7a3c33048524ce3574c57c7278fb2f1bf3"
integrity sha512-n9GrT8rrr2fhvBbANa1g+xFmgGK5X91KFeDwlKQ3+SJfmH5+tKv/M/kahx/TXOMflfWHKGKqKyfHQaLKTNzJ6w==
ms@2.0.0:
version "2.0.0"
@@ -73,40 +73,41 @@ request-light@^0.2.4:
https-proxy-agent "^2.2.1"
vscode-nls "^4.0.0"
vscode-json-languageservice@^3.3.0-next.7:
version "3.3.0-next.7"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.0-next.7.tgz#3ad4bf31f37fa110676b2c0db69b5f4810bdd4b9"
integrity sha512-uKXnzoZrqNOPRa+FmUdoCpNU5KCLhy7yDGCAzzfn0mocsEllPcspjHcBDu9HJCfT165UkhulZ2gl5vVX5NzBVA==
vscode-json-languageservice@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.0.tgz#f80ec21c19fb8648c815220a2857f9f0b22e1094"
integrity sha512-upq1PhwDItazdtRJ/R7uU0Fgrf9iaYa1xLK4WFLExR0DgbPojd0YgMpfyknVyXGlxsg3fJQ0H7J++QeByXHh9w==
dependencies:
jsonc-parser "^2.0.3"
vscode-languageserver-types "^3.14.0"
vscode-nls "^4.0.0"
vscode-uri "^1.0.6"
jsonc-parser "^2.1.0"
vscode-languageserver-types "^3.15.0-next.2"
vscode-nls "^4.1.1"
vscode-uri "^2.0.1"
vscode-jsonrpc@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz#a7bf74ef3254d0a0c272fab15c82128e378b3be9"
integrity sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==
vscode-jsonrpc@^4.1.0-next.2:
version "4.1.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-4.1.0-next.2.tgz#3bd318910a48e631742b290975386e3dae685be3"
integrity sha512-GsBLjP9DxQ42yl1mW9GEIlnSc0+R8mfzhaebwmmTPEJjezD5SPoAo3DFrIAFZha9yvQ1nzZfZlhtVpGQmgxtXg==
vscode-languageserver-protocol@3.15.0-next.1:
version "3.15.0-next.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.0-next.1.tgz#1e45e224d7eef8c79b4bed75b9dcb1930d2ab8ed"
integrity sha512-LXF0d9s3vxFBxVQ4aKl/XghdEMAncGt3dh4urIYa9Is43g3MfIQL9fC44YZtP+XXOrI2rpZU8lRNN01U1V6CDg==
vscode-languageserver-protocol@^3.15.0-next.6:
version "3.15.0-next.6"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.0-next.6.tgz#a8aeb7e7dd65da8216b386db59494cdfd3215d92"
integrity sha512-/yDpYlWyNs26mM23mT73xmOFsh1iRfgZfBdHmfAxwDKwpQKLoOSqVidtYfxlK/pD3IEKGcAVnT4WXTsguxxAMQ==
dependencies:
vscode-jsonrpc "^4.0.0"
vscode-languageserver-types "3.14.0"
vscode-jsonrpc "^4.1.0-next.2"
vscode-languageserver-types "^3.15.0-next.2"
vscode-languageserver-types@3.14.0, vscode-languageserver-types@^3.14.0:
version "3.14.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.14.0.tgz#d3b5952246d30e5241592b6dde8280e03942e743"
integrity sha512-lTmS6AlAlMHOvPQemVwo3CezxBp0sNB95KNPkqp3Nxd5VFEnuG1ByM0zlRWos0zjO3ZWtkvhal0COgiV1xIA4A==
vscode-languageserver-types@^3.15.0-next.2:
version "3.15.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.2.tgz#a0601332cdaafac21931f497bb080cfb8d73f254"
integrity sha512-2JkrMWWUi2rlVLSo9OFR2PIGUzdiowEM8NgNYiwLKnXTjpwpjjIrJbNNxDik7Rv4oo9KtikcFQZKXbrKilL/MQ==
vscode-languageserver@^5.3.0-next.2:
version "5.3.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-5.3.0-next.2.tgz#31ce4c34d68b517b400ca9e211e43f8d868b8dcc"
integrity sha512-n5onRw9naMrRHp2jnOn+ZwN1n+tTfzftWLPonjp1FWf/iCZWIlnw2TyF/Hn+SDGhLoVtoghmxhwEQaxEAfLHvw==
vscode-languageserver@^5.3.0-next.8:
version "5.3.0-next.8"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-5.3.0-next.8.tgz#12a4adf60374dbb93e153e08bdca5525f9b2029f"
integrity sha512-6vUb96wsRfrFqndril3gct/FBCSc24OxFZ2iz7kuEuXvLaIcEVOcSZIqQK8oFN7PdbAIaa9nnIpKSy4Yd15cIw==
dependencies:
vscode-languageserver-protocol "3.15.0-next.1"
vscode-languageserver-protocol "^3.15.0-next.6"
vscode-textbuffer "^1.0.0"
vscode-uri "^1.0.6"
vscode-nls@^4.0.0:
@@ -114,7 +115,22 @@ vscode-nls@^4.0.0:
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
vscode-textbuffer@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/vscode-textbuffer/-/vscode-textbuffer-1.0.0.tgz#1faee638c8e0e4131c8d5c353993a1874acda086"
integrity sha512-zPaHo4urgpwsm+PrJWfNakolRpryNja18SUip/qIIsfhuEqEIPEXMxHOlFPjvDC4JgTaimkncNW7UMXRJTY6ow==
vscode-uri@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.6.tgz#6b8f141b0bbc44ad7b07e94f82f168ac7608ad4d"
integrity sha512-sLI2L0uGov3wKVb9EB+vIQBl9tVP90nqRvxSoJ35vI3NjxE8jfsE5DSOhWgSunHSZmKS4OCi2jrtfxK7uyp2ww==
vscode-uri@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.0.1.tgz#5448e4f77d21d93ffa34b96f84c6c5e09e3f5a9b"
integrity sha512-s/k0zsYr6y+tsocFyxT/+G5aq8mEdpDZuph3LZ+UmCs7LNhx/xomiCy5kyP+jOAKC7RMCUvb6JbPD1/TgAvq0g==

View File

@@ -2,10 +2,10 @@
# yarn lockfile v1
"@types/node@^10.12.21":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
integrity sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
agent-base@4, agent-base@^4.1.0:
version "4.2.1"
@@ -113,37 +113,42 @@ vscode-extension-telemetry@0.1.1:
dependencies:
applicationinsights "1.0.8"
vscode-jsonrpc@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz#a7bf74ef3254d0a0c272fab15c82128e378b3be9"
integrity sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==
vscode-jsonrpc@^4.1.0-next.2:
version "4.1.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-4.1.0-next.2.tgz#3bd318910a48e631742b290975386e3dae685be3"
integrity sha512-GsBLjP9DxQ42yl1mW9GEIlnSc0+R8mfzhaebwmmTPEJjezD5SPoAo3DFrIAFZha9yvQ1nzZfZlhtVpGQmgxtXg==
vscode-languageclient@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-5.2.1.tgz#7cfc83a294c409f58cfa2b910a8cfeaad0397193"
integrity sha512-7jrS/9WnV0ruqPamN1nE7qCxn0phkH5LjSgSp9h6qoJGoeAKzwKz/PF6M+iGA/aklx4GLZg1prddhEPQtuXI1Q==
vscode-languageclient@^5.3.0-next.6:
version "5.3.0-next.6"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-5.3.0-next.6.tgz#35e74882781158e8b111911c0953869d3df08777"
integrity sha512-DxT8+gkenjCjJV6ArcP75/AQfx6HP6m6kHIbacPCpffMeoE1YMLKj6ZixA9J87yr0fMtBmqumLmDeGe7MIF2bw==
dependencies:
semver "^5.5.0"
vscode-languageserver-protocol "3.14.1"
vscode-languageserver-protocol "^3.15.0-next.6"
vscode-languageserver-protocol@3.14.1:
version "3.14.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.14.1.tgz#b8aab6afae2849c84a8983d39a1cf742417afe2f"
integrity sha512-IL66BLb2g20uIKog5Y2dQ0IiigW0XKrvmWiOvc0yXw80z3tMEzEnHjaGAb3ENuU7MnQqgnYJ1Cl2l9RvNgDi4g==
vscode-languageserver-protocol@^3.15.0-next.6:
version "3.15.0-next.6"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.0-next.6.tgz#a8aeb7e7dd65da8216b386db59494cdfd3215d92"
integrity sha512-/yDpYlWyNs26mM23mT73xmOFsh1iRfgZfBdHmfAxwDKwpQKLoOSqVidtYfxlK/pD3IEKGcAVnT4WXTsguxxAMQ==
dependencies:
vscode-jsonrpc "^4.0.0"
vscode-languageserver-types "3.14.0"
vscode-jsonrpc "^4.1.0-next.2"
vscode-languageserver-types "^3.15.0-next.2"
vscode-languageserver-types@3.14.0:
version "3.14.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.14.0.tgz#d3b5952246d30e5241592b6dde8280e03942e743"
integrity sha512-lTmS6AlAlMHOvPQemVwo3CezxBp0sNB95KNPkqp3Nxd5VFEnuG1ByM0zlRWos0zjO3ZWtkvhal0COgiV1xIA4A==
vscode-languageserver-types@^3.15.0-next.2:
version "3.15.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.2.tgz#a0601332cdaafac21931f497bb080cfb8d73f254"
integrity sha512-2JkrMWWUi2rlVLSo9OFR2PIGUzdiowEM8NgNYiwLKnXTjpwpjjIrJbNNxDik7Rv4oo9KtikcFQZKXbrKilL/MQ==
vscode-nls@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
zone.js@0.7.6:
version "0.7.6"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.7.6.tgz#fbbc39d3e0261d0986f1ba06306eb3aeb0d22009"

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "0.10.x"
},
@@ -23,7 +24,6 @@
".bowerrc",
".jshintrc",
".jscsrc",
".eslintrc",
".swcrc",
".webmanifest",
".js.map",
@@ -48,7 +48,9 @@
"extensions": [
".hintrc",
".babelrc",
".jsonc"
".jsonc",
".eslintrc",
".eslintrc.json"
],
"configuration": "./language-configuration.json"
}

View File

@@ -4,6 +4,7 @@
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "^1.20.0"
},

View File

@@ -716,7 +716,7 @@
{
"begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"contentName": "meta.embedded.block.cpp",
"contentName": "meta.embedded.block.cpp source.cpp",
"patterns": [
{
"include": "source.cpp"

View File

@@ -1,32 +0,0 @@
{
"registrations": [
{
"component": {
"type": "git",
"git": {
"name": "textmate/markdown.tmbundle",
"repositoryUrl": "https://github.com/textmate/markdown.tmbundle",
"commitHash": "11cf764606cb2cde54badb5d0e5a0758a8871c4b"
}
},
"licenseDetail": [
"Copyright (c) markdown.tmbundle authors",
"",
"If not otherwise specified (see below), files in this repository fall under the following license:",
"",
"Permission to copy, use, modify, sell and distribute this",
"software is granted. This software is provided \"as is\" without",
"express or implied warranty, and with no claim as to its",
"suitability for any purpose.",
"",
"An exception is made for files in readable text which contain their own license information,",
"or files where an accompanying file exists (in the same directory) with a \"-license\" suffix added",
"to the base-name name of the original file, and an extension of txt, html, or similar. For example",
"\"tidy\" is accompanied by \"tidy-license.txt\"."
],
"license": "TextMate Bundle License",
"version": "0.0.0"
}
],
"version": 1
}

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.icon-canvas-transparent,.icon-vs-out{fill:#f6f6f6;}.icon-canvas-transparent{opacity:0;}.icon-vs-bg{fill:#424242;}.icon-vs-action-blue{fill:#00539c;}</style></defs><title>SwitchToPreview_16x</title><g id="canvas"><path class="icon-canvas-transparent" d="M16,0V16H0V0Z"/></g><g id="outline" style="display: none;"><path class="icon-vs-out" d="M16,4V16H5V9.121l-1.939,1.94A1.5,1.5,0,0,1,.939,8.939L3.446,6.433A4.4,4.4,0,0,1,3,4.5,4.488,4.488,0,0,1,11.949,4Z" style="display: none;"/></g><g id="iconBg"><path class="icon-vs-bg" d="M12,10h1v3H12Zm0-3h-.762a4.5,4.5,0,0,1-.944,1H12Zm-2,6h1V11H10Zm2-8h-.051a4.485,4.485,0,0,1-.225,1H14v8H7V8.972a4.4,4.4,0,0,1-1-.237V15h9V5ZM9,12H8v1H9Zm1-3H8v1h2Z"/></g><g id="colorAction"><path class="icon-vs-action-blue" d="M7.5,1A3.5,3.5,0,0,0,4,4.5a3.463,3.463,0,0,0,.707,2.086L1.646,9.646a.5.5,0,0,0,.708.708l3.06-3.061A3.463,3.463,0,0,0,7.5,8a3.5,3.5,0,0,0,0-7Zm0,6A2.5,2.5,0,1,1,10,4.5,2.5,2.5,0,0,1,7.5,7Z"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.icon-canvas-transparent,.icon-vs-out{fill:#f6f6f6;}.icon-canvas-transparent{opacity:0;}.icon-vs-bg{fill:#424242;}.icon-vs-action-blue{fill:#00539c;}</style></defs><title>PreviewInRightPanel_16x</title><g id="canvas"><path class="icon-canvas-transparent" d="M16,0V16H0V0Z"/></g><g id="outline" style="display: none;"><path class="icon-vs-out" d="M16,1V15H10.121l-.56.561a1.5,1.5,0,0,1-2.122,0A1.469,1.469,0,0,1,7.1,15H0V1Z" style="display: none;"/></g><g id="iconBg"><path class="icon-vs-bg" d="M1,2V14H7.1a1.469,1.469,0,0,1,.341-.561L9,11.88V5h5V7.351a3.515,3.515,0,0,1,1,.707V2ZM7,13H2V5H7Z"/></g><g id="colorAction"><path class="icon-vs-action-blue" d="M12.5,8a2.5,2.5,0,0,0-2.084,3.877l-2.27,2.269a.5.5,0,0,0,.708.708l2.269-2.27A2.5,2.5,0,1,0,12.5,8Zm0,4A1.5,1.5,0,1,1,14,10.5,1.5,1.5,0,0,1,12.5,12Z"/></g></svg>

Before

Width:  |  Height:  |  Size: 890 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.icon-canvas-transparent,.icon-vs-out{fill:#252526;}.icon-canvas-transparent{opacity:0;}.icon-vs-bg{fill:#c5c5c5;}.icon-vs-action-blue{fill:#75beff;}</style></defs><title>PreviewInRightPanel_16x</title><g id="canvas"><path class="icon-canvas-transparent" d="M16,0V16H0V0Z"/></g><g id="outline" style="display: none;"><path class="icon-vs-out" d="M16,1V15H10.121l-.56.561a1.5,1.5,0,0,1-2.122,0A1.469,1.469,0,0,1,7.1,15H0V1Z" style="display: none;"/></g><g id="iconBg"><path class="icon-vs-bg" d="M1,2V14H7.1a1.469,1.469,0,0,1,.341-.561L9,11.88V5h5V7.351a3.515,3.515,0,0,1,1,.707V2ZM7,13H2V5H7Z"/></g><g id="colorAction"><path class="icon-vs-action-blue" d="M12.5,8a2.5,2.5,0,0,0-2.084,3.877l-2.27,2.269a.5.5,0,0,0,.708.708l2.269-2.27A2.5,2.5,0,1,0,12.5,8Zm0,4A1.5,1.5,0,1,1,14,10.5,1.5,1.5,0,0,1,12.5,12Z"/></g></svg>

Before

Width:  |  Height:  |  Size: 889 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.icon-canvas-transparent,.icon-vs-out{fill:#252526;}.icon-canvas-transparent{opacity:0;}.icon-vs-bg{fill:#c5c5c5;}.icon-vs-action-blue{fill:#75beff;}</style></defs><title>SwitchToPreview_16x</title><g id="canvas"><path class="icon-canvas-transparent" d="M16,0V16H0V0Z"/></g><g id="outline" style="display: none;"><path class="icon-vs-out" d="M16,4V16H5V9.121l-1.939,1.94A1.5,1.5,0,0,1,.939,8.939L3.446,6.433A4.4,4.4,0,0,1,3,4.5,4.488,4.488,0,0,1,11.949,4Z" style="display: none;"/></g><g id="iconBg"><path class="icon-vs-bg" d="M12,10h1v3H12Zm0-3h-.762a4.5,4.5,0,0,1-.944,1H12Zm-2,6h1V11H10Zm2-8h-.051a4.485,4.485,0,0,1-.225,1H14v8H7V8.972a4.4,4.4,0,0,1-1-.237V15h9V5ZM9,12H8v1H9Zm1-3H8v1h2Z"/></g><g id="colorAction"><path class="icon-vs-action-blue" d="M7.5,1A3.5,3.5,0,0,0,4,4.5a3.463,3.463,0,0,0,.707,2.086L1.646,9.646a.5.5,0,0,0,.708.708l3.06-3.061A3.463,3.463,0,0,0,7.5,8a3.5,3.5,0,0,0,0-7Zm0,6A2.5,2.5,0,1,1,10,4.5,2.5,2.5,0,0,1,7.5,7Z"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1,3 +0,0 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#656565" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#00539C" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>

Before

Width:  |  Height:  |  Size: 417 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><polygon fill="#C5C5C5" points="10,2 7.414,2 8.414,3 9,3 9,3.586 9,4 9,4.414 9,6 12,6 12,13 4,13 4,8 3,8 3,14 13,14 13,5"/><polygon fill="#75BEFF" points="5,1 3,1 5,3 1,3 1,5 5,5 3,7 5,7 8,4"/></svg>

Before

Width:  |  Height:  |  Size: 262 B

File diff suppressed because one or more lines are too long

View File

@@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
html, body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif;
font-size: 14px;
font-family: var(--vscode-markdown-font-family, -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "Ubuntu", "Droid Sans", sans-serif);
font-size: var(--vscode-markdown-font-size, 14px);
padding: 0 26px;
line-height: 22px;
line-height: var(--vscode-markdown-line-height, 22px);
word-wrap: break-word;
}
@@ -135,7 +135,6 @@ h3 code,
h4 code,
h5 code,
h6 code {
font-size: inherit;
line-height: auto;
}
@@ -168,8 +167,8 @@ blockquote {
code {
font-family: Menlo, Monaco, Consolas, "Droid Sans Mono", "Courier New", monospace, "Droid Sans Fallback";
font-size: 1rem;
line-height: 1.357rem;
font-size: 1em;
line-height: 1.357em;
}
body.wordWrap pre {

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3V13L2 14H14L15 13V3L14 2H2ZM2 13V3H14V13H2ZM12 5H4V6H12V5ZM3 4V7H13V4H3ZM7 9H3V8H7V9ZM3 12H7V11H3V12ZM12 9H10V11H12V9ZM9 8V12H13V8H9Z" fill="#C5C5C5"/>
</svg>

After

Width:  |  Height:  |  Size: 312 B

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 2L1 3V13L2 14H14L15 13V3L14 2H2ZM2 13V3H14V13H2ZM12 5H4V6H12V5ZM3 4V7H13V4H3ZM7 9H3V8H7V9ZM3 12H7V11H3V12ZM12 9H10V11H12V9ZM9 8V12H13V8H9Z" fill="#424242"/>
</svg>

After

Width:  |  Height:  |  Size: 312 B

View File

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.219 8.35484C11.6063 8.12309 12.049 8.00047 12.5003 8C12.8904 7.99939 13.2753 8.0901 13.6241 8.26486C13.9729 8.43963 14.276 8.6936 14.5091 9.00646C14.7421 9.31933 14.8987 9.6824 14.9664 10.0666C15.034 10.4509 15.0108 10.8456 14.8985 11.2192C14.7863 11.5929 14.5882 11.9351 14.32 12.2184C14.0518 12.5018 13.7211 12.7185 13.3542 12.8511C12.9873 12.9837 12.5944 13.0287 12.207 12.9823C11.8197 12.9359 11.4485 12.7995 11.1233 12.584L8.7683 14.9399L8.06055 14.2322L10.4163 11.877C10.1677 11.5003 10.0258 11.0634 10.0054 10.6126C9.98511 10.1618 10.0872 9.71384 10.3009 9.31634C10.5145 8.91885 10.8318 8.58659 11.219 8.35484ZM11.667 11.7472C11.9136 11.912 12.2036 12 12.5003 12C12.8981 12 13.2797 11.842 13.561 11.5607C13.8423 11.2794 14.0003 10.8978 14.0003 10.5C14.0003 10.2033 13.9123 9.91332 13.7475 9.66665C13.5827 9.41997 13.3484 9.22772 13.0743 9.11418C12.8002 9.00065 12.4986 8.97095 12.2077 9.02883C11.9167 9.0867 11.6494 9.22956 11.4396 9.43934C11.2299 9.64912 11.087 9.9164 11.0291 10.2074C10.9712 10.4983 11.001 10.7999 11.1145 11.074C11.228 11.3481 11.4203 11.5824 11.667 11.7472Z" fill="#C5C5C5"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 1L14 2V7.33573C13.6829 7.18584 13.3457 7.08481 13 7.03533V2L8 2L8 12.8787L6.87837 14H2L1 13V2L2 1H13ZM9.70794 14H9.70785L10 13.7077V13.7079L9.70794 14ZM13 10.5174C13.0002 10.5116 13.0003 10.5058 13.0003 10.5C13.0003 10.4942 13.0002 10.4884 13 10.4826V10.5174ZM2 2L7 2L7 13H2L2 2Z" fill="#C5C5C5"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.219 8.35484C11.6063 8.12309 12.049 8.00047 12.5003 8C12.8904 7.99939 13.2753 8.0901 13.6241 8.26486C13.9729 8.43963 14.276 8.6936 14.5091 9.00646C14.7421 9.31933 14.8987 9.6824 14.9664 10.0666C15.034 10.4509 15.0108 10.8456 14.8985 11.2192C14.7863 11.5929 14.5882 11.9351 14.32 12.2184C14.0518 12.5018 13.7211 12.7185 13.3542 12.8511C12.9873 12.9837 12.5944 13.0287 12.207 12.9823C11.8197 12.9359 11.4485 12.7995 11.1233 12.584L8.7683 14.9399L8.06055 14.2322L10.4163 11.877C10.1677 11.5003 10.0258 11.0634 10.0054 10.6126C9.98511 10.1618 10.0872 9.71384 10.3009 9.31634C10.5145 8.91885 10.8318 8.58659 11.219 8.35484ZM11.667 11.7472C11.9136 11.912 12.2036 12 12.5003 12C12.8981 12 13.2797 11.842 13.561 11.5607C13.8423 11.2794 14.0003 10.8978 14.0003 10.5C14.0003 10.2033 13.9123 9.91332 13.7475 9.66665C13.5827 9.41997 13.3484 9.22772 13.0743 9.11418C12.8002 9.00065 12.4986 8.97095 12.2077 9.02883C11.9167 9.0867 11.6494 9.22956 11.4396 9.43934C11.2299 9.64912 11.087 9.9164 11.0291 10.2074C10.9712 10.4983 11.001 10.7999 11.1145 11.074C11.228 11.3481 11.4203 11.5824 11.667 11.7472Z" fill="#424242"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 1L14 2V7.33573C13.6829 7.18584 13.3457 7.08481 13 7.03533V2L8 2L8 12.8787L6.87837 14H2L1 13V2L2 1H13ZM9.70794 14H9.70785L10 13.7077V13.7079L9.70794 14ZM13 10.5174C13.0002 10.5116 13.0003 10.5058 13.0003 10.5C13.0003 10.4942 13.0002 10.4884 13 10.4826V10.5174ZM2 2L7 2L7 13H2L2 2Z" fill="#424242"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.06065 3.85356L5.91421 6L5.2071 5.29289L6.49999 4H3.5C3.10218 4 2.72064 4.15804 2.43934 4.43934C2.15804 4.72065 2 5.10218 2 5.5C2 5.89783 2.15804 6.27936 2.43934 6.56066C2.72064 6.84197 3.10218 7 3.5 7H4V8H3.5C2.83696 8 2.20107 7.73661 1.73223 7.26777C1.26339 6.79893 1 6.16305 1 5.5C1 4.83696 1.26339 4.20108 1.73223 3.73224C2.20107 3.2634 2.83696 3 3.5 3H6.49999L6.49999 3H6.49996L6 2.50004V2.50001L5.2071 1.70711L5.91421 1L8.06065 3.14645L8.06065 3.85356ZM5 6.50003L5.91421 7.41424L6 7.32845V14H14V7H10V3H9.06065V2.73227L8.32838 2H11.2L11.5 2.1L14.9 5.6L15 6V14.5L14.5 15H5.5L5 14.5V9.00003V6.50003ZM11 3V6H13.9032L11 3Z" fill="#C5C5C5"/>
</svg>

After

Width:  |  Height:  |  Size: 796 B

View File

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.06065 3.85356L5.91421 6L5.2071 5.29289L6.49999 4H3.5C3.10218 4 2.72064 4.15804 2.43934 4.43934C2.15804 4.72065 2 5.10218 2 5.5C2 5.89783 2.15804 6.27936 2.43934 6.56066C2.72064 6.84197 3.10218 7 3.5 7H4V8H3.5C2.83696 8 2.20107 7.73661 1.73223 7.26777C1.26339 6.79893 1 6.16305 1 5.5C1 4.83696 1.26339 4.20108 1.73223 3.73224C2.20107 3.2634 2.83696 3 3.5 3H6.49999L6.49999 3H6.49996L6 2.50004V2.50001L5.2071 1.70711L5.91421 1L8.06065 3.14645L8.06065 3.85356ZM5 6.50003L5.91421 7.41424L6 7.32845V14H14V7H10V3H9.06065V2.73227L8.32838 2H11.2L11.5 2.1L14.9 5.6L15 6V14.5L14.5 15H5.5L5 14.5V9.00003V6.50003ZM11 3V6H13.9032L11 3Z" fill="#424242"/>
</svg>

After

Width:  |  Height:  |  Size: 796 B

View File

@@ -4,7 +4,9 @@
"description": "%description%",
"version": "1.0.0",
"icon": "icon.png",
"publisher": "vscode",
"publisher": "vscode",
"enableProposedApi": true,
"license": "MIT",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"engines": {
"vscode": "^1.20.0"
@@ -32,8 +34,8 @@
"title": "%markdown.preview.title%",
"category": "Markdown",
"icon": {
"light": "./media/Preview.svg",
"dark": "./media/Preview_inverse.svg"
"light": "./media/preview-light.svg",
"dark": "./media/preview-dark.svg"
}
},
{
@@ -41,8 +43,8 @@
"title": "%markdown.previewSide.title%",
"category": "Markdown",
"icon": {
"light": "./media/PreviewOnRightPane_16x.svg",
"dark": "./media/PreviewOnRightPane_16x_dark.svg"
"light": "./media/preview-right-light.svg",
"dark": "./media/preview-right-dark.svg"
}
},
{
@@ -50,8 +52,8 @@
"title": "%markdown.showLockedPreviewToSide.title%",
"category": "Markdown",
"icon": {
"light": "./media/PreviewOnRightPane_16x.svg",
"dark": "./media/PreviewOnRightPane_16x_dark.svg"
"light": "./media/preview-right-light.svg",
"dark": "./media/preview-right-dark.svg"
}
},
{
@@ -59,8 +61,8 @@
"title": "%markdown.showSource.title%",
"category": "Markdown",
"icon": {
"light": "./media/ViewSource.svg",
"dark": "./media/ViewSource_inverse.svg"
"light": "./media/view-source-light.svg",
"dark": "./media/view-source-dark.svg"
}
},
{
@@ -313,7 +315,7 @@
"build-preview": "webpack --mode development"
},
"dependencies": {
"highlight.js": "9.13.1",
"highlight.js": "9.15.8",
"markdown-it": "^8.4.2",
"markdown-it-front-matter": "^0.1.2",
"vscode-extension-telemetry": "0.1.1",
@@ -323,7 +325,7 @@
"@types/highlight.js": "9.12.3",
"@types/lodash.throttle": "^4.1.3",
"@types/markdown-it": "0.0.2",
"@types/node": "^10.12.21",
"@types/node": "^10.14.8",
"lodash.throttle": "^4.1.1",
"mocha-junit-reporter": "^1.17.0",
"mocha-multi-reporters": "^1.1.7",

View File

@@ -19,7 +19,7 @@ const settings = getSettings();
const vscode = acquireVsCodeApi();
// Set VS Code state
let state = getData('data-state');
let state = getData<{ line: number }>('data-state');
vscode.setState(state);
const messaging = createPosterForVsCode(vscode);
@@ -131,8 +131,8 @@ document.addEventListener('click', event => {
if (node.getAttribute('href').startsWith('#')) {
break;
}
if (node.href.startsWith('file://') || node.href.startsWith('vscode-resource:')) {
const [path, fragment] = node.href.replace(/^(file:\/\/|vscode-resource:)/i, '').split('#');
if (node.href.startsWith('file://') || node.href.startsWith('vscode-resource:') || node.href.startsWith(settings.webviewResourceRoot)) {
const [path, fragment] = node.href.replace(/^(file:\/\/|vscode-resource:)/i, '').replace(new RegExp(`^${escapeRegExp(settings.webviewResourceRoot)}`)).split('#');
messaging.postMessage('clickLink', { path, fragment });
event.preventDefault();
event.stopPropagation();
@@ -157,4 +157,8 @@ if (settings.scrollEditorWithPreview) {
}
}
}, 50));
}
function escapeRegExp(text: string) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}

View File

@@ -4,18 +4,19 @@
*--------------------------------------------------------------------------------------------*/
export interface PreviewSettings {
source: string;
line: number;
lineCount: number;
scrollPreviewWithEditor?: boolean;
scrollEditorWithPreview: boolean;
disableSecurityWarnings: boolean;
doubleClickToSwitchToEditor: boolean;
readonly source: string;
readonly line: number;
readonly lineCount: number;
readonly scrollPreviewWithEditor?: boolean;
readonly scrollEditorWithPreview: boolean;
readonly disableSecurityWarnings: boolean;
readonly doubleClickToSwitchToEditor: boolean;
readonly webviewResourceRoot: string;
}
let cachedSettings: PreviewSettings | undefined = undefined;
export function getData(key: string): PreviewSettings {
export function getData<T = {}>(key: string): T {
const element = document.getElementById('vscode-markdown-preview-data');
if (element) {
const data = element.getAttribute(key);

View File

@@ -5,17 +5,20 @@
import * as path from 'path';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { OpenDocumentLinkCommand } from '../commands/openDocumentLink';
import { getUriForLinkWithKnownExternalScheme } from '../util/links';
function normalizeLink(
const localize = nls.loadMessageBundle();
function parseLink(
document: vscode.TextDocument,
link: string,
base: string
): vscode.Uri {
): { uri: vscode.Uri, tooltip?: string } {
const externalSchemeUri = getUriForLinkWithKnownExternalScheme(link);
if (externalSchemeUri) {
return externalSchemeUri;
return { uri: externalSchemeUri };
}
// Assume it must be an relative or absolute file path
@@ -34,7 +37,10 @@ function normalizeLink(
resourcePath = base ? path.join(base, tempUri.path) : tempUri.path;
}
return OpenDocumentLinkCommand.createCommandUri(resourcePath, tempUri.fragment);
return {
uri: OpenDocumentLinkCommand.createCommandUri(resourcePath, tempUri.fragment),
tooltip: localize('documentLink.tooltip', 'Follow link')
};
}
function matchAll(
@@ -61,18 +67,21 @@ function extractDocumentLink(
const linkStart = document.positionAt(offset);
const linkEnd = document.positionAt(offset + link.length);
try {
return new vscode.DocumentLink(
const { uri, tooltip } = parseLink(document, link, base);
const documentLink = new vscode.DocumentLink(
new vscode.Range(linkStart, linkEnd),
normalizeLink(document, link, base));
uri);
documentLink.tooltip = tooltip;
return documentLink;
} catch (e) {
return undefined;
}
}
export default class LinkProvider implements vscode.DocumentLinkProvider {
private readonly linkPattern = /(\[((!\[[^\]]*?\]\(\s*)([^\s\(\)]+?)\s*\)\]|[^\]]*\])\(\s*)(([^\s\(\)]|\(\S*?\))+)\s*(".*?")?\)/g;
private readonly referenceLinkPattern = /(\[([^\]]+)\]\[\s*?)([^\s\]]*?)\]/g;
private readonly definitionPattern = /^([\t ]*\[([^\]]+)\]:\s*)(\S+)/gm;
private readonly linkPattern = /(\[((!\[[^\]]*?\]\(\s*)([^\s\(\)]+?)\s*\)\]|(?:\\\]|[^\]])*\])\(\s*)(([^\s\(\)]|\(\S*?\))+)\s*(".*?")?\)/g;
private readonly referenceLinkPattern = /(\[((?:\\\]|[^\]])+)\]\[\s*?)([^\s\]]*?)\]/g;
private readonly definitionPattern = /^([\t ]*\[((?:\\\]|[^\]])+)\]:\s*)(\S+)/gm;
public provideDocumentLinks(
document: vscode.TextDocument,
@@ -144,11 +153,10 @@ export default class LinkProvider implements vscode.DocumentLinkProvider {
}
}
for (const definition of Array.from(definitions.values())) {
for (const definition of definitions.values()) {
try {
results.push(new vscode.DocumentLink(
definition.linkRange,
normalizeLink(document, definition.link, base)));
const { uri } = parseLink(document, definition.link, base);
results.push(new vscode.DocumentLink(definition.linkRange, uri));
} catch (e) {
// noop
}

View File

@@ -16,6 +16,7 @@ import { MarkdownPreviewConfigurationManager } from './previewConfig';
import { MarkdownContributionProvider, MarkdownContributions } from '../markdownExtensions';
import { isMarkdownFile } from '../util/file';
import { resolveLinkToMarkdownFile } from '../commands/openDocumentLink';
import { WebviewResourceProvider, normalizeResource } from '../util/resources';
const localize = nls.loadMessageBundle();
interface WebviewMessage {
@@ -345,8 +346,8 @@ export class MarkdownPreview extends Disposable {
private get iconPath() {
const root = path.join(this._contributionProvider.extensionPath, 'media');
return {
light: vscode.Uri.file(path.join(root, 'Preview.svg')),
dark: vscode.Uri.file(path.join(root, 'Preview_inverse.svg'))
light: vscode.Uri.file(path.join(root, 'preview-light.svg')),
dark: vscode.Uri.file(path.join(root, 'preview-dark.svg'))
};
}
@@ -388,31 +389,46 @@ export class MarkdownPreview extends Disposable {
}
private async doUpdate(): Promise<void> {
const resource = this._resource;
if (this._disposed) {
return;
}
const markdownResource = this._resource;
clearTimeout(this.throttleTimer);
this.throttleTimer = undefined;
let document: vscode.TextDocument;
try {
document = await vscode.workspace.openTextDocument(resource);
document = await vscode.workspace.openTextDocument(markdownResource);
} catch {
await this.showFileNotFoundError();
return;
}
const pendingVersion = new PreviewDocumentVersion(resource, document.version);
if (this._disposed) {
return;
}
const pendingVersion = new PreviewDocumentVersion(markdownResource, document.version);
if (!this.forceUpdate && this.currentVersion && this.currentVersion.equals(pendingVersion)) {
if (this.line) {
this.updateForView(resource, this.line);
this.updateForView(markdownResource, this.line);
}
return;
}
this.forceUpdate = false;
this.currentVersion = pendingVersion;
if (this._resource === resource) {
const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state);
if (this._resource === markdownResource) {
const self = this;
const resourceProvider: WebviewResourceProvider = {
toWebviewResource: (resource) => {
return this.editor.webview.toWebviewResource(normalizeResource(markdownResource, resource));
},
get cspSource() { return self.editor.webview.cspSource; }
};
const content = await this._contentProvider.provideTextDocumentContent(document, resourceProvider, this._previewConfigurations, this.line, this.state);
// Another call to `doUpdate` may have happened.
// Make sure we are still updating for the correct document
if (this.currentVersion && this.currentVersion.equals(pendingVersion)) {
@@ -432,21 +448,19 @@ export class MarkdownPreview extends Disposable {
}
private static getLocalResourceRoots(
resource: vscode.Uri,
base: vscode.Uri,
contributions: MarkdownContributions
): ReadonlyArray<vscode.Uri> {
const baseRoots = contributions.previewResourceRoots;
const baseRoots = Array.from(contributions.previewResourceRoots);
const folder = vscode.workspace.getWorkspaceFolder(resource);
const folder = vscode.workspace.getWorkspaceFolder(base);
if (folder) {
return baseRoots.concat(folder.uri);
baseRoots.push(folder.uri);
} else if (!base.scheme || base.scheme === 'file') {
baseRoots.push(vscode.Uri.file(path.dirname(base.fsPath)));
}
if (!resource.scheme || resource.scheme === 'file') {
return baseRoots.concat(vscode.Uri.file(path.dirname(resource.fsPath)));
}
return baseRoots;
return baseRoots.map(root => normalizeResource(base, root));
}
private onDidScrollPreview(line: number) {

View File

@@ -3,17 +3,17 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as path from 'path';
import { MarkdownEngine } from '../markdownEngine';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { Logger } from '../logger';
import { ContentSecurityPolicyArbiter, MarkdownPreviewSecurityLevel } from '../security';
import { MarkdownPreviewConfigurationManager, MarkdownPreviewConfiguration } from './previewConfig';
import { MarkdownEngine } from '../markdownEngine';
import { MarkdownContributionProvider } from '../markdownExtensions';
import { ContentSecurityPolicyArbiter, MarkdownPreviewSecurityLevel } from '../security';
import { WebviewResourceProvider } from '../util/resources';
import { MarkdownPreviewConfiguration, MarkdownPreviewConfigurationManager } from './previewConfig';
const localize = nls.loadMessageBundle();
/**
* Strings used inside the markdown preview.
@@ -35,8 +35,8 @@ const previewStrings = {
'Content Disabled Security Warning')
};
function escapeAttribute(value: string): string {
return value.replace(/"/g, '&quot;');
function escapeAttribute(value: string | vscode.Uri): string {
return value.toString().replace(/"/g, '&quot;');
}
export class MarkdownContentProvider {
@@ -50,6 +50,7 @@ export class MarkdownContentProvider {
public async provideTextDocumentContent(
markdownDocument: vscode.TextDocument,
resourceProvider: WebviewResourceProvider,
previewConfigurations: MarkdownPreviewConfigurationManager,
initialLine: number | undefined = undefined,
state?: any
@@ -63,18 +64,19 @@ export class MarkdownContentProvider {
scrollPreviewWithEditor: config.scrollPreviewWithEditor,
scrollEditorWithPreview: config.scrollEditorWithPreview,
doubleClickToSwitchToEditor: config.doubleClickToSwitchToEditor,
disableSecurityWarnings: this.cspArbiter.shouldDisableSecurityWarnings()
disableSecurityWarnings: this.cspArbiter.shouldDisableSecurityWarnings(),
webviewResourceRoot: resourceProvider.toWebviewResource(markdownDocument.uri).toString(),
};
this.logger.log('provideTextDocumentContent', initialData);
// Content Security Policy
const nonce = new Date().getTime() + '' + new Date().getMilliseconds();
const csp = this.getCspForResource(sourceUri, nonce);
const csp = this.getCsp(resourceProvider, sourceUri, nonce);
const body = await this.engine.render(markdownDocument);
return `<!DOCTYPE html>
<html>
<html style="${escapeAttribute(this.getSettingsOverrideStyles(config))}">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
${csp}
@@ -82,14 +84,14 @@ export class MarkdownContentProvider {
data-settings="${escapeAttribute(JSON.stringify(initialData))}"
data-strings="${escapeAttribute(JSON.stringify(previewStrings))}"
data-state="${escapeAttribute(JSON.stringify(state || {}))}">
<script src="${this.extensionResourcePath('pre.js')}" nonce="${nonce}"></script>
${this.getStyles(sourceUri, nonce, config, state)}
<base href="${markdownDocument.uri.with({ scheme: 'vscode-resource' }).toString(true)}">
<script src="${this.extensionResourcePath(resourceProvider, 'pre.js')}" nonce="${nonce}"></script>
${this.getStyles(resourceProvider, sourceUri, config, state)}
<base href="${resourceProvider.toWebviewResource(markdownDocument.uri)}">
</head>
<body class="vscode-body ${config.scrollBeyondLastLine ? 'scrollBeyondLastLine' : ''} ${config.wordWrap ? 'wordWrap' : ''} ${config.markEditorSelection ? 'showEditorSelection' : ''}">
${body}
<div class="code-line" data-line="${markdownDocument.lineCount}"></div>
${this.getScripts(nonce)}
${this.getScripts(resourceProvider, nonce)}
</body>
</html>`;
}
@@ -107,13 +109,13 @@ export class MarkdownContentProvider {
</html>`;
}
private extensionResourcePath(mediaFile: string): string {
return vscode.Uri.file(this.context.asAbsolutePath(path.join('media', mediaFile)))
.with({ scheme: 'vscode-resource' })
.toString();
private extensionResourcePath(resourceProvider: WebviewResourceProvider, mediaFile: string): string {
const webviewResource = resourceProvider.toWebviewResource(
vscode.Uri.file(this.context.asAbsolutePath(path.join('media', mediaFile))));
return webviewResource.toString();
}
private fixHref(resource: vscode.Uri, href: string): string {
private fixHref(resourceProvider: WebviewResourceProvider, resource: vscode.Uri, href: string): string {
if (!href) {
return href;
}
@@ -124,42 +126,36 @@ export class MarkdownContentProvider {
// Assume it must be a local file
if (path.isAbsolute(href)) {
return vscode.Uri.file(href)
.with({ scheme: 'vscode-resource' })
.toString();
return resourceProvider.toWebviewResource(vscode.Uri.file(href)).toString();
}
// Use a workspace relative path if there is a workspace
const root = vscode.workspace.getWorkspaceFolder(resource);
if (root) {
return vscode.Uri.file(path.join(root.uri.fsPath, href))
.with({ scheme: 'vscode-resource' })
.toString();
return resourceProvider.toWebviewResource(vscode.Uri.file(path.join(root.uri.fsPath, href))).toString();
}
// Otherwise look relative to the markdown file
return vscode.Uri.file(path.join(path.dirname(resource.fsPath), href))
.with({ scheme: 'vscode-resource' })
.toString();
return resourceProvider.toWebviewResource(vscode.Uri.file(path.join(path.dirname(resource.fsPath), href))).toString();
}
private computeCustomStyleSheetIncludes(resource: vscode.Uri, config: MarkdownPreviewConfiguration): string {
if (Array.isArray(config.styles)) {
return config.styles.map(style => {
return `<link rel="stylesheet" class="code-user-style" data-source="${escapeAttribute(style)}" href="${escapeAttribute(this.fixHref(resource, style))}" type="text/css" media="screen">`;
}).join('\n');
private computeCustomStyleSheetIncludes(resourceProvider: WebviewResourceProvider, resource: vscode.Uri, config: MarkdownPreviewConfiguration): string {
if (!Array.isArray(config.styles)) {
return '';
}
return '';
const out: string[] = [];
for (const style of config.styles) {
out.push(`<link rel="stylesheet" class="code-user-style" data-source="${escapeAttribute(style)}" href="${escapeAttribute(this.fixHref(resourceProvider, resource, style))}" type="text/css" media="screen">`);
}
return out.join('\n');
}
private getSettingsOverrideStyles(nonce: string, config: MarkdownPreviewConfiguration): string {
return `<style nonce="${nonce}">
html, body {
${config.fontFamily ? `font-family: ${config.fontFamily};` : ''}
${isNaN(config.fontSize) ? '' : `font-size: ${config.fontSize}px;`}
${isNaN(config.lineHeight) ? '' : `line-height: ${config.lineHeight};`}
}
</style>`;
private getSettingsOverrideStyles(config: MarkdownPreviewConfiguration): string {
return [
config.fontFamily ? `--vscode-markdown-font-family: ${config.fontFamily};` : '',
isNaN(config.fontSize) ? '' : `--vscode-markdown-font-size: ${config.fontSize}px;`,
isNaN(config.lineHeight) ? '' : `--vscode-markdown-line-height: ${config.lineHeight};`,
].join(' ');
}
private getImageStabilizerStyles(state?: any) {
@@ -177,37 +173,47 @@ export class MarkdownContentProvider {
return ret;
}
private getStyles(resource: vscode.Uri, nonce: string, config: MarkdownPreviewConfiguration, state?: any): string {
const baseStyles = this.contributionProvider.contributions.previewStyles
.map(resource => `<link rel="stylesheet" type="text/css" href="${escapeAttribute(resource.toString())}">`)
.join('\n');
private getStyles(resourceProvider: WebviewResourceProvider, resource: vscode.Uri, config: MarkdownPreviewConfiguration, state?: any): string {
const baseStyles: string[] = [];
for (const resource of this.contributionProvider.contributions.previewStyles) {
baseStyles.push(`<link rel="stylesheet" type="text/css" href="${escapeAttribute(resourceProvider.toWebviewResource(resource))}">`);
}
return `${baseStyles}
${this.getSettingsOverrideStyles(nonce, config)}
${this.computeCustomStyleSheetIncludes(resource, config)}
return `${baseStyles.join('\n')}
${this.computeCustomStyleSheetIncludes(resourceProvider, resource, config)}
${this.getImageStabilizerStyles(state)}`;
}
private getScripts(nonce: string): string {
return this.contributionProvider.contributions.previewScripts
.map(resource => `<script async src="${escapeAttribute(resource.toString())}" nonce="${nonce}" charset="UTF-8"></script>`)
.join('\n');
private getScripts(resourceProvider: WebviewResourceProvider, nonce: string): string {
const out: string[] = [];
for (const resource of this.contributionProvider.contributions.previewScripts) {
out.push(`<script async
src="${escapeAttribute(resourceProvider.toWebviewResource(resource))}"
nonce="${nonce}"
charset="UTF-8"></script>`);
}
return out.join('\n');
}
private getCspForResource(resource: vscode.Uri, nonce: string): string {
private getCsp(
provider: WebviewResourceProvider,
resource: vscode.Uri,
nonce: string
): string {
const rule = provider.cspSource;
switch (this.cspArbiter.getSecurityLevelForResource(resource)) {
case MarkdownPreviewSecurityLevel.AllowInsecureContent:
return `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: http: https: data:; media-src vscode-resource: http: https: data:; script-src 'nonce-${nonce}'; style-src vscode-resource: 'unsafe-inline' http: https: data:; font-src vscode-resource: http: https: data:;">`;
return `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' ${rule} http: https: data:; media-src 'self' ${rule} http: https: data:; script-src 'nonce-${nonce}'; style-src 'self' ${rule} 'unsafe-inline' http: https: data:; font-src 'self' ${rule} http: https: data:;">`;
case MarkdownPreviewSecurityLevel.AllowInsecureLocalContent:
return `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https: data: http://localhost:* http://127.0.0.1:*; media-src vscode-resource: https: data: http://localhost:* http://127.0.0.1:*; script-src 'nonce-${nonce}'; style-src vscode-resource: 'unsafe-inline' https: data: http://localhost:* http://127.0.0.1:*; font-src vscode-resource: https: data: http://localhost:* http://127.0.0.1:*;">`;
return `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' ${rule} https: data: http://localhost:* http://127.0.0.1:*; media-src 'self' ${rule} https: data: http://localhost:* http://127.0.0.1:*; script-src 'nonce-${nonce}'; style-src 'self' ${rule} 'unsafe-inline' https: data: http://localhost:* http://127.0.0.1:*; font-src 'self' ${rule} https: data: http://localhost:* http://127.0.0.1:*;">`;
case MarkdownPreviewSecurityLevel.AllowScriptsAndAllContent:
return '';
case MarkdownPreviewSecurityLevel.Strict:
default:
return `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https: data:; media-src vscode-resource: https: data:; script-src 'nonce-${nonce}'; style-src vscode-resource: 'unsafe-inline' https: data:; font-src vscode-resource: https: data:;">`;
return `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self' ${rule} https: data:; media-src 'self' ${rule} https: data:; script-src 'nonce-${nonce}'; style-src 'self' ${rule} 'unsafe-inline' https: data:; font-src 'self' ${rule} https: data:;">`;
}
}
}

View File

@@ -234,7 +234,6 @@ export class MarkdownEngine {
return normalizeLink(externalSchemeUri.toString(true));
}
// Assume it must be an relative or absolute file path
// Use a fake scheme to avoid parse warnings
let uri = vscode.Uri.parse(`vscode-resource:${link}`);
@@ -271,7 +270,7 @@ export class MarkdownEngine {
const validateLink = md.validateLink;
md.validateLink = (link: string) => {
// support file:// links
return validateLink(link) || link.indexOf('file:') === 0;
return validateLink(link) || link.startsWith('file:') || /^data:image\/.*?;/.test(link);
};
}

View File

@@ -9,8 +9,7 @@ import { Disposable } from './util/dispose';
import * as arrays from './util/arrays';
const resolveExtensionResource = (extension: vscode.Extension<any>, resourcePath: string): vscode.Uri => {
return vscode.Uri.file(path.join(extension.extensionPath, resourcePath))
.with({ scheme: 'vscode-resource' });
return vscode.Uri.file(path.join(extension.extensionPath, resourcePath));
};
const resolveExtensionResources = (extension: vscode.Extension<any>, resourcePaths: unknown): vscode.Uri[] => {

View File

@@ -72,6 +72,14 @@ suite('markdown.DocumentLinkProvider', () => {
assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 25));
});
// #35245
test('Should handle links with escaped characters in name', () => {
const links = getLinksForFile('a [b\\]](./file)');
assert.strictEqual(links.length, 1);
const [link] = links;
assertRangeEqual(link.range, new vscode.Range(0, 8, 0, 14));
});
test('Should handle links with balanced parens', () => {
{

View File

@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export interface WebviewResourceProvider {
toWebviewResource(resource: vscode.Uri): vscode.Uri;
readonly cspSource: string;
}
export function normalizeResource(
base: vscode.Uri,
resource: vscode.Uri
): vscode.Uri {
// If we have a windows path and are loading a workspace with an authority,
// make sure we use a unc path with an explicit localhost authority.
//
// Otherwise, the `<base>` rule will insert the authority into the resolved resource
// URI incorrectly.
if (base.authority && !resource.authority) {
const driveMatch = resource.path.match(/^\/(\w):\//);
if (driveMatch) {
return vscode.Uri.file(`\\\\localhost\\${driveMatch[1]}$\\${resource.fsPath.replace(/^\w:\\/, '')}`).with({
fragment: resource.fragment,
query: resource.query
});
}
}
return resource;
}

View File

@@ -29,10 +29,10 @@
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.2.tgz#5d9ad19e6e6508cdd2f2596df86fd0aade598660"
integrity sha1-XZrRnm5lCM3S8llt+G/Qqt5ZhmA=
"@types/node@^10.12.21":
version "10.12.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.21.tgz#7e8a0c34cf29f4e17a36e9bd0ea72d45ba03908e"
integrity sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
abbrev@1:
version "1.1.1"
@@ -2933,10 +2933,10 @@ he@1.1.1:
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0=
highlight.js@9.13.1:
version "9.13.1"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.13.1.tgz#054586d53a6863311168488a0f58d6c505ce641e"
integrity sha512-Sc28JNQNDzaH6PORtRLMvif9RSn1mYuOoX3omVjnb0+HbpPygU2ALBI0R/wsiqCb4/fcp07Gdo8g+fhtFrQl6A==
highlight.js@9.15.8:
version "9.15.8"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.15.8.tgz#f344fda123f36f1a65490e932cf90569e4999971"
integrity sha512-RrapkKQWwE+wKdF73VsOa2RQdIoO3mxwJ4P8mhbI6KYJUraUHRKM5w5zQQKXNk0xNL4UVRdulV9SBJcmzJNzVA==
hmac-drbg@^1.0.0:
version "1.0.1"

View File

@@ -5,6 +5,7 @@
"description": "%description%",
"icon": "resources/icons/merge-conflict.png",
"version": "1.0.0",
"license": "MIT",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"engines": {
"vscode": "^1.5.0"
@@ -114,6 +115,21 @@
"type": "boolean",
"description": "%config.autoNavigateNextConflictEnabled%",
"default": false
},
"merge-conflict.diffViewPosition": {
"type": "string",
"enum": [
"Current",
"Beside",
"Below"
],
"description": "%config.diffViewPosition%",
"enumDescriptions": [
"%config.diffViewPosition.current%",
"%config.diffViewPosition.beside%",
"%config.diffViewPosition.below%"
],
"default": "Current"
}
}
}
@@ -122,6 +138,6 @@
"vscode-nls": "^4.0.0"
},
"devDependencies": {
"@types/node": "8.0.33"
"@types/node": "^10.14.8"
}
}

View File

@@ -15,5 +15,9 @@
"config.title": "Merge Conflict",
"config.autoNavigateNextConflictEnabled": "Whether to automatically navigate to the next merge conflict after resolving a merge conflict.",
"config.codeLensEnabled": "Create a Code Lens for merge conflict blocks within editor.",
"config.decoratorsEnabled": "Create decorators for merge conflict blocks within editor."
"config.decoratorsEnabled": "Create decorators for merge conflict blocks within editor.",
"config.diffViewPosition": "Controls where the diff view should be opened when comparing changes in merge conflicts.",
"config.diffViewPosition.current": "Open the diff view in the current editor group.",
"config.diffViewPosition.beside": "Open the diff view next to the current editor group.",
"config.diffViewPosition.below": "Open the diff view below the current editor group."
}

View File

@@ -34,8 +34,8 @@ export default class CommandHandler implements vscode.Disposable {
this.registerTextEditorCommand('merge-conflict.accept.incoming', this.acceptIncoming),
this.registerTextEditorCommand('merge-conflict.accept.selection', this.acceptSelection),
this.registerTextEditorCommand('merge-conflict.accept.both', this.acceptBoth),
this.registerTextEditorCommand('merge-conflict.accept.all-current', this.acceptAllCurrent),
this.registerTextEditorCommand('merge-conflict.accept.all-incoming', this.acceptAllIncoming),
this.registerTextEditorCommand('merge-conflict.accept.all-current', this.acceptAllCurrent, this.acceptAllCurrentResources),
this.registerTextEditorCommand('merge-conflict.accept.all-incoming', this.acceptAllIncoming, this.acceptAllIncomingResources),
this.registerTextEditorCommand('merge-conflict.accept.all-both', this.acceptAllBoth),
this.registerTextEditorCommand('merge-conflict.next', this.navigateNext),
this.registerTextEditorCommand('merge-conflict.previous', this.navigatePrevious),
@@ -43,8 +43,11 @@ export default class CommandHandler implements vscode.Disposable {
);
}
private registerTextEditorCommand(command: string, cb: (editor: vscode.TextEditor, ...args: any[]) => Promise<void>) {
private registerTextEditorCommand(command: string, cb: (editor: vscode.TextEditor, ...args: any[]) => Promise<void>, resourceCB?: (uris: vscode.Uri[]) => Promise<void>) {
return vscode.commands.registerCommand(command, (...args) => {
if (resourceCB && args.length && args.every(arg => arg && arg.resourceUri)) {
return resourceCB.call(this, args.map(arg => arg.resourceUri));
}
const editor = vscode.window.activeTextEditor;
return editor && cb.call(this, editor, ...args);
});
@@ -70,6 +73,14 @@ export default class CommandHandler implements vscode.Disposable {
return this.acceptAll(interfaces.CommitType.Incoming, editor);
}
acceptAllCurrentResources(resources: vscode.Uri[]): Promise<void> {
return this.acceptAllResources(interfaces.CommitType.Current, resources);
}
acceptAllIncomingResources(resources: vscode.Uri[]): Promise<void> {
return this.acceptAllResources(interfaces.CommitType.Incoming, resources);
}
acceptAllBoth(editor: vscode.TextEditor): Promise<void> {
return this.acceptAll(interfaces.CommitType.Both, editor);
}
@@ -88,18 +99,54 @@ export default class CommandHandler implements vscode.Disposable {
}
}
const conflicts = await this.tracker.getConflicts(editor.document);
// Still failed to find conflict, warn the user and exit
if (!conflicts) {
vscode.window.showWarningMessage(localize('cursorNotInConflict', 'Editor cursor is not within a merge conflict'));
return;
}
const scheme = editor.document.uri.scheme;
let range = conflict.current.content;
let leftRanges = conflicts.map(conflict => [conflict.current.content, conflict.range]);
let rightRanges = conflicts.map(conflict => [conflict.incoming.content, conflict.range]);
const leftUri = editor.document.uri.with({
scheme: ContentProvider.scheme,
query: JSON.stringify({ scheme, range })
query: JSON.stringify({ scheme, range: range, ranges: leftRanges })
});
range = conflict.incoming.content;
const rightUri = leftUri.with({ query: JSON.stringify({ scheme, range }) });
const rightUri = leftUri.with({ query: JSON.stringify({ scheme, ranges: rightRanges }) });
let mergeConflictLineOffsets = 0;
for (let nextconflict of conflicts) {
if (nextconflict.range.isEqual(conflict.range)) {
break;
} else {
mergeConflictLineOffsets += (nextconflict.range.end.line - nextconflict.range.start.line) - (nextconflict.incoming.content.end.line - nextconflict.incoming.content.start.line);
}
}
const selection = new vscode.Range(
conflict.range.start.line - mergeConflictLineOffsets, conflict.range.start.character,
conflict.range.start.line - mergeConflictLineOffsets, conflict.range.start.character
);
const title = localize('compareChangesTitle', '{0}: Current Changes ⟷ Incoming Changes', fileName);
vscode.commands.executeCommand('vscode.diff', leftUri, rightUri, title);
const mergeConflictConfig = vscode.workspace.getConfiguration('merge-conflict');
const openToTheSide = mergeConflictConfig.get<string>('diffViewPosition');
const opts: vscode.TextDocumentShowOptions = {
viewColumn: openToTheSide === 'Beside' ? vscode.ViewColumn.Beside : vscode.ViewColumn.Active,
selection
};
if (openToTheSide === 'Below') {
await vscode.commands.executeCommand('workbench.action.newGroupBelow');
}
await vscode.commands.executeCommand('vscode.diff', leftUri, rightUri, title, opts);
}
navigateNext(editor: vscode.TextEditor): Promise<void> {
@@ -223,10 +270,31 @@ export default class CommandHandler implements vscode.Disposable {
// Apply all changes as one edit
await editor.edit((edit) => conflicts.forEach(conflict => {
conflict.applyEdit(type, editor, edit);
conflict.applyEdit(type, editor.document, edit);
}));
}
private async acceptAllResources(type: interfaces.CommitType, resources: vscode.Uri[]): Promise<void> {
const documents = await Promise.all(resources.map(resource => vscode.workspace.openTextDocument(resource)));
const edit = new vscode.WorkspaceEdit();
for (const document of documents) {
const conflicts = await this.tracker.getConflicts(document);
if (!conflicts || conflicts.length === 0) {
continue;
}
// For get the current state of the document, as we know we are doing to do a large edit
this.tracker.forget(document);
// Apply all changes as one edit
conflicts.forEach(conflict => {
conflict.applyEdit(type, document, { replace: (range, newText) => edit.replace(document.uri, range, newText) });
});
}
vscode.workspace.applyEdit(edit);
}
private async findConflictContainingSelection(editor: vscode.TextEditor, conflicts?: interfaces.IDocumentMergeConflict[]): Promise<interfaces.IDocumentMergeConflict | null> {
if (!conflicts) {

View File

@@ -23,11 +23,27 @@ export default class MergeConflictContentProvider implements vscode.TextDocument
async provideTextDocumentContent(uri: vscode.Uri): Promise<string | null> {
try {
const { scheme, range } = JSON.parse(uri.query) as { scheme: string; range: { line: number, character: number }[] };
const [start, end] = range;
const { scheme, ranges } = JSON.parse(uri.query) as { scheme: string, ranges: [{ line: number, character: number }[], { line: number, character: number }[]][] };
// complete diff
const document = await vscode.workspace.openTextDocument(uri.with({ scheme, query: '' }));
const text = document.getText(new vscode.Range(start.line, start.character, end.line, end.character));
let text = '';
let lastPosition = new vscode.Position(0, 0);
ranges.forEach(rangeObj => {
let [conflictRange, fullRange] = rangeObj;
const [start, end] = conflictRange;
const [fullStart, fullEnd] = fullRange;
text += document.getText(new vscode.Range(lastPosition.line, lastPosition.character, fullStart.line, fullStart.character));
text += document.getText(new vscode.Range(start.line, start.character, end.line, end.character));
lastPosition = new vscode.Position(fullEnd.line, fullEnd.character);
});
let documentEnd = document.lineAt(document.lineCount - 1).range.end;
text += document.getText(new vscode.Range(lastPosition.line, lastPosition.character, documentEnd.line, documentEnd.character));
return text;
}
catch (ex) {

View File

@@ -25,14 +25,14 @@ export class DocumentMergeConflict implements interfaces.IDocumentMergeConflict
if (edit) {
this.applyEdit(type, editor, edit);
this.applyEdit(type, editor.document, edit);
return Promise.resolve(true);
}
return editor.edit((edit) => this.applyEdit(type, editor, edit));
return editor.edit((edit) => this.applyEdit(type, editor.document, edit));
}
public applyEdit(type: interfaces.CommitType, editor: vscode.TextEditor, edit: vscode.TextEditorEdit): void {
public applyEdit(type: interfaces.CommitType, document: vscode.TextDocument, edit: { replace(range: vscode.Range, newText: string): void; }): void {
// Each conflict is a set of ranges as follows, note placements or newlines
// which may not in in spans
@@ -45,24 +45,24 @@ export class DocumentMergeConflict implements interfaces.IDocumentMergeConflict
// ]
if (type === interfaces.CommitType.Current) {
// Replace [ Conflict Range ] with [ Current Content ]
let content = editor.document.getText(this.current.content);
let content = document.getText(this.current.content);
this.replaceRangeWithContent(content, edit);
}
else if (type === interfaces.CommitType.Incoming) {
let content = editor.document.getText(this.incoming.content);
let content = document.getText(this.incoming.content);
this.replaceRangeWithContent(content, edit);
}
else if (type === interfaces.CommitType.Both) {
// Replace [ Conflict Range ] with [ Current Content ] + \n + [ Incoming Content ]
const currentContent = editor.document.getText(this.current.content);
const incomingContent = editor.document.getText(this.incoming.content);
const currentContent = document.getText(this.current.content);
const incomingContent = document.getText(this.incoming.content);
edit.replace(this.range, currentContent.concat(incomingContent));
}
}
private replaceRangeWithContent(content: string, edit: vscode.TextEditorEdit) {
private replaceRangeWithContent(content: string, edit: { replace(range: vscode.Range, newText: string): void; }) {
if (this.isNewlineOnly(content)) {
edit.replace(this.range, '');
return;

View File

@@ -25,7 +25,7 @@ export interface IExtensionConfiguration {
export interface IDocumentMergeConflict extends IDocumentMergeConflictDescriptor {
commitEdit(type: CommitType, editor: vscode.TextEditor, edit?: vscode.TextEditorEdit): Thenable<boolean>;
applyEdit(type: CommitType, editor: vscode.TextEditor, edit: vscode.TextEditorEdit): void;
applyEdit(type: CommitType, document: vscode.TextDocument, edit: { replace(range: vscode.Range, newText: string): void; }): void;
}
export interface IDocumentMergeConflictDescriptor {

View File

@@ -2,10 +2,10 @@
# yarn lockfile v1
"@types/node@8.0.33":
version "8.0.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.33.tgz#1126e94374014e54478092830704f6ea89df04cd"
integrity sha512-vmCdO8Bm1ExT+FWfC9sd9r4jwqM7o97gGy2WBshkkXbf/2nLAJQUrZfIhw27yVOtLUev6kSZc4cav/46KbDd8A==
"@types/node@^10.14.8":
version "10.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.8.tgz#fe444203ecef1162348cd6deb76c62477b2cc6e9"
integrity sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==
vscode-nls@^4.0.0:
version "4.0.0"

View File

@@ -3,3 +3,4 @@ out/**
tsconfig.json
extension.webpack.config.js
yarn.lock
.vscode

View File

@@ -0,0 +1,11 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
var updateGrammar = require('../../../build/npm/update-grammar');
updateGrammar.update('jeff-hykin/cpp-textmate-grammar', '/syntaxes/objc.tmLanguage.json', './syntaxes/objective-c.tmLanguage.json', undefined, 'master', 'source/languages/cpp');
updateGrammar.update('jeff-hykin/cpp-textmate-grammar', '/syntaxes/objcpp.tmLanguage.json', './syntaxes/objective-c++.tmLanguage.json', undefined, 'master', 'source/languages/cpp');

View File

@@ -0,0 +1,52 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#import "UseQuotes.h"
#import <Use/GTLT.h>
/*
Multi
Line
Comments
*/
@implementation Test
- (void) applicationWillFinishLaunching:(NSNotification *)notification
{
}
- (IBAction)onSelectInput:(id)sender
{
NSString* defaultDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0];
NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel setAllowedFileTypes:[[NSArray alloc] initWithObjects:@"ipa", @"xcarchive", @"app", nil]];
[panel beginWithCompletionHandler:^(NSInteger result)
{
if (result == NSFileHandlingPanelOKButton)
[self.inputTextField setStringValue:[panel.URL path]];
}];
return YES;
int hex = 0xFEF1F0F;
float ing = 3.14;
ing = 3.14e0;
ing = 31.4e-2;
}
-(id) initWithParams:(id<anObject>) aHandler withDeviceStateManager:(id<anotherObject>) deviceStateManager
{
// add a tap gesture recognizer
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
NSMutableArray *gestureRecognizers = [NSMutableArray array];
[gestureRecognizers addObject:tapGesture];
[gestureRecognizers addObjectsFromArray:scnView.gestureRecognizers];
scnView.gestureRecognizers = gestureRecognizers;
return tapGesture;
return nil;
}
@end

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More