Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into tyriar/11275_termin…
Browse files Browse the repository at this point in the history
…al_refactor
  • Loading branch information
Tyriar committed Sep 12, 2016
2 parents b2d6d33 + 54e6e40 commit 5183372
Show file tree
Hide file tree
Showing 89 changed files with 2,177 additions and 1,216 deletions.
6 changes: 3 additions & 3 deletions build/npm/preinstall.js
Expand Up @@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

var win = "Please run '.\\scripts\\npm.bat install' instead."
var nix = "Please run './scripts/npm.sh install' instead."
var win = "Please run '.\\scripts\\npm.bat install' instead.";
var nix = "Please run './scripts/npm.sh install' instead.";

if (process.env['npm_config_disturl'] !== 'https://atom.io/download/atom-shell') {
console.error("You can't use plain npm to install Code's dependencies.");
console.error(/^win/.test(process.platform) ? win : nix);
process.exit(1);
}
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -107,6 +107,7 @@
}
},
"optionalDependencies": {
"windows-mutex": "^0.2.0"
"windows-mutex": "^0.2.0",
"fsevents": "0.3.8"
}
}
2 changes: 1 addition & 1 deletion src/main.js
Expand Up @@ -122,7 +122,7 @@ try {
}

// Set userData path before app 'ready' event
var userData = args['user-data-dir'] || paths.getDefaultUserDataPath(process.platform);
var userData = path.resolve(args['user-data-dir'] || paths.getDefaultUserDataPath(process.platform));
app.setPath('userData', userData);

// Mac: when someone drops a file to the not-yet running VSCode, the open-file event fires even before
Expand Down
6 changes: 3 additions & 3 deletions src/vs/base/browser/dom.ts
Expand Up @@ -13,6 +13,7 @@ import {isObject} from 'vs/base/common/types';
import {isChrome, isWebKit} from 'vs/base/browser/browser';
import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent';
import {IMouseEvent, StandardMouseEvent} from 'vs/base/browser/mouseEvent';
import {CharCode} from 'vs/base/common/charCode';

