Skip to content
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

Shared tests #981

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move ColLineFunctionHandler.kt to vim-engine
  • Loading branch information
lippfi committed Aug 30, 2024
commit 9061fe54e70ea3b417228f98bc247f984c84de18
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"col": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.ColFunctionHandler",
"has": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.HasFunctionHandler",
"line": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.LineFunctionHandler"
"has": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.HasFunctionHandler"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2023 The IdeaVim authors
* Copyright 2003-2024 The IdeaVim authors
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE.txt file or at
Expand All @@ -15,9 +15,6 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.lineLength
import com.maddyhome.idea.vim.api.options
import com.maddyhome.idea.vim.api.visualLineToBufferLine
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.vimLine
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.state.mode.inVisualMode
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
Expand Down Expand Up @@ -102,12 +99,12 @@ private fun variableToPosition(editor: VimEditor, variable: VimDataType, dollarF
if (name.isEmpty()) return null

// Current caret line
if (name[0] == '.') return editor.ij.vimLine.asVimInt() to currentCol(editor)
if (name[0] == '.') return editor.currentCaret().vimLine.asVimInt() to currentCol(editor)

// Visual start
if (name == "v") {
if (!editor.inVisualMode) {
return editor.ij.vimLine.asVimInt() to currentCol(editor)
return editor.currentCaret().vimLine.asVimInt() to currentCol(editor)
}

val vimStart = editor.currentCaret().vimSelectionStart
Expand All @@ -130,15 +127,15 @@ private fun variableToPosition(editor: VimEditor, variable: VimDataType, dollarF
// First visual line
if (name.length >= 2 && name[0] == 'w' && name[1] == '0') {
if (!dollarForLine) return null
val actualVisualTop = EditorHelper.getVisualLineAtTopOfScreen(editor.ij)
val actualVisualTop = injector.engineEditorHelper.getVisualLineAtTopOfScreen(editor)
val actualLogicalTop = editor.visualLineToBufferLine(actualVisualTop)
return (actualLogicalTop + 1).asVimInt() to currentCol(editor)
}

// Last visual line
if (name.length >= 2 && name[0] == 'w' && name[1] == '$') {
if (!dollarForLine) return null
val actualVisualBottom = EditorHelper.getVisualLineAtBottomOfScreen(editor.ij)
val actualVisualBottom = injector.engineEditorHelper.getVisualLineAtBottomOfScreen(editor)
val actualLogicalBottom = editor.visualLineToBufferLine(actualVisualBottom)
return (actualLogicalBottom + 1).asVimInt() to currentCol(editor)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"abs": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.AbsFunctionHandler",
"col": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.ColFunctionHandler",
"empty": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.EmptyFunctionHandler",
"exists": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.ExistsFunctionHandler",
"funcref": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.FuncrefFunctionHandler",
"function": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.FunctionFunctionHandler",
"get": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.GetFunctionHandler",
"join": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.JoinFunctionHandler",
"len": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.LenFunctionHandler",
"line": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.LineFunctionHandler",
"sin": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.SinFunctionHandler",
"split": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.SplitFunctionHandler",
"submatch": "com.maddyhome.idea.vim.vimscript.model.functions.handlers.SubmatchFunctionHandler",
Expand Down