提交 5c112d77 编写于 作者: J João Moreno

Merge branch 'master' of https://github.com/microsoft/vscode

......@@ -64,6 +64,7 @@ const vscodeResources = [
'out-build/paths.js',
'out-build/vs/**/*.{svg,png,html}',
'!out-build/vs/code/browser/**/*.html',
'!out-build/vs/editor/standalone/**/*.svg',
'out-build/vs/base/common/performance.js',
'out-build/vs/base/node/languagePacks.js',
'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh,cpuUsage.sh,ps.sh}',
......
......@@ -224,23 +224,23 @@ export class ExtensionEditor extends BaseEditor {
builtin.textContent = localize('builtin', "Built-in");
const subtitle = append(details, $('.subtitle'));
const publisher = append(subtitle, $('span.publisher.clickable', { title: localize('publisher', "Publisher name"), tabIndex: 0 }));
const publisher = append(append(subtitle, $('.subtitle-entry')), $('span.publisher.clickable', { title: localize('publisher', "Publisher name"), tabIndex: 0 }));
const installCount = append(subtitle, $('span.install', { title: localize('install count', "Install count"), tabIndex: 0 }));
const installCount = append(append(subtitle, $('.subtitle-entry')), $('span.install', { title: localize('install count', "Install count"), tabIndex: 0 }));
const rating = append(subtitle, $('span.rating.clickable', { title: localize('rating', "Rating"), tabIndex: 0 }));
const rating = append(append(subtitle, $('.subtitle-entry')), $('span.rating.clickable', { title: localize('rating', "Rating"), tabIndex: 0 }));
const repository = append(subtitle, $('span.repository.clickable'));
const repository = append(append(subtitle, $('.subtitle-entry')), $('span.repository.clickable'));
repository.textContent = localize('repository', 'Repository');
repository.style.display = 'none';
repository.tabIndex = 0;
const license = append(subtitle, $('span.license.clickable'));
const license = append(append(subtitle, $('.subtitle-entry')), $('span.license.clickable'));
license.textContent = localize('license', 'License');
license.style.display = 'none';
license.tabIndex = 0;
const version = append(subtitle, $('span.version'));
const version = append(append(subtitle, $('.subtitle-entry')), $('span.version'));
version.textContent = localize('version', 'Version');
const description = append(details, $('.description'));
......
......@@ -113,7 +113,7 @@
line-height: 20px;
}
.extension-editor > .header > .details > .subtitle > .publisher {
.extension-editor > .header > .details > .subtitle .publisher {
font-size: 18px;
}
......@@ -124,12 +124,11 @@
align-items: center;
}
.extension-editor > .header > .details > .subtitle > .install > .count {
.extension-editor > .header > .details > .subtitle .install > .count {
margin-left: 6px;
}
.extension-editor > .header > .details > .subtitle > span:not(:first-child):not(:empty),
.extension-editor > .header > .details > .subtitle > a:not(:first-child):not(:empty) {
.extension-editor > .header > .details > .subtitle > div:not(:first-child):not(:empty) {
border-left: 1px solid rgba(128, 128, 128, 0.7);
margin-left: 14px;
padding-left: 14px;
......
......@@ -38,7 +38,7 @@ import { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { CollapseAllAction } from 'vs/base/browser/ui/tree/treeDefaults';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { SIDE_BAR_BACKGROUND, PANEL_BACKGROUND } from 'vs/workbench/common/theme';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { IHoverService, IHoverOptions } from 'vs/workbench/services/hover/browser/hover';
class Root implements ITreeItem {
label = { label: 'root' };
......@@ -795,6 +795,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
const resolvableNode: ResolvableTreeItem = node;
const hoverService = this.hoverService;
const hoverDelay = this.hoverDelay;
let hoverOptions: IHoverOptions | undefined;
function mouseOver(this: HTMLElement, e: MouseEvent): any {
let isHovering = true;
function mouseLeave(this: HTMLElement, e: MouseEvent): any {
......@@ -805,7 +806,10 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
await resolvableNode.resolve();
const tooltip = resolvableNode.tooltip ?? label;
if (isHovering && tooltip) {
hoverService.showHover({ text: isString(tooltip) ? { value: tooltip } : tooltip, target: this });
if (!hoverOptions) {
hoverOptions = { text: isString(tooltip) ? { value: tooltip } : tooltip, target: this };
}
hoverService.showHover(hoverOptions);
}
this.removeEventListener(DOM.EventType.MOUSE_LEAVE, mouseLeave);
}, hoverDelay);
......
......@@ -6,6 +6,7 @@
import { localize } from 'vs/nls';
import { Queue } from 'vs/base/common/async';
import * as json from 'vs/base/common/json';
import * as objects from 'vs/base/common/objects';
import { setProperty } from 'vs/base/common/jsonEdit';
import { Edit } from 'vs/base/common/jsonFormatter';
import { Disposable, IReference } from 'vs/base/common/lifecycle';
......@@ -143,7 +144,11 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
const eol = model.getEOL();
const key = keybindingItem.resolvedKeybinding ? keybindingItem.resolvedKeybinding.getUserSettingsLabel() : null;
if (key) {
this.applyEditsToBuffer(setProperty(model.getValue(), [-1], this.asObject(key, keybindingItem.command, keybindingItem.when ? keybindingItem.when.serialize() : undefined, true), { tabSize, insertSpaces, eol })[0], model);
const entry: IUserFriendlyKeybinding = this.asObject(key, keybindingItem.command, keybindingItem.when ? keybindingItem.when.serialize() : undefined, true);
const userKeybindingEntries = <IUserFriendlyKeybinding[]>json.parse(model.getValue());
if (userKeybindingEntries.every(e => !this.areSame(e, entry))) {
this.applyEditsToBuffer(setProperty(model.getValue(), [-1], entry, { tabSize, insertSpaces, eol })[0], model);
}
}
}
......@@ -196,6 +201,26 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
return object;
}
private areSame(a: IUserFriendlyKeybinding, b: IUserFriendlyKeybinding): boolean {
if (a.command !== b.command) {
return false;
}
if (a.key !== b.key) {
return false;
}
const whenA = ContextKeyExpr.deserialize(a.when);
const whenB = ContextKeyExpr.deserialize(b.when);
if ((whenA && !whenB) || (!whenA && whenB)) {
return false;
}
if (whenA && whenB && !whenA.equals(whenB)) {
return false;
}
if (!objects.equals(a.args, b.args)) {
return false;
}
return true;
}
private applyEditsToBuffer(edit: Edit, model: ITextModel): void {
const startPosition = model.getPositionAt(edit.offset);
......@@ -206,7 +231,6 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
model.pushEditOperations([new Selection(startPosition.lineNumber, startPosition.column, startPosition.lineNumber, startPosition.column)], [editOperation], () => []);
}
private resolveModelReference(): Promise<IReference<IResolvedTextEditorModel>> {
return this.fileService.exists(this.resource)
.then(exists => {
......
......@@ -220,6 +220,16 @@ suite('KeybindingsEditing', () => {
.then(() => assert.deepEqual(getUserKeybindings(), expected));
});
test('remove a default keybinding should not ad duplicate entries', async () => {
const expected: IUserFriendlyKeybinding[] = [{ key: 'alt+c', command: '-a' }];
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
await testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'a', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } } }));
assert.deepEqual(getUserKeybindings(), expected);
});
test('remove a user keybinding', () => {
writeToKeybindingsFile({ key: 'alt+c', command: 'b' });
return testObject.removeKeybinding(aResolvedKeybindingItem({ command: 'b', firstPart: { keyCode: KeyCode.KEY_C, modifiers: { altKey: true } }, isDefault: false }))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册