Merge pull request #4089 from Tyriar/lgtm

Fix lgtm recommendations
This commit is contained in:
Daniel Imms
2022-08-31 06:26:56 -07:00
committed by GitHub
17 changed files with 29 additions and 40 deletions
@@ -3,12 +3,11 @@
* @license MIT * @license MIT
*/ */
import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types'; import { IRenderDimensions } from 'browser/renderer/Types';
import { BaseRenderLayer } from './BaseRenderLayer'; import { BaseRenderLayer } from './BaseRenderLayer';
import { IColorSet } from 'browser/Types'; import { IColorSet } from 'browser/Types';
import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services'; import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
import { ICoreBrowserService } from 'browser/services/Services'; import { ICoreBrowserService } from 'browser/services/Services';
import { IEventEmitter } from 'common/EventEmitter';
interface ISelectionState { interface ISelectionState {
start?: [number, number]; start?: [number, number];
@@ -8,7 +8,7 @@ import { WebglCharAtlas } from './atlas/WebglCharAtlas';
import { IWebGL2RenderingContext, IWebGLVertexArrayObject, IRenderModel, IRasterizedGlyph } from './Types'; import { IWebGL2RenderingContext, IWebGLVertexArrayObject, IRenderModel, IRasterizedGlyph } from './Types';
import { fill } from 'common/TypedArrayUtils'; import { fill } from 'common/TypedArrayUtils';
import { NULL_CELL_CODE } from 'common/buffer/Constants'; import { NULL_CELL_CODE } from 'common/buffer/Constants';
import { Terminal, IBufferLine } from 'xterm'; import { Terminal } from 'xterm';
import { IColorSet } from 'browser/Types'; import { IColorSet } from 'browser/Types';
import { IRenderDimensions } from 'browser/renderer/Types'; import { IRenderDimensions } from 'browser/renderer/Types';
import { Disposable, toDisposable } from 'common/Lifecycle'; import { Disposable, toDisposable } from 'common/Lifecycle';
-4
View File
@@ -3,10 +3,6 @@
* @license MIT * @license MIT
*/ */
export interface IRasterizedGlyphSet {
[bg: number]: { [fg: number]: { [ext: number]: IRasterizedGlyph } } | undefined;
}
/** /**
* Represents a rasterized glyph within a texture atlas. Some numbers are * Represents a rasterized glyph within a texture atlas. Some numbers are
* tracked in CSS pixels as well in order to reduce calculations during the * tracked in CSS pixels as well in order to reduce calculations during the
@@ -5,7 +5,7 @@
import { ICharAtlasConfig } from './Types'; import { ICharAtlasConfig } from './Types';
import { DIM_OPACITY, TEXT_BASELINE } from 'browser/renderer/Constants'; import { DIM_OPACITY, TEXT_BASELINE } from 'browser/renderer/Constants';
import { IRasterizedGlyph, IBoundingBox, IRasterizedGlyphSet } from '../Types'; import { IRasterizedGlyph, IBoundingBox } from '../Types';
import { DEFAULT_COLOR, Attributes, DEFAULT_EXT, UnderlineStyle } from 'common/buffer/Constants'; import { DEFAULT_COLOR, Attributes, DEFAULT_EXT, UnderlineStyle } from 'common/buffer/Constants';
import { throwIfFalsy } from '../WebglUtils'; import { throwIfFalsy } from '../WebglUtils';
import { IColor } from 'common/Types'; import { IColor } from 'common/Types';
@@ -450,7 +450,6 @@ export class WebglCharAtlas implements IDisposable {
// Underline style/stroke // Underline style/stroke
this._tmpCtx.beginPath(); this._tmpCtx.beginPath();
const xLeft = padding; const xLeft = padding;
const xRight = padding + this._config.scaledCellWidth * chWidth;
const yTop = Math.ceil(padding + this._config.scaledCharHeight) - yOffset; const yTop = Math.ceil(padding + this._config.scaledCharHeight) - yOffset;
const yMid = padding + this._config.scaledCharHeight + lineWidth - yOffset; const yMid = padding + this._config.scaledCharHeight + lineWidth - yOffset;
const yBot = Math.ceil(padding + this._config.scaledCharHeight + lineWidth * 2) - yOffset; const yBot = Math.ceil(padding + this._config.scaledCharHeight + lineWidth * 2) - yOffset;
@@ -7,7 +7,7 @@ import { Terminal } from 'xterm';
import { BaseRenderLayer } from './BaseRenderLayer'; import { BaseRenderLayer } from './BaseRenderLayer';
import { ICellData } from 'common/Types'; import { ICellData } from 'common/Types';
import { CellData } from 'common/buffer/CellData'; import { CellData } from 'common/buffer/CellData';
import { IColorSet, ITerminal } from 'browser/Types'; import { IColorSet } from 'browser/Types';
import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types'; import { IRenderDimensions, IRequestRedrawEvent } from 'browser/renderer/Types';
import { IEventEmitter } from 'common/EventEmitter'; import { IEventEmitter } from 'common/EventEmitter';
import { ICoreBrowserService } from 'browser/services/Services'; import { ICoreBrowserService } from 'browser/services/Services';
+1 -1
View File
@@ -362,7 +362,7 @@ function* parseMultiLineGen(filename, s) {
if (!s.includes('@vt:')) { if (!s.includes('@vt:')) {
return; return;
} }
const lines = s.split('\n').map(el => el.trim().replace(/\*/, '').replace(/\s/, '')); const lines = s.split('\n').map(el => el.trim().replace(/\*/, '').replace(/\s/, '')); // lgtm [js/incomplete-sanitization]
let grabLine = false; let grabLine = false;
let longDescription = []; let longDescription = [];
let feature = undefined; let feature = undefined;
+2 -2
View File
@@ -10,8 +10,8 @@
<link rel="shortcut icon" type="image/png" href="/logo.png"> <link rel="shortcut icon" type="image/png" href="/logo.png">
<link rel="stylesheet" href="/xterm.css" /> <link rel="stylesheet" href="/xterm.css" />
<link rel="stylesheet" href="/style.css" /> <link rel="stylesheet" href="/style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js" integrity="sha384-kM3+BR0fKGmv8mDasMGLSHdqcbgWHUNWV1rAL+tkqnH578xS82vhlu9gR5BHhBai" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js" integrity="sha384-bR8my2pcqqtUkMMTomrgTyDVACSJz1M9D70XdkeK2BaYbCYxG3CfngYdSAOcPkUZ" crossorigin="anonymous"></script>
</head> </head>
<body> <body>
<h1 style="color: #2D2E2C">xterm.js: A terminal for the <em style="color: #5DA5D5">web</em></h1> <h1 style="color: #2D2E2C">xterm.js: A terminal for the <em style="color: #5DA5D5">web</em></h1>
+14 -16
View File
@@ -213,22 +213,20 @@ export class Terminal extends CoreTerminal implements ITerminal {
acc = 'ansi'; acc = 'ansi';
ident = '4;' + req.index; ident = '4;' + req.index;
} }
if (acc) { switch (req.type) {
switch (req.type) { case ColorRequestType.REPORT:
case ColorRequestType.REPORT: const channels = color.toColorRGB(acc === 'ansi'
const channels = color.toColorRGB(acc === 'ansi' ? this._colorManager.colors.ansi[req.index]
? this._colorManager.colors.ansi[req.index] : this._colorManager.colors[acc]);
: this._colorManager.colors[acc]); this.coreService.triggerDataEvent(`${C0.ESC}]${ident};${toRgbString(channels)}${C1_ESCAPED.ST}`);
this.coreService.triggerDataEvent(`${C0.ESC}]${ident};${toRgbString(channels)}${C1_ESCAPED.ST}`); break;
break; case ColorRequestType.SET:
case ColorRequestType.SET: if (acc === 'ansi') this._colorManager.colors.ansi[req.index] = rgba.toColor(...req.color);
if (acc === 'ansi') this._colorManager.colors.ansi[req.index] = rgba.toColor(...req.color); else this._colorManager.colors[acc] = rgba.toColor(...req.color);
else this._colorManager.colors[acc] = rgba.toColor(...req.color); break;
break; case ColorRequestType.RESTORE:
case ColorRequestType.RESTORE: this._colorManager.restoreColor(req.index);
this._colorManager.restoreColor(req.index); break;
break;
}
} }
} }
this._renderService?.setColors(this._colorManager.colors); this._renderService?.setColors(this._colorManager.colors);
+1 -1
View File
@@ -7,7 +7,7 @@ import { IDisposable, IMarker, ILinkProvider, IDecorationOptions, IDecoration }
import { IEvent, EventEmitter } from 'common/EventEmitter'; import { IEvent, EventEmitter } from 'common/EventEmitter';
import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IMouseService, IRenderService, ISelectionService } from 'browser/services/Services'; import { ICharacterJoinerService, ICharSizeService, ICoreBrowserService, IMouseService, IRenderService, ISelectionService } from 'browser/services/Services';
import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/Types'; import { IRenderDimensions, IRenderer, IRequestRedrawEvent } from 'browser/renderer/Types';
import { IColorSet, ITerminal, ILinkifier2, IBrowser, IViewport, IColorManager, ICompositionHelper, CharacterJoinerHandler, IRenderDebouncer, IBufferRange } from 'browser/Types'; import { IColorSet, ITerminal, ILinkifier2, IBrowser, IViewport, IColorManager, ICompositionHelper, CharacterJoinerHandler, IBufferRange } from 'browser/Types';
import { IBuffer, IBufferStringIterator, IBufferSet } from 'common/buffer/Types'; import { IBuffer, IBufferStringIterator, IBufferSet } from 'common/buffer/Types';
import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener, ICharset, ITerminalOptions } from 'common/Types'; import { IBufferLine, ICellData, IAttributeData, ICircularList, XtermListener, ICharset, ITerminalOptions } from 'common/Types';
import { Buffer } from 'common/buffer/Buffer'; import { Buffer } from 'common/buffer/Buffer';
@@ -7,7 +7,7 @@ import { ColorZoneStore, IColorZone, IColorZoneStore } from 'browser/decorations
import { addDisposableDomListener } from 'browser/Lifecycle'; import { addDisposableDomListener } from 'browser/Lifecycle';
import { IRenderService } from 'browser/services/Services'; import { IRenderService } from 'browser/services/Services';
import { Disposable } from 'common/Lifecycle'; import { Disposable } from 'common/Lifecycle';
import { IBufferService, IDecorationService, IInternalDecoration, IOptionsService } from 'common/services/Services'; import { IBufferService, IDecorationService, IOptionsService } from 'common/services/Services';
// Helper objects to avoid excessive calculation and garbage collection during rendering. These are // Helper objects to avoid excessive calculation and garbage collection during rendering. These are
// static values for each render and can be accessed using the decoration position as the key. // static values for each render and can be accessed using the decoration position as the key.
+1 -1
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { Terminal as ITerminalApi, IMarker, IDisposable, ILocalizableStrings, ITerminalAddon, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight, IModes, IDecorationOptions, IDecoration } from 'xterm'; import { Terminal as ITerminalApi, IMarker, IDisposable, ILocalizableStrings, ITerminalAddon, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, IModes, IDecorationOptions, IDecoration } from 'xterm';
import { IBufferRange, ITerminal } from 'browser/Types'; import { IBufferRange, ITerminal } from 'browser/Types';
import { Terminal as TerminalCore } from 'browser/Terminal'; import { Terminal as TerminalCore } from 'browser/Terminal';
import * as Strings from 'browser/LocalizableStrings'; import * as Strings from 'browser/LocalizableStrings';
+1 -1
View File
@@ -9,7 +9,7 @@ import { INVERTED_DEFAULT_COLOR } from 'browser/renderer/Constants';
import { Disposable } from 'common/Lifecycle'; import { Disposable } from 'common/Lifecycle';
import { IColorSet, ILinkifierEvent, ILinkifier2 } from 'browser/Types'; import { IColorSet, ILinkifierEvent, ILinkifier2 } from 'browser/Types';
import { ICharSizeService } from 'browser/services/Services'; import { ICharSizeService } from 'browser/services/Services';
import { IOptionsService, IBufferService, IInstantiationService, IDecorationService } from 'common/services/Services'; import { IOptionsService, IBufferService, IInstantiationService } from 'common/services/Services';
import { EventEmitter, IEvent } from 'common/EventEmitter'; import { EventEmitter, IEvent } from 'common/EventEmitter';
import { color } from 'common/Color'; import { color } from 'common/Color';
import { removeElementFromParent } from 'browser/Dom'; import { removeElementFromParent } from 'browser/Dom';
+1 -1
View File
@@ -9,7 +9,7 @@ import { EventEmitter, IEvent } from 'common/EventEmitter';
import { Disposable } from 'common/Lifecycle'; import { Disposable } from 'common/Lifecycle';
import { ScreenDprMonitor } from 'browser/ScreenDprMonitor'; import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
import { addDisposableDomListener } from 'browser/Lifecycle'; import { addDisposableDomListener } from 'browser/Lifecycle';
import { IColorSet, IRenderDebouncer, IRenderDebouncerWithCallback } from 'browser/Types'; import { IColorSet, IRenderDebouncerWithCallback } from 'browser/Types';
import { IOptionsService, IBufferService, IDecorationService } from 'common/services/Services'; import { IOptionsService, IBufferService, IDecorationService } from 'common/services/Services';
import { ICharSizeService, IRenderService } from 'browser/services/Services'; import { ICharSizeService, IRenderService } from 'browser/services/Services';
+1 -3
View File
@@ -5,12 +5,10 @@
import { IEvent } from 'common/EventEmitter'; import { IEvent } from 'common/EventEmitter';
import { IRenderDimensions, IRenderer } from 'browser/renderer/Types'; import { IRenderDimensions, IRenderer } from 'browser/renderer/Types';
import { IColorSet, IRenderDebouncer } from 'browser/Types'; import { IColorSet } from 'browser/Types';
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types'; import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
import { createDecorator } from 'common/services/ServiceRegistry'; import { createDecorator } from 'common/services/ServiceRegistry';
import { IDisposable } from 'common/Types'; import { IDisposable } from 'common/Types';
import { IDecorationOptions, IDecoration } from 'xterm';
import { IBufferService } from 'common/services/Services';
export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService'); export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService');
export interface ICharSizeService { export interface ICharSizeService {
+1 -1
View File
@@ -27,7 +27,7 @@ import { InstantiationService } from 'common/services/InstantiationService';
import { LogService } from 'common/services/LogService'; import { LogService } from 'common/services/LogService';
import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService'; import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/BufferService';
import { OptionsService } from 'common/services/OptionsService'; import { OptionsService } from 'common/services/OptionsService';
import { IDisposable, IBufferLine, IAttributeData, ICoreTerminal, IKeyboardEvent, IScrollEvent, ScrollSource, ITerminalOptions as IPublicTerminalOptions } from 'common/Types'; import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent, ScrollSource } from 'common/Types';
import { CoreService } from 'common/services/CoreService'; import { CoreService } from 'common/services/CoreService';
import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
import { CoreMouseService } from 'common/services/CoreMouseService'; import { CoreMouseService } from 'common/services/CoreMouseService';
-1
View File
@@ -120,7 +120,6 @@ export class OptionsService implements IOptionsService {
throw new Error(`"${value}" is not a valid value for ${key}`); throw new Error(`"${value}" is not a valid value for ${key}`);
} }
break; break;
case 'cursorStyle':
case 'wordSeparator': case 'wordSeparator':
if (!value) { if (!value) {
value = DEFAULT_OPTIONS[key]; value = DEFAULT_OPTIONS[key];
+1 -1
View File
@@ -5,7 +5,7 @@
import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IEvent, IEventEmitter } from 'common/EventEmitter';
import { IBuffer, IBufferSet } from 'common/buffer/Types'; import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColorRGB, IColor, CursorStyle, IOscLinkData } from 'common/Types'; import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColor, CursorStyle, IOscLinkData } from 'common/Types';
import { createDecorator } from 'common/services/ServiceRegistry'; import { createDecorator } from 'common/services/ServiceRegistry';
import { IDecorationOptions, IDecoration, ILinkHandler } from 'xterm'; import { IDecorationOptions, IDecoration, ILinkHandler } from 'xterm';