Skip to content

Commit

Permalink
fix gf to be like issue VSCodeVim#2683 (VSCodeVim#2701)
Browse files Browse the repository at this point in the history
* fix gf to be like issue VSCodeVim#2683

* converted to vscodevim style

* fix bug that came with variable double negation
  • Loading branch information
SuyogSoti authored and jpoon committed Jun 7, 2018
1 parent c46a3f0 commit e851a80
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2343,7 +2343,11 @@ class CommandOpenFile extends BaseCommand {
if (fileInfo) {
const filePath = fileInfo[1];
const lineNumber = parseInt(fileInfo[2], 10);
const fileCommand = new FileCommand({ name: filePath, lineNumber: lineNumber });
const fileCommand = new FileCommand({
name: filePath,
lineNumber: lineNumber,
createFileIfNotExists: false,
});
fileCommand.execute();
}

Expand Down
9 changes: 8 additions & 1 deletion src/cmd_line/commands/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from 'path';
import * as vscode from 'vscode';

import * as node from '../node';
import { showError } from './../../util';

const untildify = require('untildify');

Expand All @@ -16,6 +17,7 @@ export interface IFileCommandArguments extends node.ICommandArgs {
bang?: boolean;
position?: FilePosition;
lineNumber?: number;
createFileIfNotExists?: boolean;
}

export class FileCommand extends node.CommandBase {
Expand Down Expand Up @@ -102,7 +104,12 @@ export class FileCommand extends node.CommandBase {
filePath = pathWithExt;
} else {
// create file
fs.closeSync(fs.openSync(filePath, 'w'));
if (this.arguments.createFileIfNotExists) {
fs.closeSync(fs.openSync(filePath, 'w'));
} else {
showError('The file ' + filePath + ' does not exist.');
return;
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/cmd_line/subparsers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Scanner } from '../scanner';

export function parseEditFileCommandArgs(args: string): node.FileCommand {
if (!args) {
return new node.FileCommand({ name: '' });
return new node.FileCommand({ name: '', createFileIfNotExists: true });
}

let scanner = new Scanner(args);
let bang;
const c = scanner.next();
bang = c === '!';
if (scanner.isAtEof) {
return new node.FileCommand({ name: '', bang: bang });
return new node.FileCommand({ name: '', bang: bang, createFileIfNotExists: true });
}

let name = scanner.nextWord();
Expand All @@ -20,6 +20,7 @@ export function parseEditFileCommandArgs(args: string): node.FileCommand {
name: name.trim(),
position: node.FilePosition.CurrentWindow,
bang: bang,
createFileIfNotExists: true,
});
}

Expand Down

0 comments on commit e851a80

Please sign in to comment.