Just some trivial clean-up

This commit is contained in:
Jason Fields 2019-11-28 23:15:15 -05:00
parent 6e1334acc8
commit 2ffbb78833
10 changed files with 34 additions and 38 deletions

View File

@ -25,7 +25,6 @@ import { configuration } from './src/configuration/configuration';
import { globalState } from './src/state/globalState';
import { taskQueue } from './src/taskQueue';
import { Register } from './src/register/register';
import { vimrc } from './src/configuration/vimrc';
let extensionContext: vscode.ExtensionContext;
let previousActiveEditorId: EditorIdentity | null = null;
@ -123,13 +122,13 @@ export async function activate(context: vscode.ExtensionContext) {
);
registerEventListener(context, vscode.workspace.onDidChangeTextDocument, async event => {
const textWasDeleted = changeEvent =>
const textWasDeleted = (changeEvent: vscode.TextDocumentChangeEvent) =>
changeEvent.contentChanges.length === 1 &&
changeEvent.contentChanges[0].text === '' &&
changeEvent.contentChanges[0].range.start.line !==
changeEvent.contentChanges[0].range.end.line;
const textWasAdded = changeEvent =>
const textWasAdded = (changeEvent: vscode.TextDocumentChangeEvent) =>
changeEvent.contentChanges.length === 1 &&
(changeEvent.contentChanges[0].text === '\n' ||
changeEvent.contentChanges[0].text === '\r\n') &&

View File

@ -1583,6 +1583,7 @@ export abstract class MoveQuoteMatch extends BaseMovement {
isJump = true;
public async execAction(position: Position, vimState: VimState): Promise<IMovement> {
// TODO: Don't limit quote matching to the same line
const text = TextEditor.getLineAt(position).text;
const quoteMatcher = new QuoteMatcher(this.charToMatch, text);
let start = quoteMatcher.findOpening(position.character);

View File

@ -156,6 +156,8 @@ export class SelectABigWord extends TextObjectMovement {
* larger blocks. e.g. if you had "blah (foo [bar 'ba|z'])" then it would
* select 'baz' first. If you pressed af again, it'd then select [bar 'baz'],
* and if you did it a third time it would select "(foo [bar 'baz'])".
*
* Very similar is the now built-in `editor.action.smartSelect.expand`
*/
@RegisterAction
export class SelectAnExpandingBlock extends ExpandingSelection {

View File

@ -136,23 +136,10 @@ namespace LexerFunctions {
return null;
}
const c = state.next();
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
continue;
default:
state.backup();
tokens.push(emitToken(tokenType, state)!);
return lexRange;
if (!/[0-9]/.test(state.next())) {
state.backup();
tokens.push(emitToken(tokenType, state)!);
return lexRange;
}
}
};
@ -165,9 +152,8 @@ namespace LexerFunctions {
tokens.push(emitToken(TokenType.CommandName, state)!);
break;
}
const c = state.next();
const lc = c.toLowerCase();
if (lc >= 'a' && lc <= 'z') {
const c = state.next().toLowerCase();
if (c >= 'a' && c <= 'z') {
continue;
} else {
state.backup();

View File

@ -40,7 +40,7 @@ export class PairMatcher {
position: Position,
charToFind: string,
charToStack: string,
stackHeight,
stackHeight: number,
isNextMatchForward: boolean,
vimState?: VimState
): Position | undefined {
@ -107,7 +107,7 @@ export class PairMatcher {
return undefined;
}
private static keepSearching(lineNumber, lineCount, isNextMatchForward) {
private static keepSearching(lineNumber: number, lineCount: number, isNextMatchForward: boolean) {
if (isNextMatchForward) {
return lineNumber <= lineCount - 1;
} else {

View File

@ -288,7 +288,9 @@ export class Position extends vscode.Position {
}
}
// Iterates through words on the same line, starting from the current position.
/**
* Iterates through words on the same line, starting from the current position.
*/
public static *IterateWords(
start: Position
): Iterable<{ start: Position; end: Position; word: string }> {
@ -1297,16 +1299,19 @@ export class Position extends vscode.Position {
throw new Error('This should never happen...');
}
private findHelper(char: string, count: number, direction: number): Position | undefined {
// -1 = backwards, +1 = forwards
private findHelper(
char: string,
count: number,
direction: 'forward' | 'backward'
): Position | undefined {
const line = TextEditor.getLineAt(this);
let index = this.character;
while (count && index !== -1) {
if (direction > 0) {
index = line.text.indexOf(char, index + direction);
if (direction === 'forward') {
index = line.text.indexOf(char, index + 1);
} else {
index = line.text.lastIndexOf(char, index + direction);
index = line.text.lastIndexOf(char, index - 1);
}
count--;
}
@ -1319,7 +1324,7 @@ export class Position extends vscode.Position {
}
public tilForwards(char: string, count: number = 1): Position | null {
const position = this.findHelper(char, count, +1);
const position = this.findHelper(char, count, 'forward');
if (!position) {
return null;
}
@ -1328,7 +1333,7 @@ export class Position extends vscode.Position {
}
public tilBackwards(char: string, count: number = 1): Position | null {
const position = this.findHelper(char, count, -1);
const position = this.findHelper(char, count, 'backward');
if (!position) {
return null;
}
@ -1337,7 +1342,7 @@ export class Position extends vscode.Position {
}
public findForwards(char: string, count: number = 1): Position | null {
const position = this.findHelper(char, count, +1);
const position = this.findHelper(char, count, 'forward');
if (!position) {
return null;
}
@ -1346,7 +1351,7 @@ export class Position extends vscode.Position {
}
public findBackwards(char: string, count: number = 1): Position | null {
const position = this.findHelper(char, count, -1);
const position = this.findHelper(char, count, 'backward');
if (!position) {
return null;
}

View File

@ -13,7 +13,7 @@ import { VimState } from './../state/vimState';
/**
* There are two different modes of copy/paste in Vim - copy by character
* and copy by line. Copy by line typically happens in Visual Line mode, but
* also shows up in some other actions that work over lines (most noteably dd,
* also shows up in some other actions that work over lines (most notably dd,
* yy).
*/
export enum RegisterMode {

View File

@ -87,7 +87,7 @@ class StatusBarImpl implements vscode.Disposable {
'statusBar.foreground': `${foreground}`,
});
// if colors are undefined, return to vscode defaults
// If colors are undefined, return to VSCode defaults
if (background === undefined) {
delete colorCustomizations['statusBar.background'];
delete colorCustomizations['statusBar.noFolderBackground'];

View File

@ -1,6 +1,9 @@
import * as vscode from 'vscode';
import { Logger } from './logger';
/**
* A thin wrapper around `vscode.env.clipboard`
*/
export class Clipboard {
private static readonly logger = Logger.get('Clipboard');

View File

@ -10,7 +10,7 @@ interface VsCodeMessageOptions extends TransportStream.TransportStreamOptions {
/**
* Implementation of Winston transport
* Displays VS Code message to user
* Displays VSCode message to user
*/
class VsCodeMessage extends TransportStream {
prefix?: string;