-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added: :
to start Command Palette Support
#199
Conversation
:
to started Command Palette Support:
to start Command Palette Support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloud you lint the code with tslint?
I'm noticing a lot missing semicolons. They won't hurt much but let's follow the good practice.
src/Actions/Command.ts
Outdated
return commands.executeCommand('workbench.action.gotoLine'); | ||
static async command(): Promise<void> { | ||
// this is undefined | ||
return await CommandLine.PromptAndRun(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems redundant.
Shall we move src/CommandLine/
to src/Actions/CommandLine/
and use it directly like this?
{ keys: ':', actions: [ActionCommandLine.prompt] }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can
src/CommandLine/CommandLine.ts
Outdated
if (!vscode.window.activeTextEditor) { | ||
return | ||
} | ||
let text = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable is never used.
src/CommandLine/CommandLine.ts
Outdated
} | ||
return await CommandLine.Run(cmd); | ||
} catch (e) { | ||
console.log(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use console.error
to indicate that something went wrong?
src/Modes/Normal.ts
Outdated
@@ -210,7 +210,8 @@ export class ModeNormal extends Mode { | |||
{ keys: 'z M', actions: [ActionFold.foldAll] }, | |||
{ keys: 'z R', actions: [ActionFold.unfoldAll] }, | |||
|
|||
{ keys: ':', actions: [ActionCommand.goToLine] }, | |||
// { keys: ':', actions: [ActionCommand.goToLine] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just delete lines we don't need in the future.
src/CommandLine/Commands/Base.ts
Outdated
@@ -0,0 +1,4 @@ | |||
export abstract class CommandBase { | |||
protected name: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the use of name
anywhere in this Pull Request.
Is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not necessary 😂
src/CommandLine/Parser.ts
Outdated
qall: QuitAllCommand, | ||
|
||
wq: WriteQuitCommand, | ||
writequit: WriteQuitCommand, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writequit
is not a Vim command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my fault
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't mind. I like the idea though 😄.
src/CommandLine/Parser.ts
Outdated
vs: VisualSplitCommand, | ||
vsp: VisualSplitCommand, | ||
sp: VisualSplitCommand, | ||
split: VisualSplitCommand, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp
and split
are for the horizontal split. VSCode doesn't support this right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VSCode should support horizontal split now
src/CommandLine/Parser.ts
Outdated
sp: VisualSplitCommand, | ||
split: VisualSplitCommand, | ||
vsplit: VisualSplitCommand, | ||
ne: NewFileCommand, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ne
is for editing next file.
src/CommandLine/Parser.ts
Outdated
ne: NewFileCommand, | ||
vne: NewFileCommand, | ||
new: NewFileCommand, | ||
vnew: NewFileCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vne
and vnew
should create the new file in a vertically split pane.
src/CommandLine/Parser.ts
Outdated
export function parser(input: string): CommandBase | undefined { | ||
if (commandParsers[input]) { | ||
return commandParsers[input] | ||
} else if (isNumber(input)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use Number.isInteger
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type of input is string
, so if you just use Number.isInteger(input)
will get false. While I can add it in the isNumber
function to detect if the input is an interger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloud you lint the code with tslint?
I'm noticing a lot missing semicolons. They won't hurt much but let's follow the good practice.
Thanks for the reply! I'll fix them ASAP. |
All the new files have been tested by tslint 😁~ |
const lineNumber = Number(line); | ||
let editor = vscode.window.activeTextEditor; | ||
if (editor) { | ||
ActionMoveCursor.byMotions({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should await
this action.
import * as vscode from 'vscode'; | ||
import { CommandBase } from './Base'; | ||
|
||
class QuitCommand extends CommandBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be QuitAllCommand
?
async execute(): Promise<void> { | ||
await VisualSplit.execute(); | ||
await NewFile.execute(); | ||
await vscode.commands.executeCommand('workbench.action.closeOtherEditors'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may have unwanted effects when we execute the command in the third column.
We can use workbench.action.files.newUntitledFile
then workbench.action.moveEditorToNextGroup
.
import WriteAllCommand from './WriteAll'; | ||
import QuitAllCommand from './QuitAll'; | ||
|
||
class WriteQuitCommand extends CommandBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this should be WriteQuitAllCommand
.
src/Actions/CommandLine/Parser.ts
Outdated
export function parser(input: string): CommandBase | undefined { | ||
if (commandParsers[input]) { | ||
return commandParsers[input]; | ||
} else if (isNumber(input)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a simple expression, we cloud use Number.isInteger(Number(input))
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fixes!
I can fix above now, just wait for a moment~ |
Done 😀 |
Thank you for your contribution! |
Can't wait for it! Thank you for your nice job! |
@aioutecism I think you can change the |
Published 1.26.1. |
After reading the source code of the project and the VSCodeVim, I try to add
:
to startCommand Palette
Support.Now I have finished some of the vim commands in
Command Palette
:Here are some screenshots:
:
::wq
:vs
:new
I hope that my contribution can help you! If you think it can be merged, you can remove the line in your readme:
Thank you for your nice project!