This commit is contained in:
Labhansh Agrawal
2020-05-01 14:26:03 +05:30
parent c818381ef1
commit 4702a0af9d
3 changed files with 15 additions and 10 deletions
+11 -8
View File
@@ -16,18 +16,21 @@ describe('xterm-addon-ligatures', () => {
before(() => {
sinon.stub(fontFinder, 'list').returns(Promise.resolve({
// eslint-disable-next-line @typescript-eslint/naming-convention
'Fira Code': [{
path: path.join(__dirname, '../fonts/firaCode.otf'),
style: fontFinder.Style.Regular,
type: fontFinder.Type.Monospace,
weight: 400
}],
// eslint-disable-next-line @typescript-eslint/naming-convention
'Iosevka': [{
path: path.join(__dirname, '../fonts/iosevka.ttf'),
style: fontFinder.Style.Regular,
type: fontFinder.Type.Monospace,
weight: 400
}],
// eslint-disable-next-line @typescript-eslint/naming-convention
'Nonexistant Font': [{
path: path.join(__dirname, '../fonts/nonexistant.ttf'),
style: fontFinder.Style.Regular,
@@ -185,32 +188,32 @@ describe('xterm-addon-ligatures', () => {
});
class MockTerminal {
static applyAddon(addon: any): void {
public static applyAddon(addon: any): void {
addon.apply(MockTerminal);
}
private _options: { [name: string]: string | number; } = {
private _options: { [name: string]: string | number } = {
fontFamily: 'Fira Code, monospace',
rows: 50
};
joiner?: (text: string) => [number, number][];
refresh: (start: number, end: number) => void;
public joiner?: (text: string) => [number, number][];
public refresh: (start: number, end: number) => void;
constructor(onRefresh: (start: number, end: number) => void) {
this.refresh = onRefresh;
}
registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
public registerCharacterJoiner(handler: (text: string) => [number, number][]): number {
this.joiner = handler;
return 1;
}
deregisterCharacterJoiner(id: number): void {
public deregisterCharacterJoiner(id: number): void {
this.joiner = undefined;
}
setOption(name: string, value: string | number): void {
public setOption(name: string, value: string | number): void {
this._options[name] = value;
}
getOption(name: string): string | number {
public getOption(name: string): string | number {
return this._options[name];
}
}
+2 -1
View File
@@ -70,7 +70,8 @@ export function enableLigatures(term: Terminal): void {
return font.findLigatureRanges(text).map<[number, number]>(
range => [range[0], range[1]]
);
} else if (loadingState === LoadingState.FAILED) {
}
if (loadingState === LoadingState.FAILED) {
throw loadError || new Error('Failure while loading font');
}
+2 -1
View File
@@ -150,7 +150,8 @@ function parseUnicode(context: IParseContext): string {
// The first whitespace character after a unicode escape indicates the end
// of the escape and is swallowed.
return unicodeToString(str);
} else if (str.length >= 6 || !/[0-9a-fA-F]/.test(char)) {
}
if (str.length >= 6 || !/[0-9a-fA-F]/.test(char)) {
// If the next character is not a valid hex digit or we have reached the
// maximum of 6 digits in the escape, terminate the escape.
context.offset--;