Merge from vscode e1d3dd53d17fb1529a002e4d6fb066db0a0bd385 (#6460)

* Merge from vscode e1d3dd53d17fb1529a002e4d6fb066db0a0bd385

* fix servers icon

* fix tests
This commit is contained in:
Anthony Dresser
2019-07-22 18:28:21 -07:00
committed by GitHub
parent f2afacd8b2
commit 15fc7a077a
91 changed files with 2562 additions and 972 deletions

View File

@@ -31,6 +31,7 @@ import { contrastBorder, editorFindMatch, editorFindMatchBorder, editorFindMatch
import { ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { ContextScopedFindInput, ContextScopedHistoryInputBox } from 'vs/platform/browser/contextScopedHistoryWidget';
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { alert as alertFn } from 'vs/base/browser/ui/aria/aria';
export interface IFindController {
replace(): void;
@@ -372,13 +373,26 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
} else {
label = NLS_NO_RESULTS;
}
this._matchesCount.appendChild(document.createTextNode(label));
alertFn(this._getAriaLabel(label, this._state.currentMatch, this._state.searchString), true);
MAX_MATCHES_COUNT_WIDTH = Math.max(MAX_MATCHES_COUNT_WIDTH, this._matchesCount.clientWidth);
}
// ----- actions
private _getAriaLabel(label: string, currentMatch: Range | null, searchString: string): string {
if (label === NLS_NO_RESULTS) {
return searchString === ''
? nls.localize('ariaSearchNoResultEmpty', "{0} found", label)
: nls.localize('ariaSearchNoResult', "{0} found for {1}", label, searchString);
}
return currentMatch
? nls.localize('ariaSearchNoResultWithLineNum', "{0} found for {1} at {2}", label, searchString, currentMatch.startLineNumber + ':' + currentMatch.startColumn)
: nls.localize('ariaSearchNoResultWithLineNumNoCurrentMatch', "{0} found for {1}", label, searchString);
}
/**
* If 'selection find' is ON we should not disable the button (its function is to cancel 'selection find').
* If 'selection find' is OFF we enable the button only if there is a selection.

View File

@@ -581,7 +581,7 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
return new Range(selection.startLineNumber, 1, selection.startLineNumber, selection.startColumn);
}
} else {
return selection;
return new Range(selection.startLineNumber, 1, selection.endLineNumber, selection.endColumn);
}
});

View File

@@ -268,7 +268,7 @@ suite('Editor Contrib - Line Operations', () => {
editor.setSelections([new Selection(2, 2, 2, 2), new Selection(2, 4, 2, 5)]);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(2), 'ord', '002');
assert.equal(model.getLineContent(2), 'd', '002');
editor.setSelections([new Selection(3, 2, 3, 5), new Selection(3, 7, 3, 7)]);
deleteAllLeftAction.run(null!, editor);
@@ -276,11 +276,11 @@ suite('Editor Contrib - Line Operations', () => {
editor.setSelections([new Selection(4, 3, 4, 3), new Selection(4, 5, 5, 4)]);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(4), 'lljour', '004');
assert.equal(model.getLineContent(4), 'jour', '004');
editor.setSelections([new Selection(5, 3, 6, 3), new Selection(6, 5, 7, 5), new Selection(7, 7, 7, 7)]);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(5), 'horlworld', '005');
assert.equal(model.getLineContent(5), 'world', '005');
});
});

View File

@@ -25,79 +25,43 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { editorActiveLinkForeground } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
const HOVER_MESSAGE_GENERAL_META = new MarkdownString().appendText(
platform.isMacintosh
? nls.localize('links.navigate.mac', "Follow link (cmd + click)")
: nls.localize('links.navigate', "Follow link (ctrl + click)")
);
function getHoverMessage(link: Link, useMetaKey: boolean): MarkdownString {
const executeCmd = link.url && /^command:/i.test(link.url.toString());
const HOVER_MESSAGE_COMMAND_META = new MarkdownString().appendText(
platform.isMacintosh
? nls.localize('links.command.mac', "Execute command (cmd + click)")
: nls.localize('links.command', "Execute command (ctrl + click)")
);
const label = link.tooltip
? link.tooltip
: executeCmd
? nls.localize('links.navigate.executeCmd', 'Execute command')
: nls.localize('links.navigate.follow', 'Follow link');
const HOVER_MESSAGE_GENERAL_ALT = new MarkdownString().appendText(
platform.isMacintosh
? nls.localize('links.navigate.al.mac', "Follow link (option + click)")
: nls.localize('links.navigate.al', "Follow link (alt + click)")
);
const kb = useMetaKey
? platform.isMacintosh
? nls.localize('links.navigate.kb.meta.mac', "cmd + click")
: nls.localize('links.navigate.kb.meta', "ctrl + click")
: platform.isMacintosh
? nls.localize('links.navigate.kb.alt.mac', "option + click")
: nls.localize('links.navigate.kb.alt', "alt + click");
const HOVER_MESSAGE_COMMAND_ALT = new MarkdownString().appendText(
platform.isMacintosh
? nls.localize('links.command.al.mac', "Execute command (option + click)")
: nls.localize('links.command.al', "Execute command (alt + click)")
);
if (link.url) {
const hoverMessage = new MarkdownString().appendMarkdown(`[${label}](${link.url.toString()}) (${kb})`);
hoverMessage.isTrusted = true;
return hoverMessage;
} else {
return new MarkdownString().appendText(`${label} (${kb})`);
}
}
const decoration = {
meta: ModelDecorationOptions.register({
general: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link',
hoverMessage: HOVER_MESSAGE_GENERAL_META
inlineClassName: 'detected-link'
}),
metaActive: ModelDecorationOptions.register({
active: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link-active',
hoverMessage: HOVER_MESSAGE_GENERAL_META
}),
alt: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link',
hoverMessage: HOVER_MESSAGE_GENERAL_ALT
}),
altActive: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link-active',
hoverMessage: HOVER_MESSAGE_GENERAL_ALT
}),
altCommand: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link',
hoverMessage: HOVER_MESSAGE_COMMAND_ALT
}),
altCommandActive: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link-active',
hoverMessage: HOVER_MESSAGE_COMMAND_ALT
}),
metaCommand: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link',
hoverMessage: HOVER_MESSAGE_COMMAND_META
}),
metaCommandActive: ModelDecorationOptions.register({
stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges,
collapseOnReplaceEdit: true,
inlineClassName: 'detected-link-active',
hoverMessage: HOVER_MESSAGE_COMMAND_META
}),
inlineClassName: 'detected-link-active'
})
};
@@ -111,38 +75,11 @@ class LinkOccurrence {
}
private static _getOptions(link: Link, useMetaKey: boolean, isActive: boolean): ModelDecorationOptions {
const options = { ...this._getBaseOptions(link, useMetaKey, isActive) };
if (typeof link.tooltip === 'string') {
const message = new MarkdownString().appendText(
platform.isMacintosh
? useMetaKey
? nls.localize('links.custom.mac', "{0} (cmd + click)", link.tooltip)
: nls.localize('links.custom.mac.al', "{0} (option + click)", link.tooltip)
: useMetaKey
? nls.localize('links.custom', "{0} (ctrl + click)", link.tooltip)
: nls.localize('links.custom.al', "{0} (alt + click)", link.tooltip)
);
options.hoverMessage = message;
}
const options = { ... (isActive ? decoration.active : decoration.general) };
options.hoverMessage = getHoverMessage(link, useMetaKey);
return options;
}
private static _getBaseOptions(link: Link, useMetaKey: boolean, isActive: boolean): ModelDecorationOptions {
if (link.url && /^command:/i.test(link.url.toString())) {
if (useMetaKey) {
return (isActive ? decoration.metaCommandActive : decoration.metaCommand);
} else {
return (isActive ? decoration.altCommandActive : decoration.altCommand);
}
} else {
if (useMetaKey) {
return (isActive ? decoration.metaActive : decoration.meta);
} else {
return (isActive ? decoration.altActive : decoration.alt);
}
}
}
public decorationId: string;
public link: Link;