Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ gulp.task(
),
);
gulp.task('default', shell.task('yarn build-dev'));
gulp.task('build-dev', shell.task('yarn build-dev'));
40 changes: 40 additions & 0 deletions src/cmd_line/commands/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type ITabCommandArguments =
bang: boolean;
cmd?: FileCmd;
count?: number;
file?: string;
}
| {
type: TabCommandType.Close | TabCommandType.Only;
Expand Down Expand Up @@ -126,6 +127,14 @@ export class TabCommand extends ExCommand {
file,
});
}),
next: seq(
bangParser,
optWhitespace.then(alt<number | string>(numberParser, fileNameParser)).fallback(undefined),
).map(([bang, arg]) => {
const count = typeof arg === 'number' ? arg : undefined;
const file = typeof arg === 'string' ? arg : undefined;
return new TabCommand({ type: TabCommandType.Next, bang, count, file });
}),
tabmove: optWhitespace
.then(
seq(
Expand Down Expand Up @@ -180,6 +189,37 @@ export class TabCommand extends ExCommand {
}
break;
case TabCommandType.Next:
if (this.arguments.file) {
const isAbsolute = path.isAbsolute(this.arguments.file);
const currentFilePath = vscode.window.activeTextEditor!.document.uri.fsPath;
const isInWorkspace =
vscode.workspace.workspaceFolders !== undefined &&
vscode.workspace.workspaceFolders.length > 0;

let toOpenPath: string;
if (isAbsolute) {
toOpenPath = this.arguments.file;
} else if (isInWorkspace) {
const workspacePath = vscode.workspace.workspaceFolders![0].uri.path;
if (currentFilePath.startsWith(workspacePath)) {
toOpenPath = path.join(path.dirname(currentFilePath), this.arguments.file);
} else {
toOpenPath = path.join(workspacePath, this.arguments.file);
}
} else {
toOpenPath = path.join(path.dirname(currentFilePath), this.arguments.file);
}

let uri = vscode.Uri.file(toOpenPath);
try {
await vscode.workspace.fs.stat(uri);
} catch {
uri = uri.with({ scheme: 'untitled' });
}
await vscode.commands.executeCommand('vscode.open', uri);
break;
}

if (this.arguments.count !== undefined && this.arguments.count <= 0) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vimscript/exCommandParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export const builtinExCommands: ReadonlyArray<[[string, string], ArgParser | und
[['mkv', 'imrc'], undefined],
[['mkvie', 'w'], undefined],
[['mod', 'e'], undefined],
[['n', 'ext'], undefined],
[['n', 'ext'], TabCommand.argParsers.next],
[['new', ''], FileCommand.argParsers.new],
[['nm', 'ap'], undefined],
[['nmapc', 'lear'], undefined],
Expand Down
44 changes: 20 additions & 24 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.
import glob from 'glob';
import { glob } from 'glob';
import Mocha from 'mocha';
import * as path from 'path';

Expand All @@ -19,7 +19,7 @@ import { Configuration } from './testConfiguration';
Globals.isTesting = true;
Globals.mockConfiguration = new Configuration();

export function run(): Promise<void> {
export async function run(): Promise<void> {
const mochaGrep = new RegExp(process.env.MOCHA_GREP || '');

// Create the mocha test
Expand All @@ -32,28 +32,24 @@ export function run(): Promise<void> {

const testsRoot = path.resolve(__dirname, '.');

const files = await glob('**/**.test.js', { cwd: testsRoot });

// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}

// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (error) {
console.error(error);
e(error as Error);
}
});
try {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (error) {
console.error(error);
e(error as Error);
}
});
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"strict": true,
"useUnknownInCatchVariables": false,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"platform/*": ["src/platform/node/*"]
"platform/*": ["./src/platform/node/*"],
"src/*": ["./src/*"]
},
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
Expand Down