export function clearNode(node: HTMLElement) {
while (node.firstChild) {
Expand Down Expand Up @@ -55,7 +56,6 @@ export function isInDOM(node: Node): boolean {
return false;
}

const _blank = ' '.charCodeAt(0);
let lastStart: number, lastEnd: number;

function _findClassName(node: HTMLElement, className: string): void {
Expand Down Expand Up @@ -95,14 +95,14 @@ function _findClassName(node: HTMLElement, className: string): void {
idxEnd = idx + classLen;

// a class that is followed by another class
if ((idx === 0 || classes.charCodeAt(idx - 1) === _blank) && classes.charCodeAt(idxEnd) === _blank) {
if ((idx === 0 || classes.charCodeAt(idx - 1) === CharCode.Space) && classes.charCodeAt(idxEnd) === CharCode.Space) {
lastStart = idx;
lastEnd = idxEnd + 1;
return;
}

// last class
if (idx > 0 && classes.charCodeAt(idx - 1) === _blank && idxEnd === classesLen) {
if (idx > 0 && classes.charCodeAt(idx - 1) === CharCode.Space && idxEnd === classesLen) {
lastStart = idx - 1;
lastEnd = idxEnd;
return;
Expand Down
10 changes: 9 additions & 1 deletion src/vs/base/browser/event.ts
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import _Event, { Emitter } from 'vs/base/common/event';
import _Event, { Emitter, mapEvent } from 'vs/base/common/event';

export type EventHandler = HTMLElement | HTMLDocument | Window;

Expand Down Expand Up @@ -127,3 +127,11 @@ export const domEvent: IDomEvent = (element: EventHandler, type: string, useCapt

return emitter.event;
};

export function stop<T extends Event>(event: _Event<T>): _Event<T> {
return mapEvent(event, e => {
e.preventDefault();
e.stopPropagation();
return e;
});
}
17 changes: 9 additions & 8 deletions src/vs/base/browser/ui/list/listWidget.ts
Expand Up @@ -10,7 +10,7 @@ import * as DOM from 'vs/base/browser/dom';
import { EventType as TouchEventType } from 'vs/base/browser/touch';
import { KeyCode } from 'vs/base/common/keyCodes';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import Event, { Emitter, mapEvent, EventBufferer, filterEvent } from 'vs/base/common/event';
import Event, { Emitter, EventBufferer, chain, mapEvent } from 'vs/base/common/event';
import { domEvent } from 'vs/base/browser/event';
import { IDelegate, IRenderer, IListMouseEvent, IFocusChangeEvent, ISelectionChangeEvent } from './list';
import { ListView, IListViewOptions } from './listView';
Expand Down Expand Up @@ -134,13 +134,14 @@ class Controller<T> implements IDisposable {
this.disposables.push(view.addListener('click', e => this.onPointer(e)));
this.disposables.push(view.addListener(TouchEventType.Tap, e => this.onPointer(e)));

const onRawKeyDown = domEvent(view.domNode, 'keydown');
const onKeyDown = mapEvent(onRawKeyDown, e => new StandardKeyboardEvent(e));
filterEvent(onKeyDown, e => e.keyCode === KeyCode.Enter)(this.onEnter, this, this.disposables);
filterEvent(onKeyDown, e => e.keyCode === KeyCode.UpArrow)(this.onUpArrow, this, this.disposables);
filterEvent(onKeyDown, e => e.keyCode === KeyCode.DownArrow)(this.onDownArrow, this, this.disposables);
filterEvent(onKeyDown, e => e.keyCode === KeyCode.PageUp)(this.onPageUpArrow, this, this.disposables);
filterEvent(onKeyDown, e => e.keyCode === KeyCode.PageDown)(this.onPageDownArrow, this, this.disposables);
const onKeyDown = chain(domEvent(view.domNode, 'keydown'))
.map(e => new StandardKeyboardEvent(e));

onKeyDown.filter(e => e.keyCode === KeyCode.Enter).on(this.onEnter, this, this.disposables);
onKeyDown.filter(e => e.keyCode === KeyCode.UpArrow).on(this.onUpArrow, this, this.disposables);
onKeyDown.filter(e => e.keyCode === KeyCode.DownArrow).on(this.onDownArrow, this, this.disposables);
onKeyDown.filter(e => e.keyCode === KeyCode.PageUp).on(this.onPageUpArrow, this, this.disposables);
onKeyDown.filter(e => e.keyCode === KeyCode.PageDown).on(this.onPageDownArrow, this, this.disposables);
}

private onMouseDown(e: IListMouseEvent<T>) {
Expand Down
237 changes: 237 additions & 0 deletions src/vs/base/common/charCode.ts
@@ -0,0 +1,237 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';

// Names from https://blog.codinghorror.com/ascii-pronunciation-rules-for-programmers/

/**
* An inlined enum containing useful character codes (to be used with String.charCodeAt).
* Please leave the const keyword such that it gets inlined when compiled to JavaScript!
*/
export const enum CharCode {
Null = 0,
/**
* The `\t` character.
*/
Tab = 9,
/**
* The `\n` character.
*/
LineFeed = 10,
/**
* The `\r` character.
*/
CarriageReturn = 13,
Space = 32,
/**
* The `!` character.
*/
ExclamationMark = 33,
/**
* The `"` character.
*/
DoubleQuote = 34,
/**
* The `#` character.
*/
Hash = 35,
/**
* The `$` character.
*/
DollarSign = 36,
/**
* The `%` character.
*/
PercentSign = 37,
/**
* The `&` character.
*/
Ampersand = 38,
/**
* The `'` character.
*/
SingleQuote = 39,
/**
* The `(` character.
*/
OpenParen = 40,
/**
* The `)` character.
*/
CloseParen = 41,
/**
* The `*` character.
*/
Asterisk = 42,
/**
* The `+` character.
*/
Plus = 43,
/**
* The `,` character.
*/
Comma = 44,
/**
* The `-` character.
*/
Dash = 45,
/**
* The `.` character.
*/
Period = 46,
/**
* The `/` character.
*/
Slash = 47,

Digit0 = 48,
Digit1 = 49,
Digit2 = 50,
Digit3 = 51,
Digit4 = 52,
Digit5 = 53,
Digit6 = 54,
Digit7 = 55,
Digit8 = 56,
Digit9 = 57,

/**
* The `:` character.
*/
Colon = 58,
/**
* The `;` character.
*/
Semicolon = 59,
/**
* The `<` character.
*/
LessThan = 60,
/**
* The `=` character.
*/
Equals = 61,
/**
* The `>` character.
*/
GreaterThan = 62,
/**
* The `?` character.
*/
QuestionMark = 63,
/**
* The `@` character.
*/
AtSign = 64,

A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,

/**
* The `[` character.
*/
OpenSquareBracket = 91,
/**
* The `\` character.
*/
Backslash = 92,
/**
* The `]` character.
*/
CloseSquareBracket = 93,
/**
* The `^` character.
*/
Caret = 94,
/**
* The `_` character.
*/
Underline = 95,
/**
* The ``(`)`` character.
*/
BackTick = 96,

a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,

/**
* The `{` character.
*/
OpenCurlyBrace = 123,
/**
* The `|` character.
*/
Pipe = 124,
/**
* The `}` character.
*/
CloseCurlyBrace = 125,
/**
* The `~` character.
*/
Tilde = 126,

/**
* Unicode Character 'LINE SEPARATOR' (U+2028)
* http://www.fileformat.info/info/unicode/char/2028/index.htm
*/
LINE_SEPARATOR_2028 = 8232,

/**
* UTF-8 BOM
* Unicode Character 'ZERO WIDTH NO-BREAK SPACE' (U+FEFF)
* http://www.fileformat.info/info/unicode/char/feff/index.htm
*/
UTF8_BOM = 65279
}

0 comments on commit 5183372

Please sign in to comment.