Skip to content

Commit

Permalink
vim-1062 -fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalPlacek authored and AlexPl292 committed Jul 1, 2021
1 parent ddb159e commit c15eccf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions resources/META-INF/includes/VimExCommands.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.MarkHandler" names="ma[rk],k"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.MarksHandler" names="marks"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.MoveTextHandler" names="m[ove]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.NextFileHandler" names="n[ext],bn"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.NextFileHandler" names="n[ext],bn[ext]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.NoHLSearchHandler" names="noh[lsearch]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.OnlyHandler" names="on[ly]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.PreviousFileHandler" names="N[ext],prev[ious],bp"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.PreviousFileHandler" names="N[ext],prev[ious],bp[revious]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.PromptFindHandler" names="pro[mptfind]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.PrintHandler" names="p[rint],P[rint]"/>
<vimExCommand implementation="com.maddyhome.idea.vim.ex.handler.PromptReplaceHandler" names="promptr[epl]"/>
Expand Down
6 changes: 3 additions & 3 deletions src/com/maddyhome/idea/vim/ex/handler/BufferCloseHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class BufferCloseHandler : CommandHandler.SingleExecution() {
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun execute(editor: Editor, context: DataContext, cmd: ExCommand): Boolean {
val arg = cmd.argument.trim()
if (arg.isNotEmpty() && arg.matches(Regex("^\\d+$"))) {
val bufNum = arg.toInt() - 1
VimPlugin.getFile().closeFile(bufNum, editor, context)
val bufNum = arg.toIntOrNull();
if (bufNum != null) {
VimPlugin.getFile().closeFile(bufNum - 1, context)
} else {
VimPlugin.getFile().closeFile(editor, context)
}
Expand Down
7 changes: 1 addition & 6 deletions src/com/maddyhome/idea/vim/group/FileGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,14 @@ public void closeFile(@NotNull Editor editor, @NotNull DataContext context) {
/**
* Closes editor.
*/
public void closeFile(int number, @NotNull Editor editor, @NotNull DataContext context) {
public void closeFile(int number, @NotNull DataContext context) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
final EditorWindow window = fileEditorManager.getCurrentWindow();
VirtualFile[] editors = fileEditorManager.getOpenFiles();
if (number == 99) {
number = editors.length - 1;
}
if (number >= 0 && number < editors.length) {
fileEditorManager.closeFile(editors[number], window);
}
if (number < 0 || number >= editors.length) {
}
}

/**
Expand Down

0 comments on commit c15eccf

Please sign in to comment.