From 46d64ac435465facfa8773cefb30000b29f134f7 Mon Sep 17 00:00:00 2001 From: Waterpolymer Date: Wed, 20 Nov 2019 23:02:36 -0500 Subject: [PATCH 01/23] Changed instances of Code to VS Code --- README.md | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5d39d7e40c6..bde4fa2e82c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Visual Studio Code - Open Source ("Code - OSS") + [![Build Status](https://dev.azure.com/vscode/VSCode/_apis/build/status/VS%20Code?branchName=master)](https://dev.azure.com/vscode/VSCode/_build/latest?definitionId=12) [![Feature Requests](https://img.shields.io/github/issues/Microsoft/vscode/feature-request.svg)](https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc) [![Bugs](https://img.shields.io/github/issues/Microsoft/vscode/bug.svg)](https://github.com/Microsoft/vscode/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3Abug) @@ -22,41 +23,39 @@ This repository ("`Code - OSS`") is where we (Microsoft) develop the [Visual Stu Visual Studio Code is updated monthly with new features and bug fixes. You can download it for Windows, macOS, and Linux on [Visual Studio Code's website](https://code.visualstudio.com/Download). To get the latest releases every day, install the [Insiders build](https://code.visualstudio.com/insiders). - - ## Contributing There are many ways in which you can participate in the project, for example: -* [Submit bugs and feature requests](https://github.com/microsoft/vscode/issues), and help us verify as they are checked in -* Review [source code changes](https://github.com/microsoft/vscode/pulls) -* Review the [documentation](https://github.com/microsoft/vscode-docs) and make pull requests for anything from typos to new content +- [Submit bugs and feature requests](https://github.com/microsoft/vscode/issues), and help us verify as they are checked in +- Review [source code changes](https://github.com/microsoft/vscode/pulls) +- Review the [documentation](https://github.com/microsoft/vscode-docs) and make pull requests for anything from typos to new content If you are interested in fixing issues and contributing directly to the code base, please see the document [How to Contribute](https://github.com/Microsoft/vscode/wiki/How-to-Contribute), which covers the following: -* [How to build and run from source](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) -* [The development workflow, including debugging and running tests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#debugging) -* [Coding guidelines](https://github.com/Microsoft/vscode/wiki/Coding-Guidelines) -* [Submitting pull requests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#pull-requests) -* [Finding an issue to work on](https://github.com/microsoft/vscode/wiki/How-to-Contribute#where-to-contribute) -* [Contributing to translations](https://aka.ms/vscodeloc) +- [How to build and run from source](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) +- [The development workflow, including debugging and running tests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#debugging) +- [Coding guidelines](https://github.com/Microsoft/vscode/wiki/Coding-Guidelines) +- [Submitting pull requests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#pull-requests) +- [Finding an issue to work on](https://github.com/microsoft/vscode/wiki/How-to-Contribute#where-to-contribute) +- [Contributing to translations](https://aka.ms/vscodeloc) ## Feedback -* Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/vscode) -* [Request a new feature](CONTRIBUTING.md) -* Up vote [popular feature requests](https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc) -* [File an issue](https://github.com/Microsoft/vscode/issues) -* Follow [@code](https://twitter.com/code) and let us know what you think! +- Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/vscode) +- [Request a new feature](CONTRIBUTING.md) +- Up vote [popular feature requests](https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc) +- [File an issue](https://github.com/Microsoft/vscode/issues) +- Follow [@code](https://twitter.com/code) and let us know what you think! ## Related Projects -Many of the core components and extensions to Code live in their own repositories on GitHub. For example, the [node debug adapter](https://github.com/microsoft/vscode-node-debug) and the [mono debug adapter](https://github.com/microsoft/vscode-mono-debug) have their own repositories. For a complete list, please visit the [Related Projects](https://github.com/Microsoft/vscode/wiki/Related-Projects) page on our [wiki](https://github.com/Microsoft/vscode/wiki). +Many of the core components and extensions to VS Code live in their own repositories on GitHub. For example, the [node debug adapter](https://github.com/microsoft/vscode-node-debug) and the [mono debug adapter](https://github.com/microsoft/vscode-mono-debug) have their own repositories. For a complete list, please visit the [Related Projects](https://github.com/Microsoft/vscode/wiki/Related-Projects) page on our [wiki](https://github.com/Microsoft/vscode/wiki). ## Bundled Extensions -Code includes a set of built-in extensions located in the [extensions](extensions) folder, including grammars and snippets for many languages. Extensions that provide rich language support (code completion, Go to Definition) for a language have the suffix `language-features`. For example, the `json` extension provides coloring for `JSON` and the `json-language-features` provides rich language support for `JSON`. +VS Code includes a set of built-in extensions located in the [extensions](extensions) folder, including grammars and snippets for many languages. Extensions that provide rich language support (code completion, Go to Definition) for a language have the suffix `language-features`. For example, the `json` extension provides coloring for `JSON` and the `json-language-features` provides rich language support for `JSON`. ## Code of Conduct From 3b0571d8c2b24a17ca253294d7ecd58650eace40 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 21 Nov 2019 15:59:05 +0100 Subject: [PATCH 02/23] cleanup denodeify from git --- extensions/git/src/git.ts | 14 ++++++-------- extensions/git/src/ipc/ipcServer.ts | 6 ++---- extensions/git/src/util.ts | 19 ++++--------------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index a710a539c29..99ab788410e 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as fs from 'fs'; +import { promises as fs, exists } from 'fs'; import * as path from 'path'; import * as os from 'os'; import * as cp from 'child_process'; @@ -11,7 +11,7 @@ import * as which from 'which'; 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, splitInChunks, Limiter } from './util'; +import { assign, groupBy, IDisposable, toDisposable, dispose, mkdirp, readBytes, detectUnicodeEncoding, Encoding, onceEvent, splitInChunks, Limiter } from './util'; import { CancellationToken, Progress } from 'vscode'; import { URI } from 'vscode-uri'; import { detectEncoding } from './encoding'; @@ -22,8 +22,6 @@ import { StringDecoder } from 'string_decoder'; // https://github.com/microsoft/vscode/issues/65693 const MAX_CLI_LENGTH = 30000; -const readfile = denodeify(fs.readFile); - export interface IGit { path: string; version: string; @@ -350,7 +348,7 @@ export class Git { let folderPath = path.join(parentPath, folderName); let count = 1; - while (count < 20 && await new Promise(c => fs.exists(folderPath, c))) { + while (count < 20 && await new Promise(c => exists(folderPath, c))) { folderName = `${baseFolderName}-${count++}`; folderPath = path.join(parentPath, folderName); } @@ -1830,7 +1828,7 @@ export class Repository { const mergeMsgPath = path.join(this.repositoryRoot, '.git', 'MERGE_MSG'); try { - const raw = await readfile(mergeMsgPath, 'utf8'); + const raw = await fs.readFile(mergeMsgPath, 'utf8'); return raw.trim(); } catch { return undefined; @@ -1854,7 +1852,7 @@ export class Repository { templatePath = path.join(this.repositoryRoot, templatePath); } - const raw = await readfile(templatePath, 'utf8'); + const raw = await fs.readFile(templatePath, 'utf8'); return raw.trim(); } catch (err) { @@ -1879,7 +1877,7 @@ export class Repository { const gitmodulesPath = path.join(this.root, '.gitmodules'); try { - const gitmodulesRaw = await readfile(gitmodulesPath, 'utf8'); + const gitmodulesRaw = await fs.readFile(gitmodulesPath, 'utf8'); return parseGitmodules(gitmodulesRaw); } catch (err) { if (/ENOENT/.test(err.message)) { diff --git a/extensions/git/src/ipc/ipcServer.ts b/extensions/git/src/ipc/ipcServer.ts index 39d2b59e6f8..332490896cc 100644 --- a/extensions/git/src/ipc/ipcServer.ts +++ b/extensions/git/src/ipc/ipcServer.ts @@ -4,15 +4,13 @@ *--------------------------------------------------------------------------------------------*/ import { Disposable } from 'vscode'; -import { denodeify, toDisposable } from '../util'; +import { toDisposable } from '../util'; import * as path from 'path'; import * as http from 'http'; import * as os from 'os'; import * as fs from 'fs'; import * as crypto from 'crypto'; -const randomBytes = denodeify(crypto.randomBytes); - function getIPCHandlePath(nonce: string): string { if (process.platform === 'win32') { return `\\\\.\\pipe\\vscode-git-ipc-${nonce}-sock`; @@ -31,7 +29,7 @@ export interface IIPCHandler { export async function createIPCServer(): Promise { const server = http.createServer(); - const buffer = await randomBytes(20); + const buffer = await new Promise((c, e) => crypto.randomBytes(20, (err, buf) => err ? e(err) : c(buf))); const nonce = buffer.toString('hex'); const ipcHandlePath = getIPCHandlePath(nonce); diff --git a/extensions/git/src/util.ts b/extensions/git/src/util.ts index 0722cb16fbd..3110168343b 100644 --- a/extensions/git/src/util.ts +++ b/extensions/git/src/util.ts @@ -6,7 +6,7 @@ import { Event } from 'vscode'; import { dirname, sep } from 'path'; import { Readable } from 'stream'; -import * as fs from 'fs'; +import { promises as fs, createReadStream } from 'fs'; import * as byline from 'byline'; export function log(...args: any[]): void { @@ -140,25 +140,14 @@ export function groupBy(arr: T[], fn: (el: T) => string): { [key: string]: T[ }, Object.create(null)); } -export function denodeify(fn: Function): (a: A, b: B, c: C) => Promise; -export function denodeify(fn: Function): (a: A, b: B) => Promise; -export function denodeify(fn: Function): (a: A) => Promise; -export function denodeify(fn: Function): (...args: any[]) => Promise; -export function denodeify(fn: Function): (...args: any[]) => Promise { - return (...args) => new Promise((c, e) => fn(...args, (err: any, r: any) => err ? e(err) : c(r))); -} - -export function nfcall(fn: Function, ...args: any[]): Promise { - return new Promise((c, e) => fn(...args, (err: any, r: any) => err ? e(err) : c(r))); -} export async function mkdirp(path: string, mode?: number): Promise { const mkdir = async () => { try { - await nfcall(fs.mkdir, path, mode); + await fs.mkdir(path, mode); } catch (err) { if (err.code === 'EEXIST') { - const stat = await nfcall(fs.stat, path); + const stat = await fs.stat(path); if (stat.isDirectory()) { return; @@ -232,7 +221,7 @@ export function find(array: T[], fn: (t: T) => boolean): T | undefined { export async function grep(filename: string, pattern: RegExp): Promise { return new Promise((c, e) => { - const fileStream = fs.createReadStream(filename, { encoding: 'utf8' }); + const fileStream = createReadStream(filename, { encoding: 'utf8' }); const stream = byline(fileStream); stream.on('data', (line: string) => { if (pattern.test(line)) { From f4f006216850a9cc82b4a0d530a6e85a96af4a5e Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 21 Nov 2019 16:41:28 +0100 Subject: [PATCH 03/23] git input box shouldn't handle comments related to #84201 --- extensions/git/package.json | 6 ------ extensions/git/package.nls.json | 1 - extensions/git/src/commands.ts | 3 ++- extensions/git/src/git.ts | 20 +++++--------------- extensions/git/src/repository.ts | 14 +------------- 5 files changed, 8 insertions(+), 36 deletions(-) diff --git a/extensions/git/package.json b/extensions/git/package.json index 9d7086dbaad..d801ec64f97 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -1608,12 +1608,6 @@ "default": "mixed", "description": "%config.untrackedChanges%", "scope": "resource" - }, - "git.restoreCommitTemplateComments": { - "type": "boolean", - "scope": "resource", - "default": true, - "description": "%config.restoreCommitTemplateComments%" } } }, diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index c4821f5decd..5c357b40eb0 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -139,7 +139,6 @@ "config.untrackedChanges.mixed": "All changes, tracked and untracked, appear together and behave equally.", "config.untrackedChanges.separate": "Untracked changes appear separately in the Source Control view. They are also excluded from several actions.", "config.untrackedChanges.hidden": "Untracked changes are hidden and excluded from several actions.", - "config.restoreCommitTemplateComments": "Controls whether to restore commit template comments in the commit input box.", "colors.added": "Color for added resources.", "colors.modified": "Color for modified resources.", "colors.deleted": "Color for deleted resources.", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 432e16b8231..5dd981bbd9c 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1406,6 +1406,7 @@ export class CommandCenter { const message = repository.inputBox.value; const getCommitMessage = async () => { let _message: string | undefined = message; + if (!_message) { let value: string | undefined = undefined; @@ -1430,7 +1431,7 @@ export class CommandCenter { }); } - return _message ? repository.cleanUpCommitEditMessage(_message) : _message; + return _message; }; const didCommit = await this.smartCommit(repository, getCommitMessage, opts); diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 99ab788410e..193907a15bd 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1810,18 +1810,9 @@ export class Repository { } } - cleanupCommitEditMessage(message: string): string { - // If the message is a single line starting with whitespace followed by `#`, just allow it. - if (/^\s*#[^\n]*$/.test(message)) { - return message; - } - - // Else, remove all lines starting with whitespace followed by `#`. - // TODO: Support core.commentChar - return message.replace(/^(\s*#)(.*)$(\n?)/gm, (_, prefix, content, suffix) => { - // https://github.com/microsoft/vscode/issues/84201#issuecomment-552834814 - return /^\d/.test(content) ? `${prefix}${content}${suffix}` : ''; - }).trim(); + // TODO: Support core.commentChar + stripCommitMessageComments(message: string): string { + return message.replace(/^\s*#.*$\n?/gm, '').trim(); } async getMergeMessage(): Promise { @@ -1829,7 +1820,7 @@ export class Repository { try { const raw = await fs.readFile(mergeMsgPath, 'utf8'); - return raw.trim(); + return this.stripCommitMessageComments(raw); } catch { return undefined; } @@ -1853,8 +1844,7 @@ export class Repository { } const raw = await fs.readFile(templatePath, 'utf8'); - return raw.trim(); - + return this.stripCommitMessageComments(raw); } catch (err) { return ''; } diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 5f3c9bee464..4edc79262d2 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -844,15 +844,7 @@ export class Repository implements Disposable { return mergeMessage; } - let template = await this.repository.getCommitTemplate(); - - const config = workspace.getConfiguration('git', Uri.file(this.root)); - - if (!config.get('restoreCommitTemplateComments')) { - template = this.cleanUpCommitEditMessage(template); - } - - return template; + return await this.repository.getCommitTemplate(); } getConfigs(): Promise<{ key: string; value: string; }[]> { @@ -1286,10 +1278,6 @@ export class Repository implements Disposable { return await this.run(Operation.GetCommitTemplate, async () => this.repository.getCommitTemplate()); } - cleanUpCommitEditMessage(editMessage: string): string { - return this.repository.cleanupCommitEditMessage(editMessage); - } - async ignore(files: Uri[]): Promise { return await this.run(Operation.Ignore, async () => { const ignoreFile = `${this.repository.root}${path.sep}.gitignore`; From 2f5120fe3482d9967ff49b57b98b6e8d5dc00908 Mon Sep 17 00:00:00 2001 From: Waterpolymer Date: Thu, 21 Nov 2019 10:57:55 -0500 Subject: [PATCH 04/23] Reverted '-' to '*' and removed space --- README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index bde4fa2e82c..0de5f2f71da 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Visual Studio Code - Open Source ("Code - OSS") - [![Build Status](https://dev.azure.com/vscode/VSCode/_apis/build/status/VS%20Code?branchName=master)](https://dev.azure.com/vscode/VSCode/_build/latest?definitionId=12) [![Feature Requests](https://img.shields.io/github/issues/Microsoft/vscode/feature-request.svg)](https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc) [![Bugs](https://img.shields.io/github/issues/Microsoft/vscode/bug.svg)](https://github.com/Microsoft/vscode/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3Abug) @@ -27,27 +26,27 @@ Visual Studio Code is updated monthly with new features and bug fixes. You can d There are many ways in which you can participate in the project, for example: -- [Submit bugs and feature requests](https://github.com/microsoft/vscode/issues), and help us verify as they are checked in -- Review [source code changes](https://github.com/microsoft/vscode/pulls) -- Review the [documentation](https://github.com/microsoft/vscode-docs) and make pull requests for anything from typos to new content +* [Submit bugs and feature requests](https://github.com/microsoft/vscode/issues), and help us verify as they are checked in +* Review [source code changes](https://github.com/microsoft/vscode/pulls) +* Review the [documentation](https://github.com/microsoft/vscode-docs) and make pull requests for anything from typos to new content If you are interested in fixing issues and contributing directly to the code base, please see the document [How to Contribute](https://github.com/Microsoft/vscode/wiki/How-to-Contribute), which covers the following: -- [How to build and run from source](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) -- [The development workflow, including debugging and running tests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#debugging) -- [Coding guidelines](https://github.com/Microsoft/vscode/wiki/Coding-Guidelines) -- [Submitting pull requests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#pull-requests) -- [Finding an issue to work on](https://github.com/microsoft/vscode/wiki/How-to-Contribute#where-to-contribute) -- [Contributing to translations](https://aka.ms/vscodeloc) +* [How to build and run from source](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) +* [The development workflow, including debugging and running tests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#debugging) +* [Coding guidelines](https://github.com/Microsoft/vscode/wiki/Coding-Guidelines) +* [Submitting pull requests](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#pull-requests) +* [Finding an issue to work on](https://github.com/microsoft/vscode/wiki/How-to-Contribute#where-to-contribute) +* [Contributing to translations](https://aka.ms/vscodeloc) ## Feedback -- Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/vscode) -- [Request a new feature](CONTRIBUTING.md) -- Up vote [popular feature requests](https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc) -- [File an issue](https://github.com/Microsoft/vscode/issues) -- Follow [@code](https://twitter.com/code) and let us know what you think! +* Ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/vscode) +* [Request a new feature](CONTRIBUTING.md) +* Up vote [popular feature requests](https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc) +* [File an issue](https://github.com/Microsoft/vscode/issues) +* Follow [@code](https://twitter.com/code) and let us know what you think! ## Related Projects From 8f02213d4e6cbd917c0079bad2ddd536a3484e2f Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 21 Nov 2019 17:09:20 +0100 Subject: [PATCH 05/23] debug: restart frame on hover #84045 --- .../contrib/debug/browser/callStackView.ts | 16 ++++++++++++++-- .../contrib/debug/browser/media/debugViewlet.css | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index ef83c73203a..f7fd358b9f7 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -385,6 +385,7 @@ interface IStackFrameTemplateData { fileName: HTMLElement; lineNumber: HTMLElement; label: HighlightedLabel; + actionBar: ActionBar; } class SessionsRenderer implements ITreeRenderer { @@ -481,8 +482,9 @@ class StackFramesRenderer implements ITreeRenderer, index: number, data: IStackFrameTemplateData): void { @@ -490,6 +492,8 @@ class StackFramesRenderer implements ITreeRenderer { + return stackFrame.restart(); + }); + data.actionBar.push(action, { icon: true, label: false }); + } } disposeTemplate(templateData: IStackFrameTemplateData): void { - // noop + templateData.actionBar.dispose(); } } diff --git a/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css b/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css index 185b8187d41..d4e91e65cd1 100644 --- a/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css +++ b/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css @@ -148,6 +148,11 @@ display: none; } +.debug-viewlet .debug-call-stack .monaco-list-row:hover .stack-frame.has-actions .file, +.debug-viewlet .debug-call-stack .monaco-list-row.focused .stack-frame.has-actions .file { + display: none; +} + .debug-viewlet .debug-call-stack .monaco-list-row .monaco-action-bar { display: none; } From c1146debe657147bda6f9442435c677a109325b6 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 21 Nov 2019 17:17:21 +0100 Subject: [PATCH 06/23] scm: hash repo pane ids --- src/vs/workbench/contrib/scm/browser/repositoryPane.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/scm/browser/repositoryPane.ts b/src/vs/workbench/contrib/scm/browser/repositoryPane.ts index ab1d61454b2..e4fa1369aed 100644 --- a/src/vs/workbench/contrib/scm/browser/repositoryPane.ts +++ b/src/vs/workbench/contrib/scm/browser/repositoryPane.ts @@ -53,6 +53,7 @@ import { IWorkbenchThemeService, IFileIconTheme } from 'vs/workbench/services/th import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { toResource, SideBySideEditor } from 'vs/workbench/common/editor'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; +import { Hasher } from 'vs/base/common/hash'; type TreeElement = ISCMResourceGroup | IResourceNode | ISCMResource; @@ -963,7 +964,10 @@ export class RepositoryViewDescriptor implements IViewDescriptor { constructor(readonly repository: ISCMRepository, readonly hideByDefault: boolean) { const repoId = repository.provider.rootUri ? repository.provider.rootUri.toString() : `#${RepositoryViewDescriptor.counter++}`; - this.id = `scm:repository:${repository.provider.label}:${repoId}`; + const hasher = new Hasher(); + hasher.hash(repository.provider.label); + hasher.hash(repoId); + this.id = `scm:repository:${hasher.value}`; this.name = repository.provider.rootUri ? basename(repository.provider.rootUri) : repository.provider.label; this.ctorDescriptor = { ctor: RepositoryPane, arguments: [repository] }; From 687bb7c070cdcdc0e3af6f97c161ced8da2f9a13 Mon Sep 17 00:00:00 2001 From: Miguel Solorio Date: Thu, 21 Nov 2019 08:47:41 -0800 Subject: [PATCH 07/23] Update codicons: add debug stack reload and debug activity bar alternative --- .../ui/codiconLabel/codicon/codicon.css | 9 ++++++--- .../ui/codiconLabel/codicon/codicon.ttf | Bin 47104 -> 47404 bytes 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vs/base/browser/ui/codiconLabel/codicon/codicon.css b/src/vs/base/browser/ui/codiconLabel/codicon/codicon.css index 4dfc8f69330..2e259eda4f2 100644 --- a/src/vs/base/browser/ui/codiconLabel/codicon/codicon.css +++ b/src/vs/base/browser/ui/codiconLabel/codicon/codicon.css @@ -5,7 +5,7 @@ @font-face { font-family: "codicon"; - src: url("./codicon.ttf?6e26276ebddb23b7baa20bf099ba8332") format("truetype"); + src: url("./codicon.ttf?c4e66586cd3ad4acc55fc456c0760dec") format("truetype"); } .codicon[class*='codicon-'] { @@ -401,5 +401,8 @@ .codicon-debug-breakpoint-stackframe-focused:before { content: "\eb8b" } .codicon-debug-breakpoint-unsupported:before { content: "\eb8c" } .codicon-symbol-string:before { content: "\eb8d" } -.codicon-debug-reverse-continue:before { content: "\f101" } -.codicon-debug-step-back:before { content: "\f102" } +.codicon-debug-reverse-continue:before { content: "\eb8e" } +.codicon-debug-step-back:before { content: "\eb8f" } +.codicon-debug-restart-frame:before { content: "\eb90" } +.codicon-debug-alternate:before { content: "\eb91" } +.codicon-debug-alt:before { content: "\f101" } diff --git a/src/vs/base/browser/ui/codiconLabel/codicon/codicon.ttf b/src/vs/base/browser/ui/codiconLabel/codicon/codicon.ttf index a8ad5305b9440a2b054f59ce7657892883f26aa8..a51c284681e086082aecd8d267d334a25b9bce8f 100644 GIT binary patch delta 4697 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 From b24775ae6dd719148a299d325466dbec3db0c4cf Mon Sep 17 00:00:00 2001 From: Miguel Solorio Date: Thu, 21 Nov 2019 08:56:06 -0800 Subject: [PATCH 08/23] #84045: Add "debug-restart-frame" icon --- src/vs/workbench/contrib/debug/browser/callStackView.ts | 2 +- src/vs/workbench/contrib/debug/browser/debugToolBar.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index f7fd358b9f7..20029b0ec3b 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -513,7 +513,7 @@ class StackFramesRenderer implements ITreeRenderer { + const action = new Action('debug.callStack.restartFrame', nls.localize('restartFrame', "Restart Frame"), 'codicon-debug-restart-frame', true, () => { return stackFrame.restart(); }); data.actionBar.push(action, { icon: true, label: false }); diff --git a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts index cf629a37d01..4d8c423dbce 100644 --- a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts +++ b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts @@ -377,7 +377,7 @@ registerThemingParticipant((theme, collector) => { const debugIconRestartColor = theme.getColor(debugIconRestartForeground); if (debugIconRestartColor) { - collector.addRule(`.monaco-workbench .codicon-debug-restart { color: ${debugIconRestartColor} !important; }`); + collector.addRule(`.monaco-workbench .codicon-debug-restart, .monaco-workbench .codicon-debug-restart-frame { color: ${debugIconRestartColor} !important; }`); } const debugIconStepOverColor = theme.getColor(debugIconStepOverForeground); From 1ca17cd262c53f632a56ccadf92a3d38ee49cfd0 Mon Sep 17 00:00:00 2001 From: Miguel Solorio Date: Thu, 21 Nov 2019 09:07:08 -0800 Subject: [PATCH 09/23] Update debug icon to use alternate version --- src/vs/workbench/contrib/debug/browser/debug.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/debug/browser/debug.contribution.ts b/src/vs/workbench/contrib/debug/browser/debug.contribution.ts index 7b74dcb4912..67ba00c4cd6 100644 --- a/src/vs/workbench/contrib/debug/browser/debug.contribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debug.contribution.ts @@ -83,7 +83,7 @@ Registry.as(ViewletExtensions.Viewlets).registerViewlet(Viewlet DebugViewlet, VIEWLET_ID, nls.localize('debug', "Debug"), - 'codicon-debug', + 'codicon-debug-alt', 3 )); From ca855d5fe63338f6996a93f1c90a1a5af8358926 Mon Sep 17 00:00:00 2001 From: Miguel Solorio Date: Thu, 21 Nov 2019 11:42:35 -0800 Subject: [PATCH 10/23] Update "Go to file" icons to use icon font --- .../browser/menuEntryActionViewItem.ts | 2 +- .../browser/preferences.contribution.ts | 33 ++++--------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/vs/platform/actions/browser/menuEntryActionViewItem.ts b/src/vs/platform/actions/browser/menuEntryActionViewItem.ts index 05efd4bd424..77d930aa7fd 100644 --- a/src/vs/platform/actions/browser/menuEntryActionViewItem.ts +++ b/src/vs/platform/actions/browser/menuEntryActionViewItem.ts @@ -147,7 +147,7 @@ export class MenuEntryActionViewItem extends ActionViewItem { @INotificationService protected _notificationService: INotificationService, @IContextMenuService _contextMenuService: IContextMenuService ) { - super(undefined, _action, { icon: !!(_action.class || _action.item.iconLocation), label: !_action.class && !_action.item.iconLocation }); + super(undefined, _action, { icon: !!(_action.class || _action.item.iconLocation || _action.item.iconClassName), label: !_action.class && !_action.item.iconLocation && !_action.item.iconClassName }); this._altKey = AlternativeKeyEmitter.getInstance(_contextMenuService); } diff --git a/src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts b/src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts index cd52141866d..6d38111b94b 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts @@ -39,7 +39,6 @@ import { ExplorerRootContext, ExplorerFolderContext } from 'vs/workbench/contrib import { ILabelService } from 'vs/platform/label/common/label'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts'; -import { registerAndGetAmdImageURL } from 'vs/base/common/amd'; Registry.as(EditorExtensions.Editors).registerEditor( EditorDescriptor.create( @@ -368,8 +367,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ } }); -const PREFERENCES_EDITOR_LIGHT_ICON_URI = URI.parse(registerAndGetAmdImageURL(`vs/workbench/contrib/preferences/browser/media/preferences-editor-light.svg`)); -const PREFERENCES_EDITOR_DARK_ICON_URI = URI.parse(registerAndGetAmdImageURL(`vs/workbench/contrib/preferences/browser/media/preferences-editor-dark.svg`)); class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution { constructor( @@ -384,10 +381,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon command: { id: OpenGlobalKeybindingsAction.ID, title: OpenGlobalKeybindingsAction.LABEL, - iconLocation: { - light: PREFERENCES_EDITOR_LIGHT_ICON_URI, - dark: PREFERENCES_EDITOR_DARK_ICON_URI - } + iconClassName: 'codicon-go-to-file' }, when: ResourceContextKey.Resource.isEqualTo(environmentService.keybindingsResource.toString()), group: 'navigation', @@ -400,10 +394,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon command: { id: commandId, title: OpenSettings2Action.LABEL, - iconLocation: { - light: PREFERENCES_EDITOR_LIGHT_ICON_URI, - dark: PREFERENCES_EDITOR_DARK_ICON_URI - } + iconClassName: 'codicon-go-to-file' }, when: ResourceContextKey.Resource.isEqualTo(environmentService.settingsResource.toString()), group: 'navigation', @@ -441,10 +432,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon command: { id: commandId, title: OpenSettings2Action.LABEL, - iconLocation: { - light: PREFERENCES_EDITOR_LIGHT_ICON_URI, - dark: PREFERENCES_EDITOR_DARK_ICON_URI - } + iconClassName: 'codicon-go-to-file' }, when: ContextKeyExpr.and(ResourceContextKey.Resource.isEqualTo(this.preferencesService.workspaceSettingsResource!.toString()), WorkbenchStateContext.isEqualTo('workspace')), group: 'navigation', @@ -469,10 +457,7 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon command: { id: commandId, title: OpenSettings2Action.LABEL, - iconLocation: { - light: PREFERENCES_EDITOR_LIGHT_ICON_URI, - dark: PREFERENCES_EDITOR_DARK_ICON_URI - } + iconClassName: 'codicon-go-to-file' }, when: ContextKeyExpr.and(ResourceContextKey.Resource.isEqualTo(this.preferencesService.getFolderSettingsResource(folder.uri)!.toString())), group: 'navigation', @@ -536,10 +521,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: OpenGlobalKeybindingsFileAction.ID, title: OpenGlobalKeybindingsFileAction.LABEL, - iconLocation: { - light: PREFERENCES_EDITOR_LIGHT_ICON_URI, - dark: PREFERENCES_EDITOR_DARK_ICON_URI - } + iconClassName: 'codicon-go-to-file' }, when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR), group: 'navigation', @@ -820,10 +802,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON, title: nls.localize('openSettingsJson', "Open Settings (JSON)"), - iconLocation: { - dark: PREFERENCES_EDITOR_DARK_ICON_URI, - light: PREFERENCES_EDITOR_LIGHT_ICON_URI - } + iconClassName: 'codicon-go-to-file' }, group: 'navigation', order: 1, From 0df48c6af799f8df0ae5fddc6c3e73cd0c40fa8c Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Thu, 21 Nov 2019 12:02:20 -0800 Subject: [PATCH 11/23] fixes #85284 --- src/vs/workbench/contrib/search/browser/searchPanel.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/search/browser/searchPanel.ts b/src/vs/workbench/contrib/search/browser/searchPanel.ts index 54cf8e628d1..559f023dee7 100644 --- a/src/vs/workbench/contrib/search/browser/searchPanel.ts +++ b/src/vs/workbench/contrib/search/browser/searchPanel.ts @@ -31,7 +31,7 @@ export class SearchPanel extends Panel { } create(parent: HTMLElement): void { - dom.addClasses(parent, 'monaco-panel-view', 'search-panel'); + dom.addClasses(parent, 'monaco-pane-view', 'search-panel'); this.searchView.render(); dom.append(parent, this.searchView.element); this.searchView.setExpanded(true); From f965609a87e86ca5034d62fe25a8eb16dca60ad3 Mon Sep 17 00:00:00 2001 From: Miguel Solorio Date: Thu, 21 Nov 2019 13:34:19 -0800 Subject: [PATCH 12/23] Fix #85336, adjust tree padding for file icons --- src/vs/workbench/browser/parts/views/media/views.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/browser/parts/views/media/views.css b/src/vs/workbench/browser/parts/views/media/views.css index fb062a7a3af..43fa0eb55da 100644 --- a/src/vs/workbench/browser/parts/views/media/views.css +++ b/src/vs/workbench/browser/parts/views/media/views.css @@ -32,7 +32,7 @@ .file-icon-themable-tree.hide-arrows .monaco-tl-twistie:not(.force-twistie) { background-image: none !important; width: 0 !important; - margin-right: 0 !important; + padding-right: 0 !important; visibility: hidden; } From 1ef501369f1982795730ecd0b8f1cc2243bd10ea Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Thu, 21 Nov 2019 09:31:50 -0800 Subject: [PATCH 13/23] exclude system status bar from visual viewport in standalone mode. --- src/vs/base/browser/dom.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index ba6ea61595a..ee0abdc87b8 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -506,7 +506,13 @@ export function getClientArea(element: HTMLElement): Dimension { // If visual view port exits and it's on mobile, it should be used instead of window innerWidth / innerHeight, or document.body.clientWidth / document.body.clientHeight if (platform.isIOS && (window).visualViewport) { - return new Dimension((window).visualViewport.width, (window).visualViewport.height); + const width = (window).visualViewport.height; + const height = (window).visualViewport.height - ( + browser.isStandalone + ? 20 // in PWA mode, the system statusbar is counted into the visual viewport. 20 is the default size of iOS statusbar. + : 0 // in non PWA mode, the visual viewport is awalys smaller than the brower tab (which doesn't include system statusbar, browser header, etc) + ); + return new Dimension(width, height); } // Try innerWidth / innerHeight From 6b21839efdaaa74c55bd56e95e86322f2d02005a Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Thu, 21 Nov 2019 14:48:33 -0800 Subject: [PATCH 14/23] Update lightbulb gesture clicking. --- src/vs/base/browser/dom.ts | 15 ++++++++++++--- .../editor/browser/controller/pointerHandler.ts | 4 ++++ .../editor/contrib/codeAction/lightBulbWidget.ts | 5 ++++- src/vs/workbench/browser/style.ts | 9 +++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index ee0abdc87b8..7557be2bac3 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -267,6 +267,12 @@ export let addStandardDisposableListener: IAddStandardDisposableListenerSignatur return addDisposableListener(node, type, wrapHandler, useCapture); }; +export let addStandardDisposableGenericMouseDownListner = function addStandardDisposableListener(node: HTMLElement, handler: (event: any) => void, useCapture?: boolean): IDisposable { + let wrapHandler = _wrapAsStandardMouseEvent(handler); + + return addDisposableGenericMouseDownListner(node, wrapHandler, useCapture); +}; + export function addDisposableGenericMouseDownListner(node: EventTarget, handler: (event: any) => void, useCapture?: boolean): IDisposable { return addDisposableListener(node, platform.isIOS && BrowserFeatures.pointerEvents ? EventType.POINTER_DOWN : EventType.MOUSE_DOWN, handler, useCapture); } @@ -506,11 +512,14 @@ export function getClientArea(element: HTMLElement): Dimension { // If visual view port exits and it's on mobile, it should be used instead of window innerWidth / innerHeight, or document.body.clientWidth / document.body.clientHeight if (platform.isIOS && (window).visualViewport) { - const width = (window).visualViewport.height; + const width = (window).visualViewport.width; const height = (window).visualViewport.height - ( browser.isStandalone - ? 20 // in PWA mode, the system statusbar is counted into the visual viewport. 20 is the default size of iOS statusbar. - : 0 // in non PWA mode, the visual viewport is awalys smaller than the brower tab (which doesn't include system statusbar, browser header, etc) + // in PWA mode, the visual viewport always includes the safe-area-inset-bottom (which is for the home indicator) + // even when you are using the onscreen monitor, the visual viewport will include the area between system statusbar and the onscreen keyboard + // plus the area between onscreen keyboard and the bottom bezel, which is 20px on iOS. + ? (20 + 8) // body margin is 8px + : 0 ); return new Dimension(width, height); } diff --git a/src/vs/editor/browser/controller/pointerHandler.ts b/src/vs/editor/browser/controller/pointerHandler.ts index f1a997e1a4d..46894f1be15 100644 --- a/src/vs/editor/browser/controller/pointerHandler.ts +++ b/src/vs/editor/browser/controller/pointerHandler.ts @@ -226,6 +226,10 @@ export class PointerEventHandler extends MouseHandler { } private onTap(event: GestureEvent): void { + if (!event.initialTarget || !this.viewHelper.linesContentDomNode.contains(event.initialTarget)) { + return; + } + event.preventDefault(); this.viewHelper.focusTextArea(); const target = this._createMouseTarget(new EditorMouseEvent(event, this.viewHelper.viewDomNode), false); diff --git a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts index 5512a63a60f..e01343ff2b5 100644 --- a/src/vs/editor/contrib/codeAction/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/lightBulbWidget.ts @@ -17,6 +17,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { EditorOption } from 'vs/editor/common/config/editorOptions'; import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; import { editorLightBulbForeground, editorLightBulbAutoFixForeground } from 'vs/platform/theme/common/colorRegistry'; +import { Gesture } from 'vs/base/browser/touch'; namespace LightBulbState { @@ -71,7 +72,9 @@ export class LightBulbWidget extends Disposable implements IContentWidget { this.hide(); } })); - this._register(dom.addStandardDisposableListener(this._domNode, 'mousedown', e => { + + Gesture.ignoreTarget(this._domNode); + this._register(dom.addStandardDisposableGenericMouseDownListner(this._domNode, e => { if (this.state.type !== LightBulbState.Type.Showing) { return; } diff --git a/src/vs/workbench/browser/style.ts b/src/vs/workbench/browser/style.ts index d38931efc44..ea118c2511a 100644 --- a/src/vs/workbench/browser/style.ts +++ b/src/vs/workbench/browser/style.ts @@ -8,9 +8,9 @@ import 'vs/css!./media/style'; import { registerThemingParticipant, ITheme, ICssStyleCollector, HIGH_CONTRAST } from 'vs/platform/theme/common/themeService'; import { iconForeground, foreground, selectionBackground, focusBorder, scrollbarShadow, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, listHighlightForeground, inputPlaceholderForeground } from 'vs/platform/theme/common/colorRegistry'; import { WORKBENCH_BACKGROUND, TITLE_BAR_ACTIVE_BACKGROUND } from 'vs/workbench/common/theme'; -import { isWeb } from 'vs/base/common/platform'; +import { isWeb, isIOS } from 'vs/base/common/platform'; import { createMetaElement } from 'vs/base/browser/dom'; -import { isSafari } from 'vs/base/browser/browser'; +import { isSafari, isStandalone } from 'vs/base/browser/browser'; registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { @@ -184,4 +184,9 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { } `); } + + // Update body background color to ensure the home indicator area looks similar to the workbench + if (isIOS && isStandalone) { + collector.addRule(`body { background-color: ${workbenchBackground}; }`); + } }); From 9197d42531103ca6c07a9766819bcb6c2ee2bfc1 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Thu, 21 Nov 2019 15:38:54 -0800 Subject: [PATCH 15/23] 4px margin for home indicator --- src/vs/base/browser/dom.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index 7557be2bac3..e8a190d2a7d 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -518,7 +518,7 @@ export function getClientArea(element: HTMLElement): Dimension { // in PWA mode, the visual viewport always includes the safe-area-inset-bottom (which is for the home indicator) // even when you are using the onscreen monitor, the visual viewport will include the area between system statusbar and the onscreen keyboard // plus the area between onscreen keyboard and the bottom bezel, which is 20px on iOS. - ? (20 + 8) // body margin is 8px + ? (20 + 4) // + 4px for body margin : 0 ); return new Dimension(width, height); From 5534051e276539983d54cc1063c7508f3209a78c Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Nov 2019 11:14:00 -0800 Subject: [PATCH 16/23] codeActionWidget -> codeActionMenu --- .../codeAction/{codeActionWidget.ts => codeActionMenu.ts} | 2 +- src/vs/editor/contrib/codeAction/codeActionUi.ts | 6 +++--- .../codeAction/test/codeActionKeybindingResolver.test.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/vs/editor/contrib/codeAction/{codeActionWidget.ts => codeActionMenu.ts} (99%) diff --git a/src/vs/editor/contrib/codeAction/codeActionWidget.ts b/src/vs/editor/contrib/codeAction/codeActionMenu.ts similarity index 99% rename from src/vs/editor/contrib/codeAction/codeActionWidget.ts rename to src/vs/editor/contrib/codeAction/codeActionMenu.ts index 4e85aa712d2..a170112a977 100644 --- a/src/vs/editor/contrib/codeAction/codeActionWidget.ts +++ b/src/vs/editor/contrib/codeAction/codeActionMenu.ts @@ -43,7 +43,7 @@ export interface CodeActionShowOptions { readonly includeDisabledActions: boolean; } -export class CodeActionWidget extends Disposable { +export class CodeActionMenu extends Disposable { private _visible: boolean = false; private readonly _showingActions = this._register(new MutableDisposable()); diff --git a/src/vs/editor/contrib/codeAction/codeActionUi.ts b/src/vs/editor/contrib/codeAction/codeActionUi.ts index 61f1a9b29dd..a62e1c67b76 100644 --- a/src/vs/editor/contrib/codeAction/codeActionUi.ts +++ b/src/vs/editor/contrib/codeAction/codeActionUi.ts @@ -16,13 +16,13 @@ import { MessageController } from 'vs/editor/contrib/message/messageController'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { CodeActionsState } from './codeActionModel'; -import { CodeActionWidget, CodeActionShowOptions } from './codeActionWidget'; +import { CodeActionMenu, CodeActionShowOptions } from './codeActionMenu'; import { LightBulbWidget } from './lightBulbWidget'; import { CodeActionAutoApply, CodeActionTrigger } from './types'; export class CodeActionUi extends Disposable { - private readonly _codeActionWidget: Lazy; + private readonly _codeActionWidget: Lazy; private readonly _lightBulbWidget: Lazy; private readonly _activeCodeActions = this._register(new MutableDisposable()); @@ -39,7 +39,7 @@ export class CodeActionUi extends Disposable { super(); this._codeActionWidget = new Lazy(() => { - return this._register(new CodeActionWidget(this._editor, contextMenuService, keybindingService, { + return this._register(new CodeActionMenu(this._editor, contextMenuService, keybindingService, { onSelectCodeAction: async (action) => { this.delegate.applyCodeAction(action, /* retrigger */ true); } diff --git a/src/vs/editor/contrib/codeAction/test/codeActionKeybindingResolver.test.ts b/src/vs/editor/contrib/codeAction/test/codeActionKeybindingResolver.test.ts index 44314a90860..9a939303ece 100644 --- a/src/vs/editor/contrib/codeAction/test/codeActionKeybindingResolver.test.ts +++ b/src/vs/editor/contrib/codeAction/test/codeActionKeybindingResolver.test.ts @@ -8,7 +8,7 @@ import { ChordKeybinding, KeyCode, SimpleKeybinding } from 'vs/base/common/keyCo import { OperatingSystem } from 'vs/base/common/platform'; import { refactorCommandId, organizeImportsCommandId } from 'vs/editor/contrib/codeAction/codeAction'; import { CodeActionKind } from 'vs/editor/contrib/codeAction/types'; -import { CodeActionKeybindingResolver } from 'vs/editor/contrib/codeAction/codeActionWidget'; +import { CodeActionKeybindingResolver } from 'vs/editor/contrib/codeAction/codeActionMenu'; import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem'; import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding'; From 7d179d04aee96928fe2a41683943b416e942d169 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Nov 2019 11:28:33 -0800 Subject: [PATCH 17/23] Use InstantiationService --- src/vs/editor/contrib/codeAction/codeActionCommands.ts | 2 +- src/vs/editor/contrib/codeAction/codeActionMenu.ts | 4 ++-- src/vs/editor/contrib/codeAction/codeActionUi.ts | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/vs/editor/contrib/codeAction/codeActionCommands.ts b/src/vs/editor/contrib/codeAction/codeActionCommands.ts index c51443c95c3..8185eca6b17 100644 --- a/src/vs/editor/contrib/codeAction/codeActionCommands.ts +++ b/src/vs/editor/contrib/codeAction/codeActionCommands.ts @@ -106,7 +106,7 @@ export class QuickFixController extends Disposable implements IEditorContributio } } } - }, contextMenuService, keybindingService)) + }, this._instantiationService)) ); } diff --git a/src/vs/editor/contrib/codeAction/codeActionMenu.ts b/src/vs/editor/contrib/codeAction/codeActionMenu.ts index a170112a977..c2cdc9c4f0f 100644 --- a/src/vs/editor/contrib/codeAction/codeActionMenu.ts +++ b/src/vs/editor/contrib/codeAction/codeActionMenu.ts @@ -52,9 +52,9 @@ export class CodeActionMenu extends Disposable { constructor( private readonly _editor: ICodeEditor, - private readonly _contextMenuService: IContextMenuService, - keybindingService: IKeybindingService, private readonly _delegate: CodeActionWidgetDelegate, + @IContextMenuService private readonly _contextMenuService: IContextMenuService, + @IKeybindingService keybindingService: IKeybindingService, ) { super(); diff --git a/src/vs/editor/contrib/codeAction/codeActionUi.ts b/src/vs/editor/contrib/codeAction/codeActionUi.ts index a62e1c67b76..5c34b32fe7f 100644 --- a/src/vs/editor/contrib/codeAction/codeActionUi.ts +++ b/src/vs/editor/contrib/codeAction/codeActionUi.ts @@ -13,12 +13,11 @@ import { IPosition } from 'vs/editor/common/core/position'; import { CodeAction } from 'vs/editor/common/modes'; import { CodeActionSet } from 'vs/editor/contrib/codeAction/codeAction'; import { MessageController } from 'vs/editor/contrib/message/messageController'; -import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; -import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { CodeActionsState } from './codeActionModel'; import { CodeActionMenu, CodeActionShowOptions } from './codeActionMenu'; import { LightBulbWidget } from './lightBulbWidget'; import { CodeActionAutoApply, CodeActionTrigger } from './types'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; export class CodeActionUi extends Disposable { @@ -33,13 +32,12 @@ export class CodeActionUi extends Disposable { private readonly delegate: { applyCodeAction: (action: CodeAction, regtriggerAfterApply: boolean) => Promise }, - @IContextMenuService contextMenuService: IContextMenuService, - @IKeybindingService keybindingService: IKeybindingService, + @IInstantiationService instantiationService: IInstantiationService, ) { super(); this._codeActionWidget = new Lazy(() => { - return this._register(new CodeActionMenu(this._editor, contextMenuService, keybindingService, { + return this._register(instantiationService.createInstance(CodeActionMenu, this._editor, { onSelectCodeAction: async (action) => { this.delegate.applyCodeAction(action, /* retrigger */ true); } @@ -47,7 +45,7 @@ export class CodeActionUi extends Disposable { }); this._lightBulbWidget = new Lazy(() => { - const widget = this._register(new LightBulbWidget(this._editor, quickFixActionId, preferredFixActionId, keybindingService)); + const widget = this._register(instantiationService.createInstance(LightBulbWidget, this._editor, quickFixActionId, preferredFixActionId)); this._register(widget.onClick(e => this.showCodeActionList(e.actions, e, { includeDisabledActions: false }))); return widget; }); From f775aea9ad90528671a8708d942193bd39cb1a75 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Nov 2019 13:51:16 -0800 Subject: [PATCH 18/23] Remove mime extension point --- .../workbench/contrib/customEditor/browser/extensionPoint.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/vs/workbench/contrib/customEditor/browser/extensionPoint.ts b/src/vs/workbench/contrib/customEditor/browser/extensionPoint.ts index 5e169d1b2c4..2a126dabefe 100644 --- a/src/vs/workbench/contrib/customEditor/browser/extensionPoint.ts +++ b/src/vs/workbench/contrib/customEditor/browser/extensionPoint.ts @@ -53,10 +53,6 @@ const webviewEditorsContribution: IJSONSchema = { type: 'string', description: nls.localize('contributes.selector.filenamePattern', 'Glob that the custom editor is enabled for.'), }, - mime: { - type: 'string', - description: nls.localize('contributes.selector.mime', 'Glob that matches the mime type of a data uri resource.'), - } } } }, From 7d120c2d3e7c2c773cd9d2c4e26232e8aa9e3c88 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Nov 2019 15:48:16 -0800 Subject: [PATCH 19/23] Use chaining --- src/vs/workbench/api/common/extHostWebview.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/api/common/extHostWebview.ts b/src/vs/workbench/api/common/extHostWebview.ts index 2f48b4e01ea..3b717043577 100644 --- a/src/vs/workbench/api/common/extHostWebview.ts +++ b/src/vs/workbench/api/common/extHostWebview.ts @@ -449,18 +449,12 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { $undoEdits(handle: WebviewPanelHandle, edits: string[]): void { const panel = this.getWebviewPanel(handle); - if (!panel) { - return; - } - panel._undoEdits(edits); + panel?._undoEdits(edits); } $redoEdits(handle: WebviewPanelHandle, edits: string[]): void { const panel = this.getWebviewPanel(handle); - if (!panel) { - return; - } - panel._redoEdits(edits); + panel?._redoEdits(edits); } async $onSave(handle: WebviewPanelHandle): Promise { From e4fc57dcd20a135c79aa3b4ffdca6b996bc8cd0e Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Nov 2019 15:49:03 -0800 Subject: [PATCH 20/23] Don't convert json edit data tostring --- src/vs/workbench/api/common/extHostWebview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/api/common/extHostWebview.ts b/src/vs/workbench/api/common/extHostWebview.ts index 3b717043577..3cf879271d3 100644 --- a/src/vs/workbench/api/common/extHostWebview.ts +++ b/src/vs/workbench/api/common/extHostWebview.ts @@ -243,7 +243,7 @@ export class ExtHostWebviewEditor extends Disposable implements vscode.WebviewPa this._capabilities = capabilities; if (capabilities.editingCapability) { this._register(capabilities.editingCapability.onEdit(edit => { - this._proxy.$onEdit(this._handle, JSON.stringify(edit)); + this._proxy.$onEdit(this._handle, edit); })); } } From 00bc7c68dd749356f499504332a1a6e132686605 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 21 Nov 2019 20:09:44 -0800 Subject: [PATCH 21/23] Documentation for webview editors --- src/vs/vscode.proposed.d.ts | 43 +++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 7f26e5267b9..ce948daac9b 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1209,7 +1209,7 @@ declare module 'vscode' { //#region Custom editors, mjbvz /** - * + * Defines how a webview editor interacts with VS Code. */ interface WebviewEditorCapabilities { /** @@ -1224,26 +1224,36 @@ declare module 'vscode' { * * @return Thenable that signals the save is complete. */ - rename?(newResource: Uri): Thenable; + // rename?(newResource: Uri): Thenable; + /** + * Controls the editing functionality of a webview editor. This allows the webview editor to hook into standard + * editor events such as `undo` or `save`. + * + * WebviewEditors that do not have `editingCapability` are considered to be readonly. Users can still interact + * with readonly editors, but these editors will not integrate with VS Code's standard editor functionality. + */ readonly editingCapability?: WebviewEditorEditingCapability; } + /** + * Defines the editing functionality of a webview editor. This allows the webview editor to hook into standard + * editor events such as `undo` or `save`. + */ interface WebviewEditorEditingCapability { /** * Persist the resource. + * + * Extensions should persist the resource + * + * @return Thenable signaling that the save has completed. */ save(): Thenable; /** - * Called when the editor exits. - */ - hotExit(hotExitPath: Uri): Thenable; - - /** - * Signal to VS Code that an edit has occurred. + * Event triggered by extensions to signal to VS Code that an edit has occurred. * - * Edits must be a json serilizable object. + * The edit must be a json serializable object. */ readonly onEdit: Event; @@ -1269,14 +1279,16 @@ declare module 'vscode' { export interface WebviewEditorProvider { /** - * Fills out a `WebviewEditor` for a given resource. + * Resolve a webview editor for a given resource. + * + * To resolve a webview editor, a provider must fill in its initial html content and hook up all + * the event listeners it is interested it. The provider should also take ownership of the passed in `WebviewPanel`. * * @param input Information about the resource being resolved. * @param webview Webview being resolved. The provider should take ownership of this webview. * * @return Thenable to a `WebviewEditorCapabilities` indicating that the webview editor has been resolved. * The `WebviewEditorCapabilities` defines how the custom editor interacts with VS Code. - * **❗️Note**: `WebviewEditorCapabilities` is not actually implemented... yet! */ resolveWebviewEditor( input: { @@ -1287,6 +1299,15 @@ declare module 'vscode' { } namespace window { + /** + * Register a new provider for webview editors of a given type. + * + * @param viewType Type of the webview editor provider. + * @param provider Resolves webview editors. + * @param options Content settings for a webview panels the provider is given. + * + * @return Disposable that unregisters the `WebviewEditorProvider`. + */ export function registerWebviewEditorProvider( viewType: string, provider: WebviewEditorProvider, From 599c076d91be1374cf51004cec610f3bcaf4c9cd Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Fri, 22 Nov 2019 07:51:52 +0100 Subject: [PATCH 22/23] Fix path --- extensions/git/extension.webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/git/extension.webpack.config.js b/extensions/git/extension.webpack.config.js index 5efa2052e88..bf6953d3183 100644 --- a/extensions/git/extension.webpack.config.js +++ b/extensions/git/extension.webpack.config.js @@ -13,6 +13,6 @@ module.exports = withDefaults({ context: __dirname, entry: { main: './src/main.ts', - ['askpass-main']: './src/askpass-main.ts' + ['askpass-main']: './src/askpass/askpass-main.ts' } }); From 7c5d94547bbab9c3e642a526a8b723a7fa1d53c1 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 21 Nov 2019 16:24:06 +0100 Subject: [PATCH 23/23] simplify how alternative commands are defined, #73081 --- .../editor/contrib/gotoSymbol/goToCommands.ts | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/src/vs/editor/contrib/gotoSymbol/goToCommands.ts b/src/vs/editor/contrib/gotoSymbol/goToCommands.ts index 2c7b9cccefb..a0f70710925 100644 --- a/src/vs/editor/contrib/gotoSymbol/goToCommands.ts +++ b/src/vs/editor/contrib/gotoSymbol/goToCommands.ts @@ -49,15 +49,16 @@ export interface SymbolNavigationActionConfig { openToSide: boolean; openInPeek: boolean; muteMessage: boolean; + alternativeCommand?: string; } abstract class SymbolNavigationAction extends EditorAction { - private readonly _configuration: SymbolNavigationActionConfig; + private readonly _config: SymbolNavigationActionConfig; constructor(configuration: SymbolNavigationActionConfig, opts: IActionOptions) { super(opts); - this._configuration = configuration; + this._config = configuration; } run(accessor: ServicesAccessor, editor: ICodeEditor): Promise { @@ -83,11 +84,11 @@ abstract class SymbolNavigationAction extends EditorAction { alert(references.ariaMessage); const referenceCount = references.references.length; - const altAction = references.referenceAt(model.uri, pos) && editor.getAction(this._getAlternativeCommand()); + const altAction = references.referenceAt(model.uri, pos) && editor.getAction(this._config.alternativeCommand || ''); if (referenceCount === 0) { // no result -> show message - if (!this._configuration.muteMessage) { + if (!this._config.muteMessage) { const info = model.getWordAtPosition(pos); MessageController.get(editor).showMessage(this._getNoResultFoundMessage(info), pos); } @@ -115,20 +116,18 @@ abstract class SymbolNavigationAction extends EditorAction { protected abstract _getNoResultFoundMessage(info: IWordAtPosition | null): string; - protected abstract _getAlternativeCommand(): string; - protected abstract _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues; private async _onResult(editorService: ICodeEditorService, symbolNavService: ISymbolNavigationService, editor: IActiveCodeEditor, model: ReferencesModel): Promise { const gotoLocation = this._getGoToPreference(editor); - if (this._configuration.openInPeek || (gotoLocation === 'peek' && model.references.length > 1)) { + if (this._config.openInPeek || (gotoLocation === 'peek' && model.references.length > 1)) { this._openInPeek(editor, model); } else { const next = model.firstReference()!; const peek = model.references.length > 1 && gotoLocation === 'gotoAndPeek'; - const targetEditor = await this._openReference(editor, editorService, next, this._configuration.openToSide, !peek); + const targetEditor = await this._openReference(editor, editorService, next, this._config.openToSide, !peek); if (peek && targetEditor) { this._openInPeek(targetEditor, model); } else { @@ -182,7 +181,7 @@ abstract class SymbolNavigationAction extends EditorAction { private _openInPeek(target: ICodeEditor, model: ReferencesModel) { let controller = ReferencesController.get(target); if (controller && target.hasModel()) { - controller.toggleWidget(target.getSelection(), createCancelablePromise(_ => Promise.resolve(model)), this._configuration.openInPeek); + controller.toggleWidget(target.getSelection(), createCancelablePromise(_ => Promise.resolve(model)), this._config.openInPeek); } else { model.dispose(); } @@ -203,10 +202,6 @@ export class DefinitionAction extends SymbolNavigationAction { : nls.localize('generic.noResults', "No definition found"); } - protected _getAlternativeCommand(): string { - return 'editor.action.goToReferences'; - } - protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues { return editor.getOption(EditorOption.gotoLocation).multipleDefinitions; } @@ -224,7 +219,8 @@ registerEditorAction(class GoToDefinitionAction extends DefinitionAction { super({ openToSide: false, openInPeek: false, - muteMessage: false + muteMessage: false, + alternativeCommand: 'editor.action.goToReferences' }, { id: GoToDefinitionAction.id, label: nls.localize('actions.goToDecl.label', "Go to Definition"), @@ -327,10 +323,6 @@ class DeclarationAction extends SymbolNavigationAction { : nls.localize('decl.generic.noResults', "No declaration found"); } - protected _getAlternativeCommand(): string { - return 'editor.action.goToReferences'; - } - protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues { return editor.getOption(EditorOption.gotoLocation).multipleDeclarations; } @@ -344,7 +336,8 @@ registerEditorAction(class GoToDeclarationAction extends DeclarationAction { super({ openToSide: false, openInPeek: false, - muteMessage: false + muteMessage: false, + alternativeCommand: 'editor.action.goToReferences' }, { id: GoToDeclarationAction.id, label: nls.localize('actions.goToDeclaration.label', "Go to Declaration"), @@ -412,10 +405,6 @@ class TypeDefinitionAction extends SymbolNavigationAction { : nls.localize('goToTypeDefinition.generic.noResults', "No type definition found"); } - protected _getAlternativeCommand(): string { - return 'editor.action.goToReferences'; - } - protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues { return editor.getOption(EditorOption.gotoLocation).multipleTypeDefinitions; } @@ -429,7 +418,8 @@ registerEditorAction(class GoToTypeDefinitionAction extends TypeDefinitionAction super({ openToSide: false, openInPeek: false, - muteMessage: false + muteMessage: false, + alternativeCommand: 'editor.action.goToReferences' }, { id: GoToTypeDefinitionAction.ID, label: nls.localize('actions.goToTypeDefinition.label', "Go to Type Definition"), @@ -498,10 +488,6 @@ class ImplementationAction extends SymbolNavigationAction { : nls.localize('goToImplementation.generic.noResults', "No implementation found"); } - protected _getAlternativeCommand(): string { - return ''; - } - protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues { return editor.getOption(EditorOption.gotoLocation).multipleImplementations; } @@ -589,10 +575,6 @@ class ReferencesAction extends SymbolNavigationAction { : nls.localize('references.noGeneric', "No references found"); } - protected _getAlternativeCommand(): string { - return ''; - } - protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues { return editor.getOption(EditorOption.gotoLocation).multipleReferences; } @@ -694,8 +676,6 @@ class GenericGoToLocationAction extends SymbolNavigationAction { protected _getGoToPreference(editor: IActiveCodeEditor): GoToLocationValues { return this._gotoMultipleBehaviour ?? editor.getOption(EditorOption.gotoLocation).multipleReferences; } - - protected _getAlternativeCommand() { return ''; } } CommandsRegistry.registerCommand({