Skip to content

Commit

Permalink
Merge pull request #7 from VSCode-Extension/assorted-fixes
Browse files Browse the repository at this point in the history
Assorted fixes
  • Loading branch information
guillermooo committed Nov 17, 2015
2 parents f8ffa5b + 46b81a2 commit 0232bda
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
2 changes: 0 additions & 2 deletions src/cmd_line/command_node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as vscode from "vscode";
import * as token from "./token";
import * as node from "./node";
import * as lexer from "./lexer";
import * as util from "../util";

export class WriteCommand implements node.CommandBase {
Expand Down
30 changes: 12 additions & 18 deletions src/cmd_line/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ module LexerFunctions {
// The first digit has already been lexed.
while (true) {
if (state.isAtEof) {
var emitted = emitToken(TokenType.LineNumber, state);
if (emitted) {
tokens.push(emitted);
};
tokens.push(emitToken(TokenType.LineNumber, state));
return null;
}
var c = state.next();
Expand Down Expand Up @@ -115,8 +112,7 @@ module LexerFunctions {
var lc = c.toLowerCase();
if (lc >= "a" && lc <= "z") {
continue;
}
else {
} else {
state.backup();
tokens.push(emitToken(TokenType.CommandName, state));
state.skipWhiteSpace();
Expand All @@ -139,19 +135,18 @@ module LexerFunctions {
state.skip("/"); // XXX: really?
var escaping : boolean;
var searchTerm = "";
while(!state.isAtEof) {
while (!state.isAtEof) {
var c = state.next();
if (c == "/" && !escaping) {
if (c === "/" && !escaping) {
break;
}
if (c == "\\") {
if (c === "\\") {
escaping = true;
continue;
}
else {
} else {
escaping = false;
}
searchTerm += c != "\\" ? c : "\\\\";
searchTerm += c !== "\\" ? c : "\\\\";
}
tokens.push(new Token(TokenType.ForwardSearch, searchTerm));
state.ignore();
Expand All @@ -166,19 +161,18 @@ module LexerFunctions {
state.skip("?"); // XXX: really?
var escaping : boolean;
var searchTerm = "";
while(!state.isAtEof) {
while (!state.isAtEof) {
var c = state.next();
if (c == "?" && !escaping) {
if (c === "?" && !escaping) {
break;
}
if (c == "\\") {
if (c === "\\") {
escaping = true;
continue;
}
else {
} else {
escaping = false;
}
searchTerm += c != "\\" ? c : "\\\\";
searchTerm += c !== "\\" ? c : "\\\\";
}
tokens.push(new Token(TokenType.ReverseSearch, searchTerm));
state.ignore();
Expand Down
6 changes: 2 additions & 4 deletions src/cmd_line/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ export function showCmdLine(initialText = "") {
function runCmdLine(s : string) : void {
try {
var cmd = parser.parse(s);
}
catch (e) {
} catch (e) {
util.showInfo(e);
return;
}

if (cmd.isEmpty) {
vscode.window.showInformationMessage("empty cmdline");
}
else {
} else {
cmd.runOn(vscode.window.activeTextEditor);
}
}
9 changes: 3 additions & 6 deletions src/cmd_line/node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as vscode from "vscode";
import * as token from "./token";
import * as node from "./node";
import * as lexer from "./lexer";
export * from "./command_node";

export class LineRange {
Expand All @@ -21,14 +19,13 @@ export class LineRange {
}

if (!this.separator) {
if (this.left.length > 0 && tok.type != token.TokenType.Offset) {
if (this.left.length > 0 && tok.type !== token.TokenType.Offset) {
// XXX: is this always this error?
throw Error("not a Vim command");
}
this.left.push(tok);
}
else {
if (this.right.length > 0 && tok.type != token.TokenType.Offset) {
} else {
if (this.right.length > 0 && tok.type !== token.TokenType.Offset) {
// XXX: is this always this error?
throw Error("not a Vim command");
}
Expand Down
7 changes: 2 additions & 5 deletions src/cmd_line/parser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as vscode from "vscode";
import * as token from "./token";
import * as node from "./node";
import * as lexer from "./lexer";
import {parseWriteCommandArgs, commandParsers} from "./subparsers";
import * as util from "../util";
import {commandParsers} from "./subparsers";

interface ParseFunction {
(state : ParserState, command : node.CommandLine) : ParseFunction;
Expand Down Expand Up @@ -66,8 +64,7 @@ function parseCommand(state : ParserState, commandLine : node.CommandLine) : Par
if (!state.isAtEof) {
state.backup();
return parseCommand;
}
else {
} else {
return null;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/cmd_line/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class Scanner {

// skips text while any of chars matches and ignores the text span
skipRun(...chars : string[]) : void {
while(!this.isAtEof) {
while (!this.isAtEof) {
var c = this.next();
if (chars.indexOf(c) == -1) {
if (chars.indexOf(c) === -1) {
break;
}
}
Expand All @@ -75,7 +75,7 @@ export class Scanner {
skipWhiteSpace(): void {
while (true) {
var c = this.next();
if (c == " " || c == "\t") {
if (c === " " || c === "\t") {
continue;
}
break;
Expand Down

0 comments on commit 0232bda

Please sign in to comment.