1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-06-07 19:34:04 +02:00

Reformat code

This commit is contained in:
Alex Plate 2025-01-10 12:25:51 +03:00
parent 36556d559f
commit ad584d553c
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
424 changed files with 4985 additions and 1875 deletions
src
main
test/java/org/jetbrains/plugins/ideavim

View File

@ -215,7 +215,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
if (enabled) { if (enabled) {
VimInjectorKt.getInjector().getListenersNotifier().notifyPluginTurnedOn(); VimInjectorKt.getInjector().getListenersNotifier().notifyPluginTurnedOn();
} else { }
else {
VimInjectorKt.getInjector().getListenersNotifier().notifyPluginTurnedOff(); VimInjectorKt.getInjector().getListenersNotifier().notifyPluginTurnedOff();
} }

View File

@ -44,7 +44,12 @@ class VimTypedActionHandler(origHandler: TypedActionHandler) : TypedActionHandle
LOG.trace("Before execute for typed action") LOG.trace("Before execute for typed action")
if (editor.isIdeaVimDisabledHere) { if (editor.isIdeaVimDisabledHere) {
LOG.trace("IdeaVim disabled here, finish") LOG.trace("IdeaVim disabled here, finish")
(KeyHandlerKeeper.getInstance().originalHandler as? TypedActionHandlerEx)?.beforeExecute(editor, charTyped, context, plan) (KeyHandlerKeeper.getInstance().originalHandler as? TypedActionHandlerEx)?.beforeExecute(
editor,
charTyped,
context,
plan
)
return return
} }

View File

@ -205,6 +205,7 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
ShortcutOwner.VIM -> { ShortcutOwner.VIM -> {
return ActionEnableStatus.yes("Owner is vim", LogLevel.DEBUG) return ActionEnableStatus.yes("Owner is vim", LogLevel.DEBUG)
} }
ShortcutOwner.IDE -> { ShortcutOwner.IDE -> {
if (!isShortcutConflict(keyStroke)) { if (!isShortcutConflict(keyStroke)) {
ActionEnableStatus.yes("Owner is IDE, but no actionve shortcut conflict", LogLevel.DEBUG) ActionEnableStatus.yes("Owner is IDE, but no actionve shortcut conflict", LogLevel.DEBUG)
@ -212,6 +213,7 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
ActionEnableStatus.no("Owner is IDE", LogLevel.DEBUG) ActionEnableStatus.no("Owner is IDE", LogLevel.DEBUG)
} }
} }
else -> { else -> {
if (isShortcutConflict(keyStroke)) { if (isShortcutConflict(keyStroke)) {
savedShortcutConflicts[keyStroke] = ShortcutOwnerInfo.allUndefined savedShortcutConflicts[keyStroke] = ShortcutOwnerInfo.allUndefined
@ -224,7 +226,8 @@ class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
} }
private fun isEnabledForEscape(editor: Editor): Boolean { private fun isEnabledForEscape(editor: Editor): Boolean {
val ideaVimSupportDialog = injector.globalIjOptions().ideavimsupport.contains(IjOptionConstants.ideavimsupport_dialog) val ideaVimSupportDialog =
injector.globalIjOptions().ideavimsupport.contains(IjOptionConstants.ideavimsupport_dialog)
return editor.isPrimaryEditor() || return editor.isPrimaryEditor() ||
EditorHelper.isFileEditor(editor) && !editor.vim.mode.inNormalMode || EditorHelper.isFileEditor(editor) && !editor.vim.mode.inNormalMode ||
ideaVimSupportDialog && !editor.vim.mode.inNormalMode ideaVimSupportDialog && !editor.vim.mode.inNormalMode

View File

@ -37,7 +37,12 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.FunctionCallExpression
import com.maddyhome.idea.vim.vimscript.model.expressions.SimpleExpression import com.maddyhome.idea.vim.vimscript.model.expressions.SimpleExpression
// todo make it multicaret // todo make it multicaret
private fun doOperatorAction(editor: VimEditor, context: ExecutionContext, textRange: TextRange, motionType: SelectionType): Boolean { private fun doOperatorAction(
editor: VimEditor,
context: ExecutionContext,
textRange: TextRange,
motionType: SelectionType,
): Boolean {
val func = injector.globalOptions().operatorfunc val func = injector.globalOptions().operatorfunc
if (func.isEmpty()) { if (func.isEmpty()) {
VimPlugin.showMessage(MessageHelper.message("E774")) VimPlugin.showMessage(MessageHelper.message("E774"))
@ -61,8 +66,7 @@ private fun doOperatorAction(editor: VimEditor, context: ExecutionContext, textR
// Get the argument for function('...') or funcref('...') for the error message // Get the argument for function('...') or funcref('...') for the error message
val functionName = if (expression is FunctionCallExpression && expression.arguments.isNotEmpty()) { val functionName = if (expression is FunctionCallExpression && expression.arguments.isNotEmpty()) {
expression.arguments[0].evaluate(editor, context, scriptContext).toString() expression.arguments[0].evaluate(editor, context, scriptContext).toString()
} } else {
else {
func func
} }
@ -100,7 +104,12 @@ internal class OperatorAction : VimActionHandler.SingleExecution() {
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { override fun execute(
editor: VimEditor,
context: ExecutionContext,
cmd: Command,
operatorArguments: OperatorArguments,
): Boolean {
val argument = cmd.argument as? Argument.Motion ?: return false val argument = cmd.argument as? Argument.Motion ?: return false
if (!editor.inRepeatMode) { if (!editor.inRepeatMode) {
argumentCaptured = argument argumentCaptured = argument

View File

@ -23,7 +23,12 @@ import com.maddyhome.idea.vim.newapi.ij
internal class RepeatChangeAction : VimActionHandler.SingleExecution() { internal class RepeatChangeAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_WRITABLE override val type: Command.Type = Command.Type.OTHER_WRITABLE
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { override fun execute(
editor: VimEditor,
context: ExecutionContext,
cmd: Command,
operatorArguments: OperatorArguments,
): Boolean {
val state = injector.vimState val state = injector.vimState
var lastCommand = VimRepeater.lastChangeCommand var lastCommand = VimRepeater.lastChangeCommand

View File

@ -38,7 +38,7 @@ internal class VimEditorDown : IdeActionHandler(IdeActions.ACTION_EDITOR_MOVE_CA
editor: VimEditor, editor: VimEditor,
context: ExecutionContext, context: ExecutionContext,
cmd: Command, cmd: Command,
operatorArguments: OperatorArguments operatorArguments: OperatorArguments,
): Boolean { ): Boolean {
val undo = injector.undo val undo = injector.undo
when (undo) { when (undo) {
@ -67,7 +67,7 @@ internal class VimEditorUp : IdeActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARE
editor: VimEditor, editor: VimEditor,
context: ExecutionContext, context: ExecutionContext,
cmd: Command, cmd: Command,
operatorArguments: OperatorArguments operatorArguments: OperatorArguments,
): Boolean { ): Boolean {
val undo = injector.undo val undo = injector.undo
when (undo) { when (undo) {
@ -85,7 +85,12 @@ internal class VimEditorUp : IdeActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARE
internal class VimQuickJavaDoc : VimActionHandler.SingleExecution() { internal class VimQuickJavaDoc : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_READONLY override val type: Command.Type = Command.Type.OTHER_READONLY
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { override fun execute(
editor: VimEditor,
context: ExecutionContext,
cmd: Command,
operatorArguments: OperatorArguments,
): Boolean {
injector.actionExecutor.executeAction(editor, IdeActions.ACTION_QUICK_JAVADOC, context) injector.actionExecutor.executeAction(editor, IdeActions.ACTION_QUICK_JAVADOC, context)
return true return true
} }

View File

@ -36,7 +36,8 @@ class CommandState(private val machine: VimStateMachine) {
} }
} }
@get:Deprecated("Use `KeyHandler.keyHandlerState.commandBuilder", ReplaceWith( @get:Deprecated(
"Use `KeyHandler.keyHandlerState.commandBuilder", ReplaceWith(
"KeyHandler.getInstance().keyHandlerState.commandBuilder", "KeyHandler.getInstance().keyHandlerState.commandBuilder",
"com.maddyhome.idea.vim.KeyHandler" "com.maddyhome.idea.vim.KeyHandler"
) )
@ -45,7 +46,8 @@ class CommandState(private val machine: VimStateMachine) {
val commandBuilder: CommandBuilder val commandBuilder: CommandBuilder
get() = KeyHandler.getInstance().keyHandlerState.commandBuilder get() = KeyHandler.getInstance().keyHandlerState.commandBuilder
@Deprecated("Use `KeyHandler.keyHandlerState.mappingState", ReplaceWith( @Deprecated(
"Use `KeyHandler.keyHandlerState.mappingState", ReplaceWith(
"KeyHandler.getInstance().keyHandlerState.mappingState", "KeyHandler.getInstance().keyHandlerState.mappingState",
"com.maddyhome.idea.vim.KeyHandler" "com.maddyhome.idea.vim.KeyHandler"
) )

View File

@ -127,8 +127,7 @@ class ExOutputModel(private val myEditor: WeakReference<Editor>) : VimOutputPane
override fun close() { override fun close() {
if (!ApplicationManager.getApplication().isUnitTestMode) { if (!ApplicationManager.getApplication().isUnitTestMode) {
editor?.let { ExOutputPanel.getInstance(it).close() } editor?.let { ExOutputPanel.getInstance(it).close() }
} } else {
else {
isActiveInTestMode = false isActiveInTestMode = false
} }
} }

View File

@ -69,7 +69,8 @@ object VimExtensionFacade {
@JvmStatic @JvmStatic
@Deprecated("Use VimPlugin.getKey().putKeyMapping(modes, fromKeys, pluginOwner, extensionHandler, recursive)", @Deprecated(
"Use VimPlugin.getKey().putKeyMapping(modes, fromKeys, pluginOwner, extensionHandler, recursive)",
ReplaceWith( ReplaceWith(
"VimPlugin.getKey().putKeyMapping(modes, fromKeys, pluginOwner, extensionHandler, recursive)", "VimPlugin.getKey().putKeyMapping(modes, fromKeys, pluginOwner, extensionHandler, recursive)",
"com.maddyhome.idea.vim.VimPlugin" "com.maddyhome.idea.vim.VimPlugin"
@ -189,12 +190,18 @@ object VimExtensionFacade {
/** Get the current contents of the given register similar to 'getreg()'. */ /** Get the current contents of the given register similar to 'getreg()'. */
@JvmStatic @JvmStatic
fun getRegister(editor: VimEditor, register: Char): List<KeyStroke>? { fun getRegister(editor: VimEditor, register: Char): List<KeyStroke>? {
val reg = VimPlugin.getRegister().getRegister(editor, injector.executionContextManager.getEditorExecutionContext(editor), register) ?: return null val reg = VimPlugin.getRegister()
.getRegister(editor, injector.executionContextManager.getEditorExecutionContext(editor), register) ?: return null
return reg.keys return reg.keys
} }
@JvmStatic @JvmStatic
fun getRegisterForCaret(editor: VimEditor, context: ExecutionContext, register: Char, caret: VimCaret): List<KeyStroke>? { fun getRegisterForCaret(
editor: VimEditor,
context: ExecutionContext,
register: Char,
caret: VimCaret,
): List<KeyStroke>? {
val reg = caret.registerStorage.getRegister(editor, context, register) ?: return null val reg = caret.registerStorage.getRegister(editor, context, register) ?: return null
return reg.keys return reg.keys
} }
@ -225,7 +232,7 @@ object VimExtensionFacade {
defaultArgs: List<Pair<String, Expression>>, defaultArgs: List<Pair<String, Expression>>,
hasOptionalArguments: Boolean, hasOptionalArguments: Boolean,
flags: EnumSet<FunctionFlag>, flags: EnumSet<FunctionFlag>,
function: ScriptFunction function: ScriptFunction,
) { ) {
var functionDeclaration: FunctionDeclaration? = null var functionDeclaration: FunctionDeclaration? = null
val body = listOf(object : Executable { val body = listOf(object : Executable {
@ -255,8 +262,7 @@ object VimExtensionFacade {
} }
fun VimExtensionFacade.exportOperatorFunction(name: String, function: OperatorFunction) { fun VimExtensionFacade.exportOperatorFunction(name: String, function: OperatorFunction) {
exportScriptFunction(null, name, listOf("type"), emptyList(), false, noneOfEnum()) { exportScriptFunction(null, name, listOf("type"), emptyList(), false, noneOfEnum()) { editor, context, args ->
editor, context, args ->
val type = args["type"]?.asString() val type = args["type"]?.asString()
val selectionType = when (type) { val selectionType = when (type) {
@ -268,8 +274,7 @@ fun VimExtensionFacade.exportOperatorFunction(name: String, function: OperatorFu
if (function.apply(editor, context, selectionType)) { if (function.apply(editor, context, selectionType)) {
ExecutionResult.Success ExecutionResult.Success
} } else {
else {
ExecutionResult.Error ExecutionResult.Error
} }
} }

View File

@ -186,12 +186,24 @@ class ChangeGroup : VimChangeGroupBase() {
} }
} }
@Deprecated(message = "Please use listenersNotifier", replaceWith = ReplaceWith("injector.listenersNotifier.modeChangeListeners.add", imports = ["import com.maddyhome.idea.vim.api.injector"])) @Deprecated(
message = "Please use listenersNotifier",
replaceWith = ReplaceWith(
"injector.listenersNotifier.modeChangeListeners.add",
imports = ["import com.maddyhome.idea.vim.api.injector"]
)
)
fun addInsertListener(listener: VimInsertListener) { fun addInsertListener(listener: VimInsertListener) {
injector.listenersNotifier.modeChangeListeners.add(listener) injector.listenersNotifier.modeChangeListeners.add(listener)
} }
@Deprecated(message = "Please use listenersNotifier", replaceWith = ReplaceWith("injector.listenersNotifier.modeChangeListeners.remove", imports = ["import com.maddyhome.idea.vim.api.injector"])) @Deprecated(
message = "Please use listenersNotifier",
replaceWith = ReplaceWith(
"injector.listenersNotifier.modeChangeListeners.remove",
imports = ["import com.maddyhome.idea.vim.api.injector"]
)
)
fun removeInsertListener(listener: VimInsertListener) { fun removeInsertListener(listener: VimInsertListener) {
injector.listenersNotifier.modeChangeListeners.remove(listener) injector.listenersNotifier.modeChangeListeners.remove(listener)
} }

View File

@ -156,7 +156,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
private static void repaintRelativeLineNumbers(final @NotNull Editor editor) { private static void repaintRelativeLineNumbers(final @NotNull Editor editor) {
final EditorGutter gutter = editor.getGutter(); final EditorGutter gutter = editor.getGutter();
final EditorGutterComponentEx gutterComponent = gutter instanceof EditorGutterComponentEx ? (EditorGutterComponentEx) gutter : null; final EditorGutterComponentEx gutterComponent =
gutter instanceof EditorGutterComponentEx ? (EditorGutterComponentEx)gutter : null;
if (gutterComponent != null) { if (gutterComponent != null) {
gutterComponent.repaint(); gutterComponent.repaint();
} }
@ -309,26 +310,21 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
@Override @Override
public @NotNull Collection<VimEditor> getEditorsRaw() { public @NotNull Collection<VimEditor> getEditorsRaw() {
return getLocalEditors() return getLocalEditors().map(IjVimEditor::new).collect(Collectors.toList());
.map(IjVimEditor::new)
.collect(Collectors.toList());
} }
@Override @Override
public @NotNull Collection<VimEditor> getEditors() { public @NotNull Collection<VimEditor> getEditors() {
return getLocalEditors() return getLocalEditors().filter(UserDataManager::getVimInitialised).map(IjVimEditor::new)
.filter(UserDataManager::getVimInitialised)
.map(IjVimEditor::new)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override @Override
public @NotNull Collection<VimEditor> getEditors(@NotNull VimDocument buffer) { public @NotNull Collection<VimEditor> getEditors(@NotNull VimDocument buffer) {
final Document document = ((IjVimDocument)buffer).getDocument(); final Document document = ((IjVimDocument)buffer).getDocument();
return getLocalEditors() return getLocalEditors().filter(
.filter(editor -> UserDataManager.getVimInitialised(editor) && editor.getDocument().equals(document)) editor -> UserDataManager.getVimInitialised(editor) && editor.getDocument().equals(document))
.map(IjVimEditor::new) .map(IjVimEditor::new).collect(Collectors.toList());
.collect(Collectors.toList());
} }
private Stream<Editor> getLocalEditors() { private Stream<Editor> getLocalEditors() {

View File

@ -28,8 +28,7 @@ import java.util.List;
import static com.maddyhome.idea.vim.history.HistoryConstants.*; import static com.maddyhome.idea.vim.history.HistoryConstants.*;
@State(name = "VimHistorySettings", storages = { @State(name = "VimHistorySettings", storages = {
@Storage(value = "$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED) @Storage(value = "$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)})
})
public class HistoryGroup extends VimHistoryBase implements PersistentStateComponent<Element> { public class HistoryGroup extends VimHistoryBase implements PersistentStateComponent<Element> {
public void saveData(@NotNull Element element) { public void saveData(@NotNull Element element) {

View File

@ -122,6 +122,7 @@ object IjOptions {
IjOptionConstants.ideavimsupportValues IjOptionConstants.ideavimsupportValues
) )
) )
@JvmField @JvmField
val ideawrite: StringOption = addOption( val ideawrite: StringOption = addOption(
StringOption("ideawrite", GLOBAL, "ideawrite", "all", IjOptionConstants.ideaWriteValues) StringOption("ideawrite", GLOBAL, "ideawrite", "all", IjOptionConstants.ideaWriteValues)
@ -131,17 +132,21 @@ object IjOptions {
"lookupkeys", "lookupkeys",
GLOBAL, GLOBAL,
"lookupkeys", "lookupkeys",
"<Tab>,<Down>,<Up>,<Enter>,<Left>,<Right>,<C-Down>,<C-Up>,<PageUp>,<PageDown>,<C-J>,<C-Q>") "<Tab>,<Down>,<Up>,<Enter>,<Left>,<Right>,<C-Down>,<C-Up>,<PageUp>,<PageDown>,<C-J>,<C-Q>"
)
) )
val trackactionids: ToggleOption = addOption(ToggleOption("trackactionids", GLOBAL, "tai", false)) val trackactionids: ToggleOption = addOption(ToggleOption("trackactionids", GLOBAL, "tai", false))
val visualdelay: UnsignedNumberOption = addOption(UnsignedNumberOption("visualdelay", GLOBAL, "visualdelay", 100)) val visualdelay: UnsignedNumberOption = addOption(UnsignedNumberOption("visualdelay", GLOBAL, "visualdelay", 100))
// Temporary feature flags during development, not really intended for external use // Temporary feature flags during development, not really intended for external use
val closenotebooks: ToggleOption = addOption(ToggleOption("closenotebooks", GLOBAL, "closenotebooks", true, isHidden = true)) val closenotebooks: ToggleOption =
val commandOrMotionAnnotation: ToggleOption = addOption(ToggleOption("commandormotionannotation", GLOBAL, "commandormotionannotation", true, isHidden = true)) addOption(ToggleOption("closenotebooks", GLOBAL, "closenotebooks", true, isHidden = true))
val commandOrMotionAnnotation: ToggleOption =
addOption(ToggleOption("commandormotionannotation", GLOBAL, "commandormotionannotation", true, isHidden = true))
val oldundo: ToggleOption = addOption(ToggleOption("oldundo", GLOBAL, "oldundo", false, isHidden = true)) val oldundo: ToggleOption = addOption(ToggleOption("oldundo", GLOBAL, "oldundo", false, isHidden = true))
val unifyjumps: ToggleOption = addOption(ToggleOption("unifyjumps", GLOBAL, "unifyjumps", true, isHidden = true)) val unifyjumps: ToggleOption = addOption(ToggleOption("unifyjumps", GLOBAL, "unifyjumps", true, isHidden = true))
val vimscriptFunctionAnnotation: ToggleOption = addOption(ToggleOption("vimscriptfunctionannotation", GLOBAL, "vimscriptfunctionannotation", true, isHidden = true)) val vimscriptFunctionAnnotation: ToggleOption =
addOption(ToggleOption("vimscriptfunctionannotation", GLOBAL, "vimscriptfunctionannotation", true, isHidden = true))
// This needs to be Option<out VimDataType> so that it can work with derived option types, such as NumberOption, which // This needs to be Option<out VimDataType> so that it can work with derived option types, such as NumberOption, which
// derives from Option<VimInt> // derives from Option<VimInt>

View File

@ -303,8 +303,8 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
@Override @Override
public @NotNull List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) { public @NotNull List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) {
return getActions(((IjVimEditor)editor).getEditor().getComponent(), keyStroke).stream() return getActions(((IjVimEditor)editor).getEditor().getComponent(), keyStroke).stream().map(IjNativeAction::new)
.map(IjNativeAction::new).collect(toList()); .collect(toList());
} }
private static @NotNull List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) { private static @NotNull List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
@ -355,21 +355,26 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
} }
@Override @Override
public boolean showKeyMappings(@NotNull Set<? extends MappingMode> modes, @NotNull List<? extends KeyStroke> prefix, @NotNull VimEditor editor) { public boolean showKeyMappings(@NotNull Set<? extends MappingMode> modes,
@NotNull List<? extends KeyStroke> prefix,
@NotNull VimEditor editor) {
List<Pair<Set<MappingMode>, MappingInfo>> rows = getKeyMappingRows(modes, prefix); List<Pair<Set<MappingMode>, MappingInfo>> rows = getKeyMappingRows(modes, prefix);
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
for (Pair<Set<MappingMode>, MappingInfo> row : rows) { for (Pair<Set<MappingMode>, MappingInfo> row : rows) {
MappingInfo mappingInfo = row.getSecond(); MappingInfo mappingInfo = row.getSecond();
builder.append(StringsKt.padEnd(getModesStringCode(row.getFirst()), 3, ' ')); builder.append(StringsKt.padEnd(getModesStringCode(row.getFirst()), 3, ' '));
builder.append(StringsKt.padEnd(VimInjectorKt.getInjector().getParser().toKeyNotation(mappingInfo.getFromKeys()) + " ", 12, ' ')); builder.append(
StringsKt.padEnd(VimInjectorKt.getInjector().getParser().toKeyNotation(mappingInfo.getFromKeys()) + " ", 12,
' '));
builder.append(mappingInfo.isRecursive() ? " " : "*"); // Or `&` if script-local mappings being recursive builder.append(mappingInfo.isRecursive() ? " " : "*"); // Or `&` if script-local mappings being recursive
builder.append(" "); // Should be `@` if it's a buffer-local mapping builder.append(" "); // Should be `@` if it's a buffer-local mapping
builder.append(mappingInfo.getPresentableString()); builder.append(mappingInfo.getPresentableString());
builder.append("\n"); builder.append("\n");
} }
VimOutputPanel outputPanel = injector.getOutputPanel().getOrCreate(editor, injector.getExecutionContextManager().getEditorExecutionContext(editor)); VimOutputPanel outputPanel = injector.getOutputPanel()
.getOrCreate(editor, injector.getExecutionContextManager().getEditorExecutionContext(editor));
outputPanel.addText(builder.toString(), true); outputPanel.addText(builder.toString(), true);
outputPanel.show(); outputPanel.show();
return true; return true;

View File

@ -318,11 +318,13 @@ internal class MotionGroup : VimMotionGroupBase() {
vimEditor.exitVisualMode() vimEditor.exitVisualMode()
KeyHandler.getInstance().reset(vimEditor) KeyHandler.getInstance().reset(vimEditor)
} }
is Mode.CMD_LINE -> { is Mode.CMD_LINE -> {
val commandLine = injector.commandLine.getActiveCommandLine() ?: return val commandLine = injector.commandLine.getActiveCommandLine() ?: return
commandLine.close(refocusOwningEditor = false, resetCaret = false) commandLine.close(refocusOwningEditor = false, resetCaret = false)
injector.outputPanel.getCurrentOutputPanel()?.close() injector.outputPanel.getCurrentOutputPanel()?.close()
} }
else -> {} else -> {}
} }
} }

View File

@ -215,6 +215,7 @@ internal class NotificationService(private val project: Project?) {
is KeyMapIssue.AddShortcut -> { is KeyMapIssue.AddShortcut -> {
appendLine("- ${it.key} key is not assigned to the ${it.action} action.<br/>") appendLine("- ${it.key} key is not assigned to the ${it.action} action.<br/>")
} }
is KeyMapIssue.RemoveShortcut -> { is KeyMapIssue.RemoveShortcut -> {
appendLine("- ${it.shortcut} key is incorrectly assigned to the ${it.action} action.<br/>") appendLine("- ${it.shortcut} key is incorrectly assigned to the ${it.action} action.<br/>")
} }
@ -296,7 +297,8 @@ internal class NotificationService(private val project: Project?) {
} }
} + "<small>See the ${ActionCenter.getToolwindowName()} tool window for previous IDs</small>" } + "<small>See the ${ActionCenter.getToolwindowName()} tool window for previous IDs</small>"
notification = Notification(IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE, content, NotificationType.INFORMATION).also { notification =
Notification(IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE, content, NotificationType.INFORMATION).also {
it.whenExpired { notification = null } it.whenExpired { notification = null }
it.addAction(StopTracking()) it.addAction(StopTracking())
@ -312,7 +314,8 @@ internal class NotificationService(private val project: Project?) {
} }
} }
class CopyActionId(val id: String?, val project: Project?) : DumbAwareAction(MessageHelper.message("action.copy.action.id.text")) { class CopyActionId(val id: String?, val project: Project?) :
DumbAwareAction(MessageHelper.message("action.copy.action.id.text")) {
override fun actionPerformed(e: AnActionEvent) { override fun actionPerformed(e: AnActionEvent) {
CopyPasteManager.getInstance().setContents(StringSelection(id ?: "")) CopyPasteManager.getInstance().setContents(StringSelection(id ?: ""))
if (id != null) { if (id != null) {

View File

@ -151,7 +151,7 @@ internal class OptionGroup : VimOptionGroupBase(), IjVimOptionGroup, InternalOpt
override fun <T : VimDataType> setOptionValueInternal( override fun <T : VimDataType> setOptionValueInternal(
option: Option<T>, option: Option<T>,
scope: OptionAccessScope, scope: OptionAccessScope,
value: OptionValue<T> value: OptionValue<T>,
) { ) {
super.setOptionValueInternal(option, scope, value) super.setOptionValueInternal(option, scope, value)
} }
@ -391,7 +391,6 @@ private abstract class GlobalLocalOptionToGlobalLocalIdeaSettingMapper<T : VimDa
} }
/** /**
* Maps the `'bomb'` local-to-buffer Vim option to the file's current byte order mark * Maps the `'bomb'` local-to-buffer Vim option to the file's current byte order mark
* *
@ -425,7 +424,8 @@ private class BombOptionMapper : LocalOptionValueOverride<VimInt> {
// Use IntelliJ's own actions to modify the BOM. This will change the BOM stored in the virtual file, update the // Use IntelliJ's own actions to modify the BOM. This will change the BOM stored in the virtual file, update the
// file contents and save it // file contents and save it
val actionId = if (hasBom) "RemoveBom" else "AddBom" val actionId = if (hasBom) "RemoveBom" else "AddBom"
val action = injector.actionExecutor.getAction(actionId) ?: throw ExException("Cannot find native action: $actionId") val action =
injector.actionExecutor.getAction(actionId) ?: throw ExException("Cannot find native action: $actionId")
val context = injector.executionContextManager.getEditorExecutionContext(editor) val context = injector.executionContextManager.getEditorExecutionContext(editor)
injector.actionExecutor.executeAction(editor, action, context) injector.actionExecutor.executeAction(editor, action, context)
return true return true
@ -463,8 +463,8 @@ private class BreakIndentOptionMapper(
* *
* TODO: This is a code style setting - how can we react to changes? * TODO: This is a code style setting - how can we react to changes?
*/ */
private class ColorColumnOptionValueProvider(private val colorColumnOption: StringListOption) private class ColorColumnOptionValueProvider(private val colorColumnOption: StringListOption) :
: LocalOptionToGlobalLocalExternalSettingMapper<VimString>(colorColumnOption) { LocalOptionToGlobalLocalExternalSettingMapper<VimString>(colorColumnOption) {
// The IntelliJ setting is in practice global, from the user's perspective // The IntelliJ setting is in practice global, from the user's perspective
override val canUserModifyExternalLocalValue: Boolean = false override val canUserModifyExternalLocalValue: Boolean = false
@ -510,8 +510,7 @@ private class ColorColumnOptionValueProvider(private val colorColumnOption: Stri
// Given an empty string, hide the margin. // Given an empty string, hide the margin.
if (value == VimString.EMPTY) { if (value == VimString.EMPTY) {
editor.ij.settings.isRightMarginShown = false editor.ij.settings.isRightMarginShown = false
} } else {
else {
editor.ij.settings.isRightMarginShown = true editor.ij.settings.isRightMarginShown = true
val softMargins = mutableListOf<Int>() val softMargins = mutableListOf<Int>()
@ -524,8 +523,7 @@ private class ColorColumnOptionValueProvider(private val colorColumnOption: Stri
// We could perhaps add a property change listener from editor settings state? // We could perhaps add a property change listener from editor settings state?
// (editor.ij as EditorImpl).state.addPropertyChangeListener(...) // (editor.ij as EditorImpl).state.addPropertyChangeListener(...)
// (editor.ij.settings as SettingsImpl).getState().addPropertyChangeListener(...) // (editor.ij.settings as SettingsImpl).getState().addPropertyChangeListener(...)
} } else {
else {
it.toIntOrNull()?.let(softMargins::add) it.toIntOrNull()?.let(softMargins::add)
} }
} }
@ -559,8 +557,8 @@ private class ColorColumnOptionValueProvider(private val colorColumnOption: Stri
* *
* Note that there isn't a global IntelliJ setting for this option. * Note that there isn't a global IntelliJ setting for this option.
*/ */
private class CursorLineOptionMapper(cursorLineOption: ToggleOption) private class CursorLineOptionMapper(cursorLineOption: ToggleOption) :
: LocalOptionToGlobalLocalExternalSettingMapper<VimInt>(cursorLineOption) { LocalOptionToGlobalLocalExternalSettingMapper<VimInt>(cursorLineOption) {
// The IntelliJ setting is in practice global, from the user's perspective // The IntelliJ setting is in practice global, from the user's perspective
override val canUserModifyExternalLocalValue: Boolean = false override val canUserModifyExternalLocalValue: Boolean = false
@ -667,7 +665,12 @@ private class FileEncodingOptionMapper : LocalOptionValueOverride<VimString> {
} }
} }
private fun isSafeToReloadIn(virtualFile: VirtualFile, text: CharSequence, bytes: ByteArray, charset: Charset): Magic8 { private fun isSafeToReloadIn(
virtualFile: VirtualFile,
text: CharSequence,
bytes: ByteArray,
charset: Charset,
): Magic8 {
val bom = virtualFile.bom val bom = virtualFile.bom
if (bom != null && !CharsetToolkit.canHaveBom(charset, bom)) return Magic8.NO_WAY if (bom != null && !CharsetToolkit.canHaveBom(charset, bom)) return Magic8.NO_WAY
@ -680,11 +683,9 @@ private class FileEncodingOptionMapper : LocalOptionValueOverride<VimString> {
var bytesToSave = try { var bytesToSave = try {
StringUtil.convertLineSeparators(loaded, separator).toByteArray(charset) StringUtil.convertLineSeparators(loaded, separator).toByteArray(charset)
} } catch (e: UnsupportedOperationException) {
catch (e: UnsupportedOperationException) {
return Magic8.NO_WAY return Magic8.NO_WAY
} } catch (e: NullPointerException) {
catch (e: NullPointerException) {
return Magic8.NO_WAY return Magic8.NO_WAY
} }
if (bom != null && !ArrayUtil.startsWith(bytesToSave, bom)) { if (bom != null && !ArrayUtil.startsWith(bytesToSave, bom)) {
@ -718,12 +719,14 @@ private class FileFormatOptionMapper : LocalOptionValueOverride<VimString> {
// We should have a virtual file for most scenarios, e.g., scratch files, commit message dialog, etc. // We should have a virtual file for most scenarios, e.g., scratch files, commit message dialog, etc.
// The fallback window (TextComponentEditorImpl) does not have a virtual file // The fallback window (TextComponentEditorImpl) does not have a virtual file
val separator = editor.ij.virtualFile?.let { LoadTextUtil.detectLineSeparator(it, false) } val separator = editor.ij.virtualFile?.let { LoadTextUtil.detectLineSeparator(it, false) }
val value = VimString(when (separator) { val value = VimString(
when (separator) {
LineSeparator.LF.separatorString -> "unix" LineSeparator.LF.separatorString -> "unix"
LineSeparator.CR.separatorString -> "mac" LineSeparator.CR.separatorString -> "mac"
LineSeparator.CRLF.separatorString -> "dos" LineSeparator.CRLF.separatorString -> "dos"
else -> if (injector.systemInfoService.isWindows) "dos" else "unix" else -> if (injector.systemInfoService.isWindows) "dos" else "unix"
}) }
)
// There is no difference between user/external/default - the file is always just one format // There is no difference between user/external/default - the file is always just one format
return OptionValue.User(value) return OptionValue.User(value)
@ -762,8 +765,8 @@ private class FileFormatOptionMapper : LocalOptionValueOverride<VimString> {
/** /**
* Maps the `'list'` local-to-window Vim option to the IntelliJ global-local whitespace setting * Maps the `'list'` local-to-window Vim option to the IntelliJ global-local whitespace setting
*/ */
private class ListOptionMapper(listOption: ToggleOption, internalOptionValueAccessor: InternalOptionValueAccessor) private class ListOptionMapper(listOption: ToggleOption, internalOptionValueAccessor: InternalOptionValueAccessor) :
: LocalOptionToGlobalLocalIdeaSettingMapper<VimInt>(listOption, internalOptionValueAccessor) { LocalOptionToGlobalLocalIdeaSettingMapper<VimInt>(listOption, internalOptionValueAccessor) {
override val ideaPropertyName: String = EditorSettingsExternalizable.PropNames.PROP_IS_WHITESPACES_SHOWN override val ideaPropertyName: String = EditorSettingsExternalizable.PropNames.PROP_IS_WHITESPACES_SHOWN
@ -787,8 +790,8 @@ private class ListOptionMapper(listOption: ToggleOption, internalOptionValueAcce
* *
* Note that this must work with `'relativenumber'` to correctly handle the hybrid modes. * Note that this must work with `'relativenumber'` to correctly handle the hybrid modes.
*/ */
private class NumberOptionMapper(numberOption: ToggleOption, internalOptionValueAccessor: InternalOptionValueAccessor) private class NumberOptionMapper(numberOption: ToggleOption, internalOptionValueAccessor: InternalOptionValueAccessor) :
: LocalOptionToGlobalLocalIdeaSettingMapper<VimInt>(numberOption, internalOptionValueAccessor) { LocalOptionToGlobalLocalIdeaSettingMapper<VimInt>(numberOption, internalOptionValueAccessor) {
// This is a global-local setting, and can be modified by the user via _View | Active Editor | Show Line Numbers_ // This is a global-local setting, and can be modified by the user via _View | Active Editor | Show Line Numbers_
override val canUserModifyExternalLocalValue: Boolean = true override val canUserModifyExternalLocalValue: Boolean = true
@ -808,13 +811,11 @@ private class NumberOptionMapper(numberOption: ToggleOption, internalOptionValue
if (isShowingRelativeLineNumbers(editor.ij.settings.lineNumerationType)) { if (isShowingRelativeLineNumbers(editor.ij.settings.lineNumerationType)) {
editor.ij.settings.lineNumerationType = LineNumerationType.HYBRID editor.ij.settings.lineNumerationType = LineNumerationType.HYBRID
} }
} } else {
else {
editor.ij.settings.isLineNumbersShown = true editor.ij.settings.isLineNumbersShown = true
editor.ij.settings.lineNumerationType = LineNumerationType.ABSOLUTE editor.ij.settings.lineNumerationType = LineNumerationType.ABSOLUTE
} }
} } else {
else {
// Turn off 'number'. Hide lines if 'relativenumber' is not set, else switch to relative // Turn off 'number'. Hide lines if 'relativenumber' is not set, else switch to relative
if (editor.ij.settings.isLineNumbersShown) { if (editor.ij.settings.isLineNumbersShown) {
if (isShowingRelativeLineNumbers(editor.ij.settings.lineNumerationType)) { if (isShowingRelativeLineNumbers(editor.ij.settings.lineNumerationType)) {
@ -828,7 +829,8 @@ private class NumberOptionMapper(numberOption: ToggleOption, internalOptionValue
override fun onGlobalIdeaValueChanged(propertyName: String) { override fun onGlobalIdeaValueChanged(propertyName: String) {
if (propertyName == EditorSettingsExternalizable.PropNames.PROP_ARE_LINE_NUMBERS_SHOWN if (propertyName == EditorSettingsExternalizable.PropNames.PROP_ARE_LINE_NUMBERS_SHOWN
|| propertyName == EditorSettingsExternalizable.PropNames.PROP_LINE_NUMERATION) { || propertyName == EditorSettingsExternalizable.PropNames.PROP_LINE_NUMERATION
) {
doOnGlobalIdeaValueChanged() doOnGlobalIdeaValueChanged()
} }
} }
@ -863,13 +865,11 @@ private class RelativeNumberOptionMapper(
if (isShowingAbsoluteLineNumbers(editor.ij.settings.lineNumerationType)) { if (isShowingAbsoluteLineNumbers(editor.ij.settings.lineNumerationType)) {
editor.ij.settings.lineNumerationType = LineNumerationType.HYBRID editor.ij.settings.lineNumerationType = LineNumerationType.HYBRID
} }
} } else {
else {
editor.ij.settings.isLineNumbersShown = true editor.ij.settings.isLineNumbersShown = true
editor.ij.settings.lineNumerationType = LineNumerationType.RELATIVE editor.ij.settings.lineNumerationType = LineNumerationType.RELATIVE
} }
} } else {
else {
// Turn off 'relativenumber'. Hide lines if 'number' is not set, else switch to relative // Turn off 'relativenumber'. Hide lines if 'number' is not set, else switch to relative
if (editor.ij.settings.isLineNumbersShown) { if (editor.ij.settings.isLineNumbersShown) {
if (isShowingAbsoluteLineNumbers(editor.ij.settings.lineNumerationType)) { if (isShowingAbsoluteLineNumbers(editor.ij.settings.lineNumerationType)) {
@ -883,7 +883,8 @@ private class RelativeNumberOptionMapper(
override fun onGlobalIdeaValueChanged(propertyName: String) { override fun onGlobalIdeaValueChanged(propertyName: String) {
if (propertyName == EditorSettingsExternalizable.PropNames.PROP_ARE_LINE_NUMBERS_SHOWN if (propertyName == EditorSettingsExternalizable.PropNames.PROP_ARE_LINE_NUMBERS_SHOWN
|| propertyName == EditorSettingsExternalizable.PropNames.PROP_LINE_NUMERATION) { || propertyName == EditorSettingsExternalizable.PropNames.PROP_LINE_NUMERATION
) {
doOnGlobalIdeaValueChanged() doOnGlobalIdeaValueChanged()
} }
} }
@ -914,8 +915,8 @@ private fun isShowingRelativeLineNumbers(lineNumerationType: LineNumerationType)
* We can also clear the overridden IDE setting value by setting it to `-1`. So when the user resets the Vim option to * We can also clear the overridden IDE setting value by setting it to `-1`. So when the user resets the Vim option to
* defaults, it will again map to the global IDE value. It's a shame not all IDE settings do this. * defaults, it will again map to the global IDE value. It's a shame not all IDE settings do this.
*/ */
private class ScrollJumpOptionMapper(option: NumberOption, internalOptionValueAccessor: InternalOptionValueAccessor) private class ScrollJumpOptionMapper(option: NumberOption, internalOptionValueAccessor: InternalOptionValueAccessor) :
: GlobalOptionToGlobalLocalIdeaSettingMapper<VimInt>(option, internalOptionValueAccessor) { GlobalOptionToGlobalLocalIdeaSettingMapper<VimInt>(option, internalOptionValueAccessor) {
override val ideaPropertyName: String = EditorSettingsExternalizable.PropNames.PROP_VERTICAL_SCROLL_JUMP override val ideaPropertyName: String = EditorSettingsExternalizable.PropNames.PROP_VERTICAL_SCROLL_JUMP
@ -949,8 +950,8 @@ private class ScrollJumpOptionMapper(option: NumberOption, internalOptionValueAc
* We can also clear the overridden IDE setting value by setting it to `-1`. So when the user resets the Vim option to * We can also clear the overridden IDE setting value by setting it to `-1`. So when the user resets the Vim option to
* defaults, it will again map to the global IDE value. It's a shame not all IDE settings do this. * defaults, it will again map to the global IDE value. It's a shame not all IDE settings do this.
*/ */
private class SideScrollOptionMapper(option: NumberOption, internalOptionValueAccessor: InternalOptionValueAccessor) private class SideScrollOptionMapper(option: NumberOption, internalOptionValueAccessor: InternalOptionValueAccessor) :
: GlobalOptionToGlobalLocalIdeaSettingMapper<VimInt>(option, internalOptionValueAccessor) { GlobalOptionToGlobalLocalIdeaSettingMapper<VimInt>(option, internalOptionValueAccessor) {
override val ideaPropertyName: String = EditorSettingsExternalizable.PropNames.PROP_HORIZONTAL_SCROLL_JUMP override val ideaPropertyName: String = EditorSettingsExternalizable.PropNames.PROP_HORIZONTAL_SCROLL_JUMP
@ -1140,8 +1141,8 @@ private abstract class OneWayGlobalLocalOptionToGlobalLocalIdeaSettingMapper<T :
* (window) overrides. The [LocalOptionToGlobalLocalExternalSettingMapper] base class will handle this by calling * (window) overrides. The [LocalOptionToGlobalLocalExternalSettingMapper] base class will handle this by calling
* [setLocalExternalValue] for all open editors for the changed buffer. * [setLocalExternalValue] for all open editors for the changed buffer.
*/ */
private class TextWidthOptionMapper(textWidthOption: NumberOption) private class TextWidthOptionMapper(textWidthOption: NumberOption) :
: LocalOptionToGlobalLocalExternalSettingMapper<VimInt>(textWidthOption) { LocalOptionToGlobalLocalExternalSettingMapper<VimInt>(textWidthOption) {
// The IntelliJ setting is in practice global, from the user's perspective // The IntelliJ setting is in practice global, from the user's perspective
override val canUserModifyExternalLocalValue: Boolean = false override val canUserModifyExternalLocalValue: Boolean = false
@ -1168,8 +1169,7 @@ private class TextWidthOptionMapper(textWidthOption: NumberOption)
val project = ijEditor.project ?: ProjectManager.getInstance().defaultProject val project = ijEditor.project ?: ProjectManager.getInstance().defaultProject
return if (ijEditor.settings.isWrapWhenTypingReachesRightMargin(project)) { return if (ijEditor.settings.isWrapWhenTypingReachesRightMargin(project)) {
ijEditor.settings.getRightMargin(ijEditor.project).asVimInt() ijEditor.settings.getRightMargin(ijEditor.project).asVimInt()
} } else {
else {
VimInt.ZERO VimInt.ZERO
} }
} }
@ -1215,8 +1215,8 @@ private class TextWidthOptionMapper(textWidthOption: NumberOption)
/** /**
* Maps the `'wrap'` Vim option to the IntelliJ soft wrap settings * Maps the `'wrap'` Vim option to the IntelliJ soft wrap settings
*/ */
private class WrapOptionMapper(wrapOption: ToggleOption, internalOptionValueAccessor: InternalOptionValueAccessor) private class WrapOptionMapper(wrapOption: ToggleOption, internalOptionValueAccessor: InternalOptionValueAccessor) :
: LocalOptionToGlobalLocalIdeaSettingMapper<VimInt>(wrapOption, internalOptionValueAccessor) { LocalOptionToGlobalLocalIdeaSettingMapper<VimInt>(wrapOption, internalOptionValueAccessor) {
// This is a global-local setting, and can be modified by the user via _View | Active Editor | Soft-Wrap_ // This is a global-local setting, and can be modified by the user via _View | Active Editor | Soft-Wrap_
override val canUserModifyExternalLocalValue: Boolean = true override val canUserModifyExternalLocalValue: Boolean = true
@ -1245,7 +1245,9 @@ private class WrapOptionMapper(wrapOption: ToggleOption, internalOptionValueAcce
fun editorKindToSoftWrapAppliancesPlace(kind: EditorKind) = when (kind) { fun editorKindToSoftWrapAppliancesPlace(kind: EditorKind) = when (kind) {
EditorKind.UNTYPED, EditorKind.UNTYPED,
EditorKind.DIFF, EditorKind.DIFF,
EditorKind.MAIN_EDITOR -> SoftWrapAppliancePlaces.MAIN_EDITOR EditorKind.MAIN_EDITOR,
-> SoftWrapAppliancePlaces.MAIN_EDITOR
EditorKind.CONSOLE -> SoftWrapAppliancePlaces.CONSOLE EditorKind.CONSOLE -> SoftWrapAppliancePlaces.CONSOLE
// Treat PREVIEW as a kind of MAIN_EDITOR instead of SWAP.PREVIEW. There are fewer noticeable differences // Treat PREVIEW as a kind of MAIN_EDITOR instead of SWAP.PREVIEW. There are fewer noticeable differences
EditorKind.PREVIEW -> SoftWrapAppliancePlaces.MAIN_EDITOR EditorKind.PREVIEW -> SoftWrapAppliancePlaces.MAIN_EDITOR
@ -1261,7 +1263,9 @@ private class WrapOptionMapper(wrapOption: ToggleOption, internalOptionValueAcce
val softWrapAppliancePlace = when (editor.ij.editorKind) { val softWrapAppliancePlace = when (editor.ij.editorKind) {
EditorKind.UNTYPED, EditorKind.UNTYPED,
EditorKind.DIFF, EditorKind.DIFF,
EditorKind.MAIN_EDITOR -> SoftWrapAppliancePlaces.MAIN_EDITOR EditorKind.MAIN_EDITOR,
-> SoftWrapAppliancePlaces.MAIN_EDITOR
EditorKind.CONSOLE -> SoftWrapAppliancePlaces.CONSOLE EditorKind.CONSOLE -> SoftWrapAppliancePlaces.CONSOLE
EditorKind.PREVIEW -> SoftWrapAppliancePlaces.PREVIEW EditorKind.PREVIEW -> SoftWrapAppliancePlaces.PREVIEW
} }
@ -1304,7 +1308,8 @@ private class WrapOptionMapper(wrapOption: ToggleOption, internalOptionValueAcce
override fun onGlobalIdeaValueChanged(propertyName: String) { override fun onGlobalIdeaValueChanged(propertyName: String) {
if (propertyName == EditorSettingsExternalizable.PropNames.PROP_USE_SOFT_WRAPS if (propertyName == EditorSettingsExternalizable.PropNames.PROP_USE_SOFT_WRAPS
|| propertyName == EditorSettingsExternalizable.PropNames.PROP_SOFT_WRAP_FILE_MASKS) { || propertyName == EditorSettingsExternalizable.PropNames.PROP_SOFT_WRAP_FILE_MASKS
) {
doOnGlobalIdeaValueChanged() doOnGlobalIdeaValueChanged()
} }
} }
@ -1331,8 +1336,10 @@ class IjOptionConstants {
const val ideawrite_file: String = "file" const val ideawrite_file: String = "file"
val ideaStatusIconValues: Set<String> = setOf(ideastatusicon_enabled, ideastatusicon_gray, ideastatusicon_disabled) val ideaStatusIconValues: Set<String> = setOf(ideastatusicon_enabled, ideastatusicon_gray, ideastatusicon_disabled)
val ideaRefactorModeValues: Set<String> = setOf(idearefactormode_keep, idearefactormode_select, idearefactormode_visual) val ideaRefactorModeValues: Set<String> =
setOf(idearefactormode_keep, idearefactormode_select, idearefactormode_visual)
val ideaWriteValues: Set<String> = setOf(ideawrite_all, ideawrite_file) val ideaWriteValues: Set<String> = setOf(ideawrite_all, ideawrite_file)
val ideavimsupportValues: Set<String> = setOf(ideavimsupport_dialog, ideavimsupport_singleline, ideavimsupport_dialoglegacy) val ideavimsupportValues: Set<String> =
setOf(ideavimsupport_dialog, ideavimsupport_singleline, ideavimsupport_dialoglegacy)
} }
} }

View File

@ -37,7 +37,7 @@ class ProcessGroup : VimProcessGroupBase() {
editor: VimEditor, editor: VimEditor,
command: String, command: String,
input: CharSequence?, input: CharSequence?,
currentDirectoryPath: String? currentDirectoryPath: String?,
): String? { ): String? {
// This is a much simplified version of how Vim does this. We're using stdin/stdout directly, while Vim will // This is a much simplified version of how Vim does this. We're using stdin/stdout directly, while Vim will
// redirect to temp files ('shellredir' and 'shelltemp') or use pipes. We don't support 'shellquote', because we're // redirect to temp files ('shellredir' and 'shelltemp') or use pipes. We don't support 'shellquote', because we're

View File

@ -33,8 +33,7 @@ import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
* This group works with command associated with copying and pasting text * This group works with command associated with copying and pasting text
*/ */
@State(name = "VimRegisterSettings", storages = { @State(name = "VimRegisterSettings", storages = {
@Storage(value = "$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED) @Storage(value = "$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)})
})
public class RegisterGroup extends VimRegisterGroupBase implements PersistentStateComponent<Element> { public class RegisterGroup extends VimRegisterGroupBase implements PersistentStateComponent<Element> {
static { static {
@ -146,9 +145,8 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
final int modifiers = Integer.parseInt(keyElement.getAttributeValue("mods")); final int modifiers = Integer.parseInt(keyElement.getAttributeValue("mods"));
final char c = (char)Integer.parseInt(keyElement.getAttributeValue("char")); final char c = (char)Integer.parseInt(keyElement.getAttributeValue("char"));
//noinspection MagicConstant //noinspection MagicConstant
strokes.add(c == KeyEvent.CHAR_UNDEFINED ? strokes.add(
KeyStroke.getKeyStroke(code, modifiers) : c == KeyEvent.CHAR_UNDEFINED ? KeyStroke.getKeyStroke(code, modifiers) : KeyStroke.getKeyStroke(c));
KeyStroke.getKeyStroke(c));
} }
register = new Register(key, type, strokes); register = new Register(key, type, strokes);
} }

View File

@ -28,11 +28,15 @@ import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.initInjector import com.maddyhome.idea.vim.newapi.initInjector
import org.jdom.Element import org.jdom.Element
@State(name = "VimJumpsSettings", storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]) @State(
name = "VimJumpsSettings",
storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]
)
internal class VimJumpServiceImpl : VimJumpServiceBase(), PersistentStateComponent<Element?> { internal class VimJumpServiceImpl : VimJumpServiceBase(), PersistentStateComponent<Element?> {
companion object { companion object {
private val logger = vimLogger<VimJumpServiceImpl>() private val logger = vimLogger<VimJumpServiceImpl>()
} }
override var lastJumpTimeStamp: Long = 0 override var lastJumpTimeStamp: Long = 0
override fun includeCurrentCommandAsNavigation(editor: VimEditor) { override fun includeCurrentCommandAsNavigation(editor: VimEditor) {

View File

@ -45,7 +45,10 @@ import java.util.*
// todo sync vim jumps with ide jumps // todo sync vim jumps with ide jumps
// todo exception after moving to global mark after deleting it via IDE (impossible to receive markChar) // todo exception after moving to global mark after deleting it via IDE (impossible to receive markChar)
@State(name = "VimMarksSettings", storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]) @State(
name = "VimMarksSettings",
storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]
)
internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateComponent<Element?> { internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateComponent<Element?> {
private fun createOrGetSystemMark(ch: Char, line: Int, col: Int, editor: VimEditor): Mark? { private fun createOrGetSystemMark(ch: Char, line: Int, col: Int, editor: VimEditor): Mark? {
val ijEditor = (editor as IjVimEditor).editor val ijEditor = (editor as IjVimEditor).editor
@ -71,7 +74,8 @@ internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateCompone
} }
element.addContent(globalMarksElement) element.addContent(globalMarksElement)
val localMarksElement = Element("localmarks") val localMarksElement = Element("localmarks")
var files: List<LocalMarks<Char, Mark>> = filepathToLocalMarks.values.sortedWith(Comparator.comparing(LocalMarks<Char, Mark>::myTimestamp)) var files: List<LocalMarks<Char, Mark>> =
filepathToLocalMarks.values.sortedWith(Comparator.comparing(LocalMarks<Char, Mark>::myTimestamp))
if (files.size > SAVE_MARK_COUNT) { if (files.size > SAVE_MARK_COUNT) {
files = files.subList(files.size - SAVE_MARK_COUNT, files.size) files = files.subList(files.size - SAVE_MARK_COUNT, files.size)
} }
@ -85,7 +89,12 @@ internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateCompone
fileMarkElem.setAttribute("name", file) fileMarkElem.setAttribute("name", file)
fileMarkElem.setAttribute("timestamp", java.lang.Long.toString(marks.myTimestamp.time)) fileMarkElem.setAttribute("timestamp", java.lang.Long.toString(marks.myTimestamp.time))
for (mark in marks.values) { for (mark in marks.values) {
if (!Character.isUpperCase(mark.key) && injector.markService.isValidMark(mark.key, VimMarkService.Operation.SAVE, true)) { if (!Character.isUpperCase(mark.key) && injector.markService.isValidMark(
mark.key,
VimMarkService.Operation.SAVE,
true
)
) {
val markElem = Element("mark") val markElem = Element("mark")
markElem.setAttribute("key", mark.key.toString()) markElem.setAttribute("key", mark.key.toString())
markElem.setAttribute("line", mark.line.toString()) markElem.setAttribute("line", mark.line.toString())

View File

@ -105,7 +105,10 @@ public class WindowGroup extends WindowGroupBase {
@Override @Override
@RWLockLabel.Readonly @RWLockLabel.Readonly
@RequiresReadLock @RequiresReadLock
public void selectWindowInRow(@NotNull VimCaret caret, @NotNull ExecutionContext context, int relativePosition, boolean vertical) { public void selectWindowInRow(@NotNull VimCaret caret,
@NotNull ExecutionContext context,
int relativePosition,
boolean vertical) {
final Caret ijCaret = ((IjVimCaret)caret).getCaret(); final Caret ijCaret = ((IjVimCaret)caret).getCaret();
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext())); final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
final EditorWindow currentWindow = fileEditorManager.getCurrentWindow(); final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
@ -116,7 +119,8 @@ public class WindowGroup extends WindowGroupBase {
} }
} }
private void selectWindow(@NotNull EditorWindow currentWindow, @NotNull List<EditorWindow> windows, private void selectWindow(@NotNull EditorWindow currentWindow,
@NotNull List<EditorWindow> windows,
int relativePosition) { int relativePosition) {
final int pos = windows.indexOf(currentWindow); final int pos = windows.indexOf(currentWindow);
final int selected = pos + relativePosition; final int selected = pos + relativePosition;
@ -126,7 +130,8 @@ public class WindowGroup extends WindowGroupBase {
private static @NotNull List<EditorWindow> findWindowsInRow(@NotNull Caret caret, private static @NotNull List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
@NotNull EditorWindow editorWindow, @NotNull EditorWindow editorWindow,
@NotNull List<EditorWindow> windows, final boolean vertical) { @NotNull List<EditorWindow> windows,
final boolean vertical) {
final Point anchorPoint = getCaretPoint(caret); final Point anchorPoint = getCaretPoint(caret);
if (anchorPoint != null) { if (anchorPoint != null) {
final List<EditorWindow> result = new ArrayList<>(); final List<EditorWindow> result = new ArrayList<>();

View File

@ -181,7 +181,8 @@ internal class PutGroup : VimPutBase() {
val firstItemBefore = allContentsBefore.firstOrNull() val firstItemBefore = allContentsBefore.firstOrNull()
logger.debug { "Copied text: ${text.copiedText}" } logger.debug { "Copied text: ${text.copiedText}" }
val (textContent, transferableData) = text.copiedText as IjVimCopiedText val (textContent, transferableData) = text.copiedText as IjVimCopiedText
val origContent: TextBlockTransferable = injector.clipboardManager.setClipboardText(textContent, textContent, transferableData) as TextBlockTransferable val origContent: TextBlockTransferable =
injector.clipboardManager.setClipboardText(textContent, textContent, transferableData) as TextBlockTransferable
val allContentsAfter = CopyPasteManager.getInstance().allContents val allContentsAfter = CopyPasteManager.getInstance().allContents
val sizeAfterInsert = allContentsAfter.size val sizeAfterInsert = allContentsAfter.size
try { try {

View File

@ -159,18 +159,22 @@ internal object IdeaSelectionControl {
if (logReason) logger.debug("Enter select mode. Reason: one line mode") if (logReason) logger.debug("Enter select mode. Reason: one line mode")
Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim)) Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim))
} }
selectionSource == VimListenerManager.SelectionSource.MOUSE && OptionConstants.selectmode_mouse in selectmode -> { selectionSource == VimListenerManager.SelectionSource.MOUSE && OptionConstants.selectmode_mouse in selectmode -> {
if (logReason) logger.debug("Enter select mode. Selection source is mouse and selectMode option has mouse") if (logReason) logger.debug("Enter select mode. Selection source is mouse and selectMode option has mouse")
Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim)) Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim))
} }
editor.isTemplateActive() && editor.vim.isIdeaRefactorModeSelect -> { editor.isTemplateActive() && editor.vim.isIdeaRefactorModeSelect -> {
if (logReason) logger.debug("Enter select mode. Template is active and selectMode has template") if (logReason) logger.debug("Enter select mode. Template is active and selectMode has template")
Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim)) Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim))
} }
selectionSource == VimListenerManager.SelectionSource.OTHER && OptionConstants.selectmode_ideaselection in selectmode -> { selectionSource == VimListenerManager.SelectionSource.OTHER && OptionConstants.selectmode_ideaselection in selectmode -> {
if (logReason) logger.debug("Enter select mode. Selection source is OTHER and selectMode has refactoring") if (logReason) logger.debug("Enter select mode. Selection source is OTHER and selectMode has refactoring")
Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim)) Mode.SELECT(VimPlugin.getVisualMotion().detectSelectionType(editor.vim))
} }
else -> { else -> {
if (logReason) logger.debug("Enter visual mode") if (logReason) logger.debug("Enter visual mode")
Mode.VISUAL(VimPlugin.getVisualMotion().detectSelectionType(editor.vim)) Mode.VISUAL(VimPlugin.getVisualMotion().detectSelectionType(editor.vim))

View File

@ -106,8 +106,7 @@ private fun correctCopilotKeymap() {
keymap.removeShortcut("copilot.disposeInlays", escapeShortcut) keymap.removeShortcut("copilot.disposeInlays", escapeShortcut)
copilotHideActionMap[keymap.name] = Unit copilotHideActionMap[keymap.name] = Unit
LOG.info("Remove copilot escape shortcut from keymap ${keymap.name}") LOG.info("Remove copilot escape shortcut from keymap ${keymap.name}")
} } else {
else {
copilotHideActionMap.forEach { (name, _) -> copilotHideActionMap.forEach { (name, _) ->
val keymap = KeymapManagerEx.getInstanceEx().getKeymap(name) ?: return@forEach val keymap = KeymapManagerEx.getInstanceEx().getKeymap(name) ?: return@forEach
val currentShortcuts = keymap.getShortcuts("copilot.disposeInlays") val currentShortcuts = keymap.getShortcuts("copilot.disposeInlays")

View File

@ -18,7 +18,12 @@ import com.maddyhome.idea.vim.command.OperatorArguments
* Base class for Vim commands handled by existing IDE actions. * Base class for Vim commands handled by existing IDE actions.
*/ */
internal abstract class IdeActionHandler(private val actionName: String) : VimActionHandler.SingleExecution() { internal abstract class IdeActionHandler(private val actionName: String) : VimActionHandler.SingleExecution() {
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { override fun execute(
editor: VimEditor,
context: ExecutionContext,
cmd: Command,
operatorArguments: OperatorArguments,
): Boolean {
injector.actionExecutor.executeAction(editor, name = actionName, context = context) injector.actionExecutor.executeAction(editor, name = actionName, context = context)
injector.scroll.scrollCaretIntoView(editor) injector.scroll.scrollCaretIntoView(editor)
return true return true

View File

@ -111,9 +111,12 @@ private fun Editor.updateSecondaryCaretsVisualAttributes() {
} }
} }
private val HIDDEN = CaretVisualAttributes(null, CaretVisualAttributes.Weight.NORMAL, CaretVisualAttributes.Shape.BAR, 0F) private val HIDDEN =
private val BLOCK = CaretVisualAttributes(null, CaretVisualAttributes.Weight.NORMAL, CaretVisualAttributes.Shape.BLOCK, 1.0F) CaretVisualAttributes(null, CaretVisualAttributes.Weight.NORMAL, CaretVisualAttributes.Shape.BAR, 0F)
private val BAR = CaretVisualAttributes(null, CaretVisualAttributes.Weight.NORMAL, CaretVisualAttributes.Shape.BAR, 0.25F) private val BLOCK =
CaretVisualAttributes(null, CaretVisualAttributes.Weight.NORMAL, CaretVisualAttributes.Shape.BLOCK, 1.0F)
private val BAR =
CaretVisualAttributes(null, CaretVisualAttributes.Weight.NORMAL, CaretVisualAttributes.Shape.BAR, 0.25F)
private object AttributesCache { private object AttributesCache {
private var lastGuicursorValue = "" private var lastGuicursorValue = ""

View File

@ -79,7 +79,8 @@ public class EditorHelper {
public static int getVisualLineAtMiddleOfScreen(final @NotNull Editor editor) { public static int getVisualLineAtMiddleOfScreen(final @NotNull Editor editor) {
// The editor will return line numbers of virtual space if the text doesn't reach the end of the visible area // The editor will return line numbers of virtual space if the text doesn't reach the end of the visible area
// (either because it's too short, or it's been scrolled up) // (either because it's too short, or it's been scrolled up)
final int lastLineBaseline = editor.logicalPositionToXY(new LogicalPosition(new IjVimEditor(editor).lineCount(), 0)).y; final int lastLineBaseline =
editor.logicalPositionToXY(new LogicalPosition(new IjVimEditor(editor).lineCount(), 0)).y;
final Rectangle visibleArea = getVisibleArea(editor); final Rectangle visibleArea = getVisibleArea(editor);
final int height = min(lastLineBaseline - visibleArea.y, visibleArea.height); final int height = min(lastLineBaseline - visibleArea.y, visibleArea.height);
return editor.yToVisualLine(visibleArea.y + (height / 2)); return editor.yToVisualLine(visibleArea.y + (height / 2));
@ -91,8 +92,7 @@ public class EditorHelper {
// Adjust available height if the ex entry text field is visible // Adjust available height if the ex entry text field is visible
final Rectangle visibleArea = getVisibleArea(editor); final Rectangle visibleArea = getVisibleArea(editor);
final int height = visibleArea.height - getExEntryHeight() - getHorizontalScrollbarHeight(editor); final int height = visibleArea.height - getExEntryHeight() - getHorizontalScrollbarHeight(editor);
return getFullVisualLine(editor, visibleArea.y + height, visibleArea.y, return getFullVisualLine(editor, visibleArea.y + height, visibleArea.y, visibleArea.y + height);
visibleArea.y + height);
} }
public static int getVisualLineAtBottomOfScreen(final @NotNull Editor editor) { public static int getVisualLineAtBottomOfScreen(final @NotNull Editor editor) {
@ -288,7 +288,8 @@ public class EditorHelper {
// virtual space at the bottom of the screen // virtual space at the bottom of the screen
final @NotNull VimEditor editor1 = new IjVimEditor(editor); final @NotNull VimEditor editor1 = new IjVimEditor(editor);
final int lastVisualLine = EngineEditorHelperKt.getVisualLineCount(editor1) - 1; final int lastVisualLine = EngineEditorHelperKt.getVisualLineCount(editor1) - 1;
final int yBottomLineOffset = max(getOffsetToScrollVisualLineToBottomOfScreen(editor, lastVisualLine), visibleArea.y); final int yBottomLineOffset =
max(getOffsetToScrollVisualLineToBottomOfScreen(editor, lastVisualLine), visibleArea.y);
scrollVertically(editor, min(yVisualLine - caretScreenOffset - inlayOffset, yBottomLineOffset)); scrollVertically(editor, min(yVisualLine - caretScreenOffset - inlayOffset, yBottomLineOffset));
} }
@ -331,7 +332,9 @@ public class EditorHelper {
* @param editor The editor to scroll * @param editor The editor to scroll
* @param visualLine The visual line to place in the middle of the current window * @param visualLine The visual line to place in the middle of the current window
*/ */
public static void scrollVisualLineToMiddleOfScreen(@NotNull Editor editor, int visualLine, boolean allowVirtualSpace) { public static void scrollVisualLineToMiddleOfScreen(@NotNull Editor editor,
int visualLine,
boolean allowVirtualSpace) {
final int y = editor.visualLineToY(EngineEditorHelperKt.normalizeVisualLine(new IjVimEditor(editor), visualLine)); final int y = editor.visualLineToY(EngineEditorHelperKt.normalizeVisualLine(new IjVimEditor(editor), visualLine));
final Rectangle visibleArea = getVisibleArea(editor); final Rectangle visibleArea = getVisibleArea(editor);
final int screenHeight = visibleArea.height; final int screenHeight = visibleArea.height;
@ -423,7 +426,8 @@ public class EditorHelper {
} }
} }
final int columnLeftX = (int) Math.round(editor.visualPositionToPoint2D(new VisualPosition(visualLine, targetVisualColumn)).getX()); final int columnLeftX =
(int)Math.round(editor.visualPositionToPoint2D(new VisualPosition(visualLine, targetVisualColumn)).getX());
scrollHorizontally(editor, columnLeftX); scrollHorizontally(editor, columnLeftX);
} }
@ -461,7 +465,8 @@ public class EditorHelper {
} }
// Scroll to the left edge of the target column, minus a screenwidth, and adjusted for inlays // Scroll to the left edge of the target column, minus a screenwidth, and adjusted for inlays
final int targetColumnRightX = (int) Math.round(editor.visualPositionToPoint2D(new VisualPosition(visualLine, targetVisualColumn + 1)).getX()); final int targetColumnRightX =
(int)Math.round(editor.visualPositionToPoint2D(new VisualPosition(visualLine, targetVisualColumn + 1)).getX());
final int screenWidth = getVisibleArea(editor).width; final int screenWidth = getVisibleArea(editor).width;
scrollHorizontally(editor, targetColumnRightX - screenWidth); scrollHorizontally(editor, targetColumnRightX - screenWidth);
} }
@ -596,7 +601,8 @@ public class EditorHelper {
} }
if (xActualLeft >= leftBound) { if (xActualLeft >= leftBound) {
final VisualPosition nextVisualPosition = new VisualPosition(closestVisualPosition.line, closestVisualPosition.column + 1); final VisualPosition nextVisualPosition =
new VisualPosition(closestVisualPosition.line, closestVisualPosition.column + 1);
final long xActualRight = Math.round(editor.visualPositionToPoint2D(nextVisualPosition).getX()) - 1; final long xActualRight = Math.round(editor.visualPositionToPoint2D(nextVisualPosition).getX()) - 1;
if (xActualRight <= rightBound) { if (xActualRight <= rightBound) {
return closestVisualPosition.column; return closestVisualPosition.column;

View File

@ -56,7 +56,8 @@ internal class HandlerInjector {
// only true in command mode. // only true in command mode.
// Set by `org.jetbrains.plugins.notebooks.ui.editor.actions.command.mode.NotebookEditorModeListenerAdapter` // Set by `org.jetbrains.plugins.notebooks.ui.editor.actions.command.mode.NotebookEditorModeListenerAdapter`
// appears to be null in non Notebook editors // appears to be null in non Notebook editors
val allow_plain_letter_shortcuts = editor.contentComponent.getClientProperty(ActionUtil.ALLOW_PlAIN_LETTER_SHORTCUTS) val allow_plain_letter_shortcuts =
editor.contentComponent.getClientProperty(ActionUtil.ALLOW_PlAIN_LETTER_SHORTCUTS)
inEditor && (allow_plain_letter_shortcuts != null && allow_plain_letter_shortcuts as Boolean) inEditor && (allow_plain_letter_shortcuts != null && allow_plain_letter_shortcuts as Boolean)
} }
} else { } else {

View File

@ -197,4 +197,5 @@ private fun skip(iterator: IntIterator, n: Int) {
class CountPosition(val count: Int, val position: Int) class CountPosition(val count: Int, val position: Int)
private val logger = logger<SearchLogger>() private val logger = logger<SearchLogger>()
private class SearchLogger private class SearchLogger

View File

@ -48,8 +48,7 @@ internal fun updateIncsearchHighlights(
): Int { ): Int {
val searchStartOffset = if (searchRange != null && searchRange.startLine < editor.document.lineCount) { val searchStartOffset = if (searchRange != null && searchRange.startLine < editor.document.lineCount) {
editor.vim.getLineStartOffset(searchRange.startLine) editor.vim.getLineStartOffset(searchRange.startLine)
} } else {
else {
caretOffset caretOffset
} }
val showHighlights = injector.options(editor.vim).hlsearch val showHighlights = injector.options(editor.vim).hlsearch
@ -218,8 +217,7 @@ private fun findClosestMatch(
} }
val closestIndex = if (forwards) { val closestIndex = if (forwards) {
sortedResults.indexOfFirst { it.startOffset > initialOffset } sortedResults.indexOfFirst { it.startOffset > initialOffset }
} } else {
else {
sortedResults.indexOfFirst { it.startOffset < initialOffset } sortedResults.indexOfFirst { it.startOffset < initialOffset }
} }
@ -235,7 +233,12 @@ private fun findClosestMatch(
return sortedResults[nextIndex % results.size].startOffset return sortedResults[nextIndex % results.size].startOffset
} }
internal fun highlightSearchResults(editor: Editor, pattern: String, results: List<TextRange>, currentMatchOffset: Int) { internal fun highlightSearchResults(
editor: Editor,
pattern: String,
results: List<TextRange>,
currentMatchOffset: Int,
) {
var highlighters = editor.vimLastHighlighters var highlighters = editor.vimLastHighlighters
if (highlighters == null) { if (highlighters == null) {
highlighters = mutableListOf() highlighters = mutableListOf()

View File

@ -81,9 +81,11 @@ internal var Caret.vimLastColumn: Int
_vimLastColumn = value _vimLastColumn = value
_vimLastColumnPos = visualPosition _vimLastColumnPos = visualPosition
} }
internal fun Caret.resetVimLastColumn() { internal fun Caret.resetVimLastColumn() {
_vimLastColumnPos = null _vimLastColumnPos = null
} }
private var Caret._vimLastColumn: Int by userDataCaretToEditorOr { (this as Caret).inlayAwareVisualColumn } private var Caret._vimLastColumn: Int by userDataCaretToEditorOr { (this as Caret).inlayAwareVisualColumn }
private var Caret._vimLastColumnPos: VisualPosition? by userDataCaretToEditor() private var Caret._vimLastColumnPos: VisualPosition? by userDataCaretToEditor()

View File

@ -72,7 +72,8 @@ internal object IdeaSpecifics {
val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction
if (!isVimAction && injector.globalIjOptions().trackactionids) { if (!isVimAction && injector.globalIjOptions().trackactionids) {
if (action !is NotificationService.ActionIdNotifier.CopyActionId && action !is NotificationService.ActionIdNotifier.StopTracking) { if (action !is NotificationService.ActionIdNotifier.CopyActionId && action !is NotificationService.ActionIdNotifier.StopTracking) {
val id: String? = ActionManager.getInstance().getId(action) ?: (action.shortcutSet as? ProxyShortcutSet)?.actionId val id: String? =
ActionManager.getInstance().getId(action) ?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
val candidates = if (id == null) { val candidates = if (id == null) {
// Some actions are specific to the component they're registered for, and are copies of a global action, // Some actions are specific to the component they're registered for, and are copies of a global action,
// reusing the action ID and shortcuts (e.g. `NextTab` is different for editor tabs and tool window tabs). // reusing the action ID and shortcuts (e.g. `NextTab` is different for editor tabs and tool window tabs).
@ -83,8 +84,7 @@ internal object IdeaSpecifics {
// action. Note that we might return duplicate IDs because the keymap might have multiple shortcuts mapped // action. Note that we might return duplicate IDs because the keymap might have multiple shortcuts mapped
// to the same action. The notifier will handle de-duplication and sorting as a presentation detail. // to the same action. The notifier will handle de-duplication and sorting as a presentation detail.
action.shortcutSet.shortcuts.flatMap { KeymapManager.getInstance().activeKeymap.getActionIdList(it) } action.shortcutSet.shortcuts.flatMap { KeymapManager.getInstance().activeKeymap.getActionIdList(it) }
} } else {
else {
emptyList() emptyList()
} }
@ -125,7 +125,14 @@ internal object IdeaSpecifics {
val caretShift = addedTextLength - (editor.caretModel.primaryCaret.offset - prevDocumentOffset) val caretShift = addedTextLength - (editor.caretModel.primaryCaret.offset - prevDocumentOffset)
val leftArrow = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0) val leftArrow = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)
register.recordText(editor.document.getText(TextRange(prevDocumentOffset, prevDocumentOffset + addedTextLength))) register.recordText(
editor.document.getText(
TextRange(
prevDocumentOffset,
prevDocumentOffset + addedTextLength
)
)
)
repeat(caretShift.coerceAtLeast(0)) { repeat(caretShift.coerceAtLeast(0)) {
register.recordKeyStroke(leftArrow) register.recordKeyStroke(leftArrow)
} }

View File

@ -14,7 +14,10 @@ import com.maddyhome.idea.vim.common.ModeChangeListener
import com.maddyhome.idea.vim.newapi.ij import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.state.mode.Mode import com.maddyhome.idea.vim.state.mode.Mode
@Deprecated(message = "Please use ModeChangeListener", replaceWith = ReplaceWith("ModeChangeListener", imports = ["import com.maddyhome.idea.vim.common.ModeChangeListener"])) @Deprecated(
message = "Please use ModeChangeListener",
replaceWith = ReplaceWith("ModeChangeListener", imports = ["import com.maddyhome.idea.vim.common.ModeChangeListener"])
)
interface VimInsertListener : ModeChangeListener { interface VimInsertListener : ModeChangeListener {
override fun modeChanged(editor: VimEditor, oldMode: Mode) { override fun modeChanged(editor: VimEditor, oldMode: Mode) {
if (editor.mode == Mode.INSERT) { if (editor.mode == Mode.INSERT) {

View File

@ -197,7 +197,10 @@ internal object VimListenerManager {
val optionGroup = VimPlugin.getOptionGroup() val optionGroup = VimPlugin.getOptionGroup()
optionGroup.addEffectiveOptionValueChangeListener(Options.number, EditorGroup.NumberChangeListener.INSTANCE) optionGroup.addEffectiveOptionValueChangeListener(Options.number, EditorGroup.NumberChangeListener.INSTANCE)
optionGroup.addEffectiveOptionValueChangeListener(IjOptions.relativenumber, EditorGroup.NumberChangeListener.INSTANCE) optionGroup.addEffectiveOptionValueChangeListener(
IjOptions.relativenumber,
EditorGroup.NumberChangeListener.INSTANCE
)
optionGroup.addEffectiveOptionValueChangeListener(Options.scrolloff, ScrollGroup.ScrollOptionsChangeListener) optionGroup.addEffectiveOptionValueChangeListener(Options.scrolloff, ScrollGroup.ScrollOptionsChangeListener)
optionGroup.addEffectiveOptionValueChangeListener(Options.guicursor, GuicursorChangeListener) optionGroup.addEffectiveOptionValueChangeListener(Options.guicursor, GuicursorChangeListener)
optionGroup.addGlobalOptionChangeListener(Options.showcmd, ShowCmdOptionChangeListener) optionGroup.addGlobalOptionChangeListener(Options.showcmd, ShowCmdOptionChangeListener)
@ -209,8 +212,10 @@ internal object VimListenerManager {
macroWidgetOptionListener.onGlobalOptionChanged() macroWidgetOptionListener.onGlobalOptionChanged()
// Listen for and initialise new editors // Listen for and initialise new editors
EventFacade.getInstance().addEditorFactoryListener(VimEditorFactoryListener, VimPlugin.getInstance().onOffDisposable) EventFacade.getInstance()
val busConnection = ApplicationManager.getApplication().messageBus.connect(VimPlugin.getInstance().onOffDisposable) .addEditorFactoryListener(VimEditorFactoryListener, VimPlugin.getInstance().onOffDisposable)
val busConnection =
ApplicationManager.getApplication().messageBus.connect(VimPlugin.getInstance().onOffDisposable)
busConnection.subscribe(FileOpenedSyncListener.TOPIC, VimEditorFactoryListener) busConnection.subscribe(FileOpenedSyncListener.TOPIC, VimEditorFactoryListener)
} }
@ -219,7 +224,10 @@ internal object VimListenerManager {
val optionGroup = VimPlugin.getOptionGroup() val optionGroup = VimPlugin.getOptionGroup()
optionGroup.removeEffectiveOptionValueChangeListener(Options.number, EditorGroup.NumberChangeListener.INSTANCE) optionGroup.removeEffectiveOptionValueChangeListener(Options.number, EditorGroup.NumberChangeListener.INSTANCE)
optionGroup.removeEffectiveOptionValueChangeListener(IjOptions.relativenumber, EditorGroup.NumberChangeListener.INSTANCE) optionGroup.removeEffectiveOptionValueChangeListener(
IjOptions.relativenumber,
EditorGroup.NumberChangeListener.INSTANCE
)
optionGroup.removeEffectiveOptionValueChangeListener(Options.scrolloff, ScrollGroup.ScrollOptionsChangeListener) optionGroup.removeEffectiveOptionValueChangeListener(Options.scrolloff, ScrollGroup.ScrollOptionsChangeListener)
optionGroup.removeGlobalOptionChangeListener(Options.showcmd, ShowCmdOptionChangeListener) optionGroup.removeGlobalOptionChangeListener(Options.showcmd, ShowCmdOptionChangeListener)
optionGroup.removeGlobalOptionChangeListener(Options.showmode, modeWidgetOptionListener) optionGroup.removeGlobalOptionChangeListener(Options.showmode, modeWidgetOptionListener)
@ -327,8 +335,7 @@ internal object VimListenerManager {
val editorDisposable = editor.removeUserData(editorListenersDisposableKey) val editorDisposable = editor.removeUserData(editorListenersDisposableKey)
if (editorDisposable != null) { if (editorDisposable != null) {
Disposer.dispose(editorDisposable) Disposer.dispose(editorDisposable)
} } else {
else {
// We definitely do not expect this to happen // We definitely do not expect this to happen
StrictMode.fail("Editor doesn't have disposable attached. $editor") StrictMode.fail("Editor doesn't have disposable attached. $editor")
} }
@ -447,8 +454,7 @@ internal object VimListenerManager {
} }
EditorListeners.add(event.editor, openingEditor?.vim ?: injector.fallbackWindow, scenario) EditorListeners.add(event.editor, openingEditor?.vim ?: injector.fallbackWindow, scenario)
firstEditorInitialised = true firstEditorInitialised = true
} } else {
else {
// We've got a virtual file, so FileOpenedSyncListener will be called. Save data // We've got a virtual file, so FileOpenedSyncListener will be called. Save data
val project = openingEditor.project ?: return val project = openingEditor.project ?: return
val virtualFile = openingEditor.virtualFile ?: return val virtualFile = openingEditor.virtualFile ?: return
@ -469,7 +475,10 @@ internal object VimListenerManager {
// editor has been closed. This is nullable, but should always have a value // editor has been closed. This is nullable, but should always have a value
val owningEditorWindow = getOwningEditorWindow(openingEditor) val owningEditorWindow = getOwningEditorWindow(openingEditor)
event.editor.putUserData(openingEditorKey, OpeningEditor(openingEditor, owningEditorWindow, isPreview, canBeReused)) event.editor.putUserData(
openingEditorKey,
OpeningEditor(openingEditor, owningEditorWindow, isPreview, canBeReused)
)
} }
VimStandalonePluginUpdateChecker.getInstance().pluginUsed() VimStandalonePluginUpdateChecker.getInstance().pluginUsed()
@ -525,7 +534,7 @@ internal object VimListenerManager {
// Sometimes the platform will not reuse a tab when you expect it to, e.g. when reuse tabs is enabled and // Sometimes the platform will not reuse a tab when you expect it to, e.g. when reuse tabs is enabled and
// navigating to derived class. We'll confirm our heuristics by checking to see if the editor is still around // navigating to derived class. We'll confirm our heuristics by checking to see if the editor is still around
val openingEditorIsClosed = editor.project?.let { p -> val openingEditorIsClosed = editor.project?.let { p ->
FileEditorManagerEx.getInstanceEx(p).allEditors.filterIsInstance(TextEditor::class.java).all { textEditor -> FileEditorManagerEx.getInstanceEx(p).allEditors.filterIsInstance<TextEditor>().all { textEditor ->
textEditor.editor != openingEditor?.editor textEditor.editor != openingEditor?.editor
} }
} ?: false } ?: false
@ -547,7 +556,7 @@ internal object VimListenerManager {
private fun getOwningEditorWindow(editor: Editor) = editor.project?.let { p -> private fun getOwningEditorWindow(editor: Editor) = editor.project?.let { p ->
FileEditorManagerEx.getInstanceEx(p).windows.find { editorWindow -> FileEditorManagerEx.getInstanceEx(p).windows.find { editorWindow ->
editorWindow.allComposites.any { composite -> editorWindow.allComposites.any { composite ->
composite.allEditors.filterIsInstance(TextEditor::class.java).any { it.editor == editor } composite.allEditors.filterIsInstance<TextEditor>().any { it.editor == editor }
} }
} }
} }
@ -584,7 +593,8 @@ internal object VimListenerManager {
// TODO: It is very confusing that this logic is split between EditorSelectionHandler and EditorMouseHandler // TODO: It is very confusing that this logic is split between EditorSelectionHandler and EditorMouseHandler
if (MouseEventsDataHolder.dragEventCount < MouseEventsDataHolder.allowedSkippedDragEvents if (MouseEventsDataHolder.dragEventCount < MouseEventsDataHolder.allowedSkippedDragEvents
&& lineStart != lineEnd && startOffset == caretOffset) { && lineStart != lineEnd && startOffset == caretOffset
) {
if (lineEnd == endOffset - 1) { if (lineEnd == endOffset - 1) {
// When starting on an empty line and dragging vertically upwards onto // When starting on an empty line and dragging vertically upwards onto
// another line, the selection should include the entirety of the empty line // another line, the selection should include the entirety of the empty line

View File

@ -32,8 +32,7 @@ internal class IntellijMark(bookmark: LineBookmark, override val col: Int, proje
} }
private fun getMark(): LineBookmark? = private fun getMark(): LineBookmark? =
getProject()?.let { getProject()?.let { project ->
project ->
BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark
} }

View File

@ -64,7 +64,11 @@ internal class IjClipboardManager : VimClipboardManager {
override fun setClipboardContent(editor: VimEditor, context: ExecutionContext, textData: VimCopiedText): Boolean { override fun setClipboardContent(editor: VimEditor, context: ExecutionContext, textData: VimCopiedText): Boolean {
require(textData is IjVimCopiedText) require(textData is IjVimCopiedText)
return handleTextSetting(textData.text, textData.text, textData.transferableData) { content -> setContents(content) } != null return handleTextSetting(
textData.text,
textData.text,
textData.transferableData
) { content -> setContents(content) } != null
} }
// TODO prefer methods with ranges, because they collect and preprocess for us // TODO prefer methods with ranges, because they collect and preprocess for us
@ -129,7 +133,12 @@ internal class IjClipboardManager : VimClipboardManager {
} }
} }
override fun collectCopiedText(editor: VimEditor, context: ExecutionContext, range: TextRange, text: String): VimCopiedText { override fun collectCopiedText(
editor: VimEditor,
context: ExecutionContext,
range: TextRange,
text: String,
): VimCopiedText {
val transferableData = getTransferableData(editor, range) val transferableData = getTransferableData(editor, range)
val preprocessedText = preprocessText(editor, range, text, transferableData) val preprocessedText = preprocessText(editor, range, text, transferableData)
return IjVimCopiedText(preprocessedText, transferableData) return IjVimCopiedText(preprocessedText, transferableData)
@ -140,7 +149,12 @@ internal class IjClipboardManager : VimClipboardManager {
} }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private fun handleTextSetting(text: String, rawText: String, transferableData: List<Any>, setContent: (TextBlockTransferable) -> Unit?): Transferable? { private fun handleTextSetting(
text: String,
rawText: String,
transferableData: List<Any>,
setContent: (TextBlockTransferable) -> Unit?,
): Transferable? {
val mutableTransferableData = (transferableData as List<TextBlockTransferableData>).toMutableList() val mutableTransferableData = (transferableData as List<TextBlockTransferableData>).toMutableList()
try { try {
val s = TextBlockTransferable.convertLineSeparators(text, "\n", mutableTransferableData) val s = TextBlockTransferable.convertLineSeparators(text, "\n", mutableTransferableData)
@ -182,7 +196,12 @@ internal class IjClipboardManager : VimClipboardManager {
} }
} }
} }
transferableData.add(CaretStateTransferableData(intArrayOf(0), intArrayOf(textRange.endOffset - textRange.startOffset))) transferableData.add(
CaretStateTransferableData(
intArrayOf(0),
intArrayOf(textRange.endOffset - textRange.startOffset)
)
)
// These data provided by {@link com.intellij.openapi.editor.richcopy.TextWithMarkupProcessor} doesn't work with // These data provided by {@link com.intellij.openapi.editor.richcopy.TextWithMarkupProcessor} doesn't work with
// IdeaVim and I don't see a way to fix it // IdeaVim and I don't see a way to fix it

View File

@ -86,6 +86,7 @@ internal class IjVimCaret(val caret: Caret) : VimCaretBase() {
set(value) { set(value) {
caret.vimLastColumn = value caret.vimLastColumn = value
} }
override fun resetLastColumn() = caret.resetVimLastColumn() override fun resetLastColumn() = caret.resetVimLastColumn()
override val selectionStart: Int override val selectionStart: Int
get() = caret.selectionStart get() = caret.selectionStart

View File

@ -386,7 +386,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor, VimEditorBase(
} }
override fun extractProtocol(): String? { override fun extractProtocol(): String? {
return EditorHelper.getVirtualFile(editor)?.getUrl()?.let { VirtualFileManager.extractProtocol(it) } return EditorHelper.getVirtualFile(editor)?.url?.let { VirtualFileManager.extractProtocol(it) }
} }
override val projectId = editor.project?.let { injector.file.getProjectId(it) } ?: DEFAULT_PROJECT_ID override val projectId = editor.project?.let { injector.file.getProjectId(it) } ?: DEFAULT_PROJECT_ID

View File

@ -41,8 +41,7 @@ internal class IjVimMessages : VimMessagesBase() {
val project = editor?.ij?.project val project = editor?.ij?.project
if (project != null) { if (project != null) {
setStatusBarMessage(project, message) setStatusBarMessage(project, message)
} } else {
else {
// TODO: We really shouldn't set the status bar text for other projects. That's rude. // TODO: We really shouldn't set the status bar text for other projects. That's rude.
ProjectManager.getInstance().openProjects.forEach { ProjectManager.getInstance().openProjects.forEach {
setStatusBarMessage(it, message) setStatusBarMessage(it, message)

View File

@ -277,7 +277,11 @@ open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateComponent<Ele
} }
} }
(injector.searchGroup as VimSearchGroupBase).highlightSearchLines(editor.vim, startPosition.line, endPosition.line) (injector.searchGroup as VimSearchGroupBase).highlightSearchLines(
editor.vim,
startPosition.line,
endPosition.line
)
if (logger.isDebug()) { if (logger.isDebug()) {
existingHighlighters = editor.vimLastHighlighters!! existingHighlighters = editor.vimLastHighlighters!!

View File

@ -45,8 +45,7 @@ internal class IjVimSearchHelper : VimSearchHelperBase() {
endOffset = caret.offset - 1 endOffset = caret.offset - 1
skipCount = -count - 1 skipCount = -count - 1
offsetOrdering = IntComparators.OPPOSITE_COMPARATOR offsetOrdering = IntComparators.OPPOSITE_COMPARATOR
} } else {
else {
startOffset = caret.offset + 1 startOffset = caret.offset + 1
endOffset = editor.ij.document.textLength endOffset = editor.ij.document.textLength
skipCount = count - 1 skipCount = count - 1

View File

@ -29,7 +29,13 @@ internal class ShortcutConflictState : ApplicationUsagesCollector() {
val metrics = mutableSetOf<MetricEvent>() val metrics = mutableSetOf<MetricEvent>()
keyStrokes.forEach { keystroke -> keyStrokes.forEach { keystroke ->
getHandlersForShortcut(keystroke) getHandlersForShortcut(keystroke)
.filter { !setOf(HandledModes.INSERT_UNDEFINED, HandledModes.NORMAL_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED).contains(it) } .filter {
!setOf(
HandledModes.INSERT_UNDEFINED,
HandledModes.NORMAL_UNDEFINED,
HandledModes.VISUAL_AND_SELECT_UNDEFINED
).contains(it)
}
.forEach { mode -> .forEach { mode ->
metrics += HANDLER.metric(keystroke.toReadableString(), mode) metrics += HANDLER.metric(keystroke.toReadableString(), mode)
} }
@ -38,14 +44,32 @@ internal class ShortcutConflictState : ApplicationUsagesCollector() {
} }
private fun getHandlersForShortcut(shortcut: KeyStroke): List<HandledModes> { private fun getHandlersForShortcut(shortcut: KeyStroke): List<HandledModes> {
val modes = VimPlugin.getKey().shortcutConflicts[shortcut] ?: return listOf(HandledModes.NORMAL_UNDEFINED, HandledModes.INSERT_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED) val modes = VimPlugin.getKey().shortcutConflicts[shortcut] ?: return listOf(
HandledModes.NORMAL_UNDEFINED,
HandledModes.INSERT_UNDEFINED,
HandledModes.VISUAL_AND_SELECT_UNDEFINED
)
return when (modes) { return when (modes) {
is ShortcutOwnerInfo.AllModes -> { is ShortcutOwnerInfo.AllModes -> {
when (modes.owner) { when (modes.owner) {
ShortcutOwner.IDE -> listOf(HandledModes.NORMAL_IDE, HandledModes.INSERT_IDE, HandledModes.VISUAL_AND_SELECT_IDE) ShortcutOwner.IDE -> listOf(
ShortcutOwner.VIM -> listOf(HandledModes.NORMAL_VIM, HandledModes.INSERT_VIM, HandledModes.VISUAL_AND_SELECT_VIM) HandledModes.NORMAL_IDE,
ShortcutOwner.UNDEFINED -> listOf(HandledModes.NORMAL_UNDEFINED, HandledModes.INSERT_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED) HandledModes.INSERT_IDE,
HandledModes.VISUAL_AND_SELECT_IDE
)
ShortcutOwner.VIM -> listOf(
HandledModes.NORMAL_VIM,
HandledModes.INSERT_VIM,
HandledModes.VISUAL_AND_SELECT_VIM
)
ShortcutOwner.UNDEFINED -> listOf(
HandledModes.NORMAL_UNDEFINED,
HandledModes.INSERT_UNDEFINED,
HandledModes.VISUAL_AND_SELECT_UNDEFINED
)
} }
} }

View File

@ -29,7 +29,8 @@ internal class VimscriptState : ApplicationUsagesCollector() {
return setOf( return setOf(
VIMSCRIPT.metric( VIMSCRIPT.metric(
SOURCED_FILES with Util.sourcedFiles.size, SOURCED_FILES with Util.sourcedFiles.size,
IDEAVIMRC_SIZE with (VimRcService.findIdeaVimRc()?.readLines()?.filter { !it.matches(Regex("\\s*\".*")) && it.isNotBlank() }?.size ?: -1), IDEAVIMRC_SIZE with (VimRcService.findIdeaVimRc()?.readLines()
?.filter { !it.matches(Regex("\\s*\".*")) && it.isNotBlank() }?.size ?: -1),
EXTENSIONS_ENABLED_BY_SET with (PluginState.Util.enabledExtensions - Util.extensionsEnabledWithPlug).toList(), EXTENSIONS_ENABLED_BY_SET with (PluginState.Util.enabledExtensions - Util.extensionsEnabledWithPlug).toList(),
EXTENSIONS_ENABLED_BY_PLUG with Util.extensionsEnabledWithPlug.toList(), EXTENSIONS_ENABLED_BY_PLUG with Util.extensionsEnabledWithPlug.toList(),
IS_IDE_SPECIFIC_CONFIGURATION_USED with Util.isIDESpecificConfigurationUsed, IS_IDE_SPECIFIC_CONFIGURATION_USED with Util.isIDESpecificConfigurationUsed,

View File

@ -58,8 +58,10 @@ class WidgetState : ApplicationUsagesCollector() {
private val GROUP = EventLogGroup("vim.widget", 1, "FUS") private val GROUP = EventLogGroup("vim.widget", 1, "FUS")
private val IS_MODE_WIDGET_SHOWN = EventFields.Boolean("is-mode-widget-shown") private val IS_MODE_WIDGET_SHOWN = EventFields.Boolean("is-mode-widget-shown")
private val MODE_WIDGET_THEME_LIGHT = EventFields.String("mode-widget-theme-light", listOf("TERM", "COLORLESS", "ADVANCED CUSTOMIZATION")) private val MODE_WIDGET_THEME_LIGHT =
private val MODE_WIDGET_THEME_DARK = EventFields.String("mode-widget-theme-dark", listOf("TERM", "COLORLESS", "ADVANCED CUSTOMIZATION")) EventFields.String("mode-widget-theme-light", listOf("TERM", "COLORLESS", "ADVANCED CUSTOMIZATION"))
private val MODE_WIDGET_THEME_DARK =
EventFields.String("mode-widget-theme-dark", listOf("TERM", "COLORLESS", "ADVANCED CUSTOMIZATION"))
private val WIDGET: VarargEventId = GROUP.registerVarargEvent( private val WIDGET: VarargEventId = GROUP.registerVarargEvent(
"vim.widget", "vim.widget",

View File

@ -259,7 +259,8 @@ public class ExOutputPanel extends JPanel {
public boolean isAtEnd() { public boolean isAtEnd() {
int val = myScrollPane.getVerticalScrollBar().getValue(); int val = myScrollPane.getVerticalScrollBar().getValue();
return val >= myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount(); return val >=
myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount();
} }
private void positionPanel() { private void positionPanel() {
@ -316,8 +317,10 @@ public class ExOutputPanel extends JPanel {
KeyHandler.getInstance().getKeyStack().dump()); KeyHandler.getInstance().getKeyStack().dump());
} }
KeyHandler.getInstance().getKeyStack().addKeys(keys); KeyHandler.getInstance().getKeyStack().addKeys(keys);
ExecutionContext context = injector.getExecutionContextManager().getEditorExecutionContext(new IjVimEditor(myEditor)); ExecutionContext context =
injector.getApplication().runWriteAction(() -> { VimPlugin.getMacro().playbackKeys(new IjVimEditor(myEditor), context, 1); injector.getExecutionContextManager().getEditorExecutionContext(new IjVimEditor(myEditor));
injector.getApplication().runWriteAction(() -> {
VimPlugin.getMacro().playbackKeys(new IjVimEditor(myEditor), context, 1);
return null; return null;
}); });
} }
@ -342,7 +345,9 @@ public class ExOutputPanel extends JPanel {
int keyCode = e.getKeyCode(); int keyCode = e.getKeyCode();
Character keyChar = e.getKeyChar(); Character keyChar = e.getKeyChar();
int modifiers = e.getModifiersEx(); int modifiers = e.getModifiersEx();
KeyStroke keyStroke = (keyChar == KeyEvent.CHAR_UNDEFINED) ? KeyStroke.getKeyStroke(keyCode, modifiers) : KeyStroke.getKeyStroke(keyChar, modifiers); KeyStroke keyStroke = (keyChar == KeyEvent.CHAR_UNDEFINED)
? KeyStroke.getKeyStroke(keyCode, modifiers)
: KeyStroke.getKeyStroke(keyChar, modifiers);
currentPanel.handleKey(keyStroke); currentPanel.handleKey(keyStroke);
} }
} }

View File

@ -267,7 +267,8 @@ private class HelpLink(
} }
} }
private object ShortcutConflictsSettings : DumbAwareAction(MessageHelper.message("action.settings.text"))/*, LightEditCompatible*/ { private object ShortcutConflictsSettings :
DumbAwareAction(MessageHelper.message("action.settings.text"))/*, LightEditCompatible*/ {
override fun actionPerformed(e: AnActionEvent) { override fun actionPerformed(e: AnActionEvent) {
ShowSettingsUtil.getInstance().showSettingsDialog(e.project, VimEmulationConfigurable::class.java) ShowSettingsUtil.getInstance().showSettingsDialog(e.project, VimEmulationConfigurable::class.java)
} }

View File

@ -120,7 +120,7 @@ internal class VimEmulationConfigurable : Configurable {
} }
} }
return rowsToChange; return rowsToChange
} }
fun addHelpLine(model: VimShortcutConflictsTable.Model) { fun addHelpLine(model: VimShortcutConflictsTable.Model) {

View File

@ -49,7 +49,9 @@ internal object ExEditorKit : DefaultEditorKit() {
val c = key.keyChar val c = key.keyChar
if (c.code > 0) { if (c.code > 0) {
if (target.useHandleKeyFromEx) { if (target.useHandleKeyFromEx) {
val panel = ((injector.commandLine.getActiveCommandLine() as? ExEntryPanel) ?: (injector.modalInput.getCurrentModalInput() as? WrappedAsModalInputExEntryPanel)?.exEntryPanel) ?: return val panel = ((injector.commandLine.getActiveCommandLine() as? ExEntryPanel)
?: (injector.modalInput.getCurrentModalInput() as? WrappedAsModalInputExEntryPanel)?.exEntryPanel)
?: return
val entry = panel.entry val entry = panel.entry
val editor = entry.editor val editor = entry.editor
val keyHandler = KeyHandler.getInstance() val keyHandler = KeyHandler.getInstance()

View File

@ -88,11 +88,8 @@ public class ExEntryPanel extends JPanel implements VimCommandLine {
add(entry); add(entry);
// This does not need to be unregistered, it's registered as a custom UI property on this // This does not need to be unregistered, it's registered as a custom UI property on this
EventFacade.getInstance().registerCustomShortcutSet( EventFacade.getInstance().registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(
VimShortcutKeyAction.getInstance(), ((VimKeyGroupBase)injector.getKeyGroup()).getRequiredShortcutKeys()), entry);
toShortcutSet(((VimKeyGroupBase) injector.getKeyGroup()).getRequiredShortcutKeys()),
entry
);
new ExShortcutKeyAction(this).registerCustomShortcutSet(); new ExShortcutKeyAction(this).registerCustomShortcutSet();
updateUI(); updateUI();
@ -148,7 +145,8 @@ public class ExEntryPanel extends JPanel implements VimCommandLine {
public void setEditor(@Nullable Editor editor) { public void setEditor(@Nullable Editor editor) {
if (editor == null) { if (editor == null) {
weakEditor = null; weakEditor = null;
} else { }
else {
weakEditor = new WeakReference<>(editor); weakEditor = new WeakReference<>(editor);
} }
} }

View File

@ -72,17 +72,20 @@ class ExEntryPanelService : VimCommandLineServiceBase(), VimModalInputService {
commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) commandLine.deactivate(refocusOwningEditor = true, resetCaret = true)
false false
} }
key.keyCode == KeyEvent.VK_ENTER -> { key.keyCode == KeyEvent.VK_ENTER -> {
text = commandLine.actualText text = commandLine.actualText
commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) commandLine.deactivate(refocusOwningEditor = true, resetCaret = true)
false false
} }
finishOn != null && key.keyChar == finishOn -> { finishOn != null && key.keyChar == finishOn -> {
commandLine.handleKey(key) commandLine.handleKey(key)
text = commandLine.actualText text = commandLine.actualText
commandLine.deactivate(refocusOwningEditor = true, resetCaret = true) commandLine.deactivate(refocusOwningEditor = true, resetCaret = true)
false false
} }
else -> { else -> {
commandLine.handleKey(key) commandLine.handleKey(key)
true true
@ -126,7 +129,12 @@ class ExEntryPanelService : VimCommandLineServiceBase(), VimModalInputService {
panel.activate(editor.ij, context.ij, prompt, "") panel.activate(editor.ij, context.ij, prompt, "")
} }
override fun createPanel(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine { override fun createPanel(
editor: VimEditor,
context: ExecutionContext,
label: String,
initText: String,
): VimCommandLine {
val panel = ExEntryPanel.getInstance() val panel = ExEntryPanel.getInstance()
panel.activate(editor.ij, context.ij, label, initText) panel.activate(editor.ij, context.ij, label, initText)
return panel return panel
@ -137,10 +145,16 @@ class ExEntryPanelService : VimCommandLineServiceBase(), VimModalInputService {
} }
override fun getCurrentModalInput(): VimModalInput? { override fun getCurrentModalInput(): VimModalInput? {
return ExEntryPanel.getInstanceWithoutShortcuts()?.takeIf { it.isActive && it.inputInterceptor != null }?.let { WrappedAsModalInputExEntryPanel(it) } return ExEntryPanel.getInstanceWithoutShortcuts()?.takeIf { it.isActive && it.inputInterceptor != null }
?.let { WrappedAsModalInputExEntryPanel(it) }
} }
override fun create(editor: VimEditor, context: ExecutionContext, label: String, inputInterceptor: VimInputInterceptor<*>): VimModalInput { override fun create(
editor: VimEditor,
context: ExecutionContext,
label: String,
inputInterceptor: VimInputInterceptor<*>,
): VimModalInput {
val panel = ExEntryPanel.getInstanceWithoutShortcuts() val panel = ExEntryPanel.getInstanceWithoutShortcuts()
panel.inputInterceptor = inputInterceptor panel.inputInterceptor = inputInterceptor
panel.activate(editor.ij, context.ij, label, "") panel.activate(editor.ij, context.ij, label, "")
@ -151,7 +165,9 @@ class ExEntryPanelService : VimCommandLineServiceBase(), VimModalInputService {
internal class WrappedAsModalInputExEntryPanel(internal val exEntryPanel: ExEntryPanel) : VimModalInputBase() { internal class WrappedAsModalInputExEntryPanel(internal val exEntryPanel: ExEntryPanel) : VimModalInputBase() {
override var inputInterceptor: VimInputInterceptor<*> override var inputInterceptor: VimInputInterceptor<*>
get() = exEntryPanel.inputInterceptor!! get() = exEntryPanel.inputInterceptor!!
set(value) { exEntryPanel.inputInterceptor = value } set(value) {
exEntryPanel.inputInterceptor = value
}
override val caret: VimCommandLineCaret = exEntryPanel.caret override val caret: VimCommandLineCaret = exEntryPanel.caret
override val label: String = exEntryPanel.label override val label: String = exEntryPanel.label

View File

@ -239,14 +239,16 @@ public class ExTextField extends JTextField {
// This gets called for ALL events, before the IDE starts to process key events for the action system. We can add a // This gets called for ALL events, before the IDE starts to process key events for the action system. We can add a
// dispatcher that checks that the plugin is enabled, checks that the component with the focus is ExTextField, // dispatcher that checks that the plugin is enabled, checks that the component with the focus is ExTextField,
// dispatch to ExEntryPanel#handleKey and if it's processed, mark the event as consumed. // dispatch to ExEntryPanel#handleKey and if it's processed, mark the event as consumed.
KeyEvent event = new KeyEvent(this, keyChar != KeyEvent.CHAR_UNDEFINED ? KeyEvent.KEY_TYPED : KeyEvent event = new KeyEvent(this, keyChar != KeyEvent.CHAR_UNDEFINED
(stroke.isOnKeyRelease() ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED), ? KeyEvent.KEY_TYPED
: (stroke.isOnKeyRelease() ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED),
(new Date()).getTime(), modifiers, keyCode, c); (new Date()).getTime(), modifiers, keyCode, c);
useHandleKeyFromEx = false; useHandleKeyFromEx = false;
try { try {
super.processKeyEvent(event); super.processKeyEvent(event);
} finally { }
finally {
useHandleKeyFromEx = true; useHandleKeyFromEx = true;
} }
} }
@ -311,7 +313,8 @@ public class ExTextField extends JTextField {
} }
private void resetCaret() { private void resetCaret() {
if (getCaretPosition() == super.getText().length() || currentActionPromptCharacterOffset == super.getText().length() - 1) { if (getCaretPosition() == super.getText().length() ||
currentActionPromptCharacterOffset == super.getText().length() - 1) {
setNormalModeCaret(); setNormalModeCaret();
} }
else { else {
@ -417,7 +420,9 @@ public class ExTextField extends JTextField {
final float outlineThickness = (float)PaintUtil.alignToInt(1.0, g2d); final float outlineThickness = (float)PaintUtil.alignToInt(1.0, g2d);
final double caretWidth = getCaretWidth(fm, r.getX(), 100); final double caretWidth = getCaretWidth(fm, r.getX(), 100);
final Area area = new Area(new Rectangle2D.Double(r.getX(), r.getY(), caretWidth, r.getHeight())); final Area area = new Area(new Rectangle2D.Double(r.getX(), r.getY(), caretWidth, r.getHeight()));
area.subtract(new Area(new Rectangle2D.Double(r.getX() + outlineThickness, r.getY() + outlineThickness, caretWidth - (2 * outlineThickness), r.getHeight() - (2 * outlineThickness)))); area.subtract(new Area(new Rectangle2D.Double(r.getX() + outlineThickness, r.getY() + outlineThickness,
caretWidth - (2 * outlineThickness),
r.getHeight() - (2 * outlineThickness))));
g2d.fill(area); g2d.fill(area);
} }
else { else {

View File

@ -148,14 +148,20 @@ class ModeWidgetPopup : AnAction() {
val panel = panel { val panel = panel {
lateinit var advancedSettings: Cell<JBCheckBox> lateinit var advancedSettings: Cell<JBCheckBox>
row { row {
advancedSettings = checkBox(MessageHelper.getMessage("widget.mode.popup.field.advanced.settings")).bindSelected(modeColors::isFullCustomization) advancedSettings =
checkBox(MessageHelper.getMessage("widget.mode.popup.field.advanced.settings")).bindSelected(modeColors::isFullCustomization)
} }
group { group {
row { row {
label(MessageHelper.getMessage("widget.mode.popup.field.theme")) label(MessageHelper.getMessage("widget.mode.popup.field.theme"))
comboBox(ModeWidgetTheme.entries).bindItem(modeColors::theme.toNullableProperty()) comboBox(ModeWidgetTheme.entries).bindItem(modeColors::theme.toNullableProperty())
} }
row { browserLink("Suggest your theme", "https://youtrack.jetbrains.com/issue/VIM-1377/Normal-mode-needs-to-be-more-obvious") } row {
browserLink(
"Suggest your theme",
"https://youtrack.jetbrains.com/issue/VIM-1377/Normal-mode-needs-to-be-more-obvious"
)
}
}.topGap(TopGap.NONE).visibleIf(!advancedSettings.selected) }.topGap(TopGap.NONE).visibleIf(!advancedSettings.selected)
group(MessageHelper.getMessage("widget.mode.popup.group.title.full.customization")) { group(MessageHelper.getMessage("widget.mode.popup.group.title.full.customization")) {
row { text(MessageHelper.getMessage("widget.mode.popup.color.instruction")) } row { text(MessageHelper.getMessage("widget.mode.popup.color.instruction")) }
@ -279,7 +285,8 @@ class ModeWidgetPopup : AnAction() {
} }
private fun JComponent.addScrollPane(): JComponent { private fun JComponent.addScrollPane(): JComponent {
val scrollPane = JBScrollPane(this, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER) val scrollPane =
JBScrollPane(this, JBScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JBScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
scrollPane.border = BorderFactory.createEmptyBorder() scrollPane.border = BorderFactory.createEmptyBorder()
return scrollPane return scrollPane
} }
@ -339,7 +346,8 @@ class ModeWidgetPopup : AnAction() {
private class VimScopeThemeVariable(private var key: String) : ReadWriteProperty<ModeColors, ModeWidgetTheme> { private class VimScopeThemeVariable(private var key: String) : ReadWriteProperty<ModeColors, ModeWidgetTheme> {
override fun getValue(thisRef: ModeColors, property: KProperty<*>): ModeWidgetTheme { override fun getValue(thisRef: ModeColors, property: KProperty<*>): ModeWidgetTheme {
val themeString = injector.variableService.getVimVariable(key)?.asString() ?: return ModeWidgetTheme.getDefaultTheme() val themeString =
injector.variableService.getVimVariable(key)?.asString() ?: return ModeWidgetTheme.getDefaultTheme()
return ModeWidgetTheme.parseString(themeString) ?: ModeWidgetTheme.getDefaultTheme() return ModeWidgetTheme.parseString(themeString) ?: ModeWidgetTheme.getDefaultTheme()
} }

View File

@ -31,6 +31,7 @@ fun getModeBackground(mode: Mode?): Color {
is Mode.OP_PENDING, null -> UIUtil.getPanelBackground() is Mode.OP_PENDING, null -> UIUtil.getPanelBackground()
} }
} }
ModeWidgetTheme.DRACULA -> { ModeWidgetTheme.DRACULA -> {
return when (mode) { return when (mode) {
Mode.INSERT -> Color.decode("#50FA7B") Mode.INSERT -> Color.decode("#50FA7B")
@ -41,6 +42,7 @@ fun getModeBackground(mode: Mode?): Color {
is Mode.OP_PENDING, null -> UIUtil.getPanelBackground() is Mode.OP_PENDING, null -> UIUtil.getPanelBackground()
} }
} }
ModeWidgetTheme.COLORLESS -> { ModeWidgetTheme.COLORLESS -> {
return UIUtil.getPanelBackground() return UIUtil.getPanelBackground()
} }
@ -55,18 +57,26 @@ fun getModeBackground(mode: Mode?): Color {
val visualModeBackground = injector.variableService.getVimVariable("widget_mode_visual_background$keyPostfix") val visualModeBackground = injector.variableService.getVimVariable("widget_mode_visual_background$keyPostfix")
when (mode.selectionType) { when (mode.selectionType) {
SelectionType.CHARACTER_WISE -> visualModeBackground SelectionType.CHARACTER_WISE -> visualModeBackground
SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_visual_line_background$keyPostfix") ?: visualModeBackground SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_visual_line_background$keyPostfix")
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_visual_block_background$keyPostfix") ?: visualModeBackground ?: visualModeBackground
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_visual_block_background$keyPostfix")
?: visualModeBackground
} }
} }
is Mode.SELECT -> { is Mode.SELECT -> {
val selectModeBackground = injector.variableService.getVimVariable("widget_mode_select_background$keyPostfix") val selectModeBackground = injector.variableService.getVimVariable("widget_mode_select_background$keyPostfix")
when (mode.selectionType) { when (mode.selectionType) {
SelectionType.CHARACTER_WISE -> selectModeBackground SelectionType.CHARACTER_WISE -> selectModeBackground
SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_select_line_background$keyPostfix") ?: selectModeBackground SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_select_line_background$keyPostfix")
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_select_block_background$keyPostfix") ?: selectModeBackground ?: selectModeBackground
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_select_block_background$keyPostfix")
?: selectModeBackground
} }
} }
is Mode.OP_PENDING, null -> null is Mode.OP_PENDING, null -> null
}?.asString() }?.asString()
val defaultColor = UIUtil.getPanelBackground() val defaultColor = UIUtil.getPanelBackground()
@ -77,7 +87,11 @@ fun getModeBackground(mode: Mode?): Color {
if (colorString == null) { if (colorString == null) {
defaultColor defaultColor
} else { } else {
try { Color.decode(colorString) } catch (e: Exception) { defaultColor } try {
Color.decode(colorString)
} catch (e: Exception) {
defaultColor
}
} }
} }
} }
@ -106,18 +120,26 @@ fun getModeForeground(mode: Mode?): Color {
val visualModeBackground = injector.variableService.getVimVariable("widget_mode_visual_foreground$keyPostfix") val visualModeBackground = injector.variableService.getVimVariable("widget_mode_visual_foreground$keyPostfix")
when (mode.selectionType) { when (mode.selectionType) {
SelectionType.CHARACTER_WISE -> visualModeBackground SelectionType.CHARACTER_WISE -> visualModeBackground
SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_visual_line_foreground$keyPostfix") ?: visualModeBackground SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_visual_line_foreground$keyPostfix")
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_visual_block_foreground$keyPostfix") ?: visualModeBackground ?: visualModeBackground
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_visual_block_foreground$keyPostfix")
?: visualModeBackground
} }
} }
is Mode.SELECT -> { is Mode.SELECT -> {
val selectModeBackground = injector.variableService.getVimVariable("widget_mode_select_foreground$keyPostfix") val selectModeBackground = injector.variableService.getVimVariable("widget_mode_select_foreground$keyPostfix")
when (mode.selectionType) { when (mode.selectionType) {
SelectionType.CHARACTER_WISE -> selectModeBackground SelectionType.CHARACTER_WISE -> selectModeBackground
SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_select_line_foreground$keyPostfix") ?: selectModeBackground SelectionType.LINE_WISE -> injector.variableService.getVimVariable("widget_mode_select_line_foreground$keyPostfix")
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_select_block_foreground$keyPostfix") ?: selectModeBackground ?: selectModeBackground
SelectionType.BLOCK_WISE -> injector.variableService.getVimVariable("widget_mode_select_block_foreground$keyPostfix")
?: selectModeBackground
} }
} }
is Mode.OP_PENDING, null -> null is Mode.OP_PENDING, null -> null
}?.asString() }?.asString()
val defaultColor = UIUtil.getLabelForeground() val defaultColor = UIUtil.getLabelForeground()
@ -128,7 +150,11 @@ fun getModeForeground(mode: Mode?): Color {
if (colorString == null) { if (colorString == null) {
defaultColor defaultColor
} else { } else {
try { Color.decode(colorString) } catch (e: Exception) { defaultColor } try {
Color.decode(colorString)
} catch (e: Exception) {
defaultColor
}
} }
} }
} }

View File

@ -29,7 +29,11 @@ internal data class ActionListCommand(val range: Range, val modifier: CommandMod
override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY) override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult { override fun processCommand(
editor: VimEditor,
context: ExecutionContext,
operatorArguments: OperatorArguments,
): ExecutionResult {
val lineSeparator = "\n" val lineSeparator = "\n"
val searchPattern = argument.trim().lowercase(Locale.getDefault()).split("*") val searchPattern = argument.trim().lowercase(Locale.getDefault()).split("*")
val actionManager = ActionManager.getInstance() val actionManager = ActionManager.getInstance()

View File

@ -32,7 +32,11 @@ internal data class BufferCommand(val range: Range, val modifier: CommandModifie
override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY) override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult { override fun processCommand(
editor: VimEditor,
context: ExecutionContext,
operatorArguments: OperatorArguments,
): ExecutionResult {
val overrideModified = modifier == CommandModifier.BANG val overrideModified = modifier == CommandModifier.BANG
val buffer = argument.trim() val buffer = argument.trim()
var result = true var result = true
@ -55,6 +59,7 @@ internal data class BufferCommand(val range: Range, val modifier: CommandModifie
VimPlugin.showMessage(MessageHelper.message("no.matching.buffer.for.0", buffer)) VimPlugin.showMessage(MessageHelper.message("no.matching.buffer.for.0", buffer))
result = false result = false
} }
1 -> { 1 -> {
if (EditorHelper.hasUnsavedChanges(editor.ij) && !overrideModified) { if (EditorHelper.hasUnsavedChanges(editor.ij) && !overrideModified) {
VimPlugin.showMessage(MessageHelper.message("no.write.since.last.change.add.to.override")) VimPlugin.showMessage(MessageHelper.message("no.write.since.last.change.add.to.override"))
@ -63,6 +68,7 @@ internal data class BufferCommand(val range: Range, val modifier: CommandModifie
VimPlugin.getFile().openFile(EditorHelper.getVirtualFile(editors[0].ij)!!.name, context) VimPlugin.getFile().openFile(EditorHelper.getVirtualFile(editors[0].ij)!!.name, context)
} }
} }
else -> { else -> {
VimPlugin.showMessage(MessageHelper.message("more.than.one.match.for.0", buffer)) VimPlugin.showMessage(MessageHelper.message("more.than.one.match.for.0", buffer))
result = false result = false

View File

@ -42,7 +42,11 @@ internal data class BufferListCommand(val range: Range, val modifier: CommandMod
val SUPPORTED_FILTERS = setOf('+', '=', 'a', '%', '#') val SUPPORTED_FILTERS = setOf('+', '=', 'a', '%', '#')
} }
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult { override fun processCommand(
editor: VimEditor,
context: ExecutionContext,
operatorArguments: OperatorArguments,
): ExecutionResult {
val arg = argument.trim() val arg = argument.trim()
val filter = pruneUnsupportedFilters(arg) val filter = pruneUnsupportedFilters(arg)
val bufferList = getBufferList(context, filter) val bufferList = getBufferList(context, filter)

View File

@ -29,12 +29,16 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :!" * see "h :!"
*/ */
@ExCommand(command = "!") @ExCommand(command = "!")
internal data class CmdFilterCommand(val range: Range, val modifier: CommandModifier, val argument: String) internal data class CmdFilterCommand(val range: Range, val modifier: CommandModifier, val argument: String) :
: Command.SingleExecution(range, modifier) { Command.SingleExecution(range, modifier) {
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED) override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult { override fun processCommand(
editor: VimEditor,
context: ExecutionContext,
operatorArguments: OperatorArguments,
): ExecutionResult {
logger.debug("execute") logger.debug("execute")
val command = buildString { val command = buildString {
var inBackslash = false var inBackslash = false
@ -48,6 +52,7 @@ internal data class CmdFilterCommand(val range: Range, val modifier: CommandModi
} }
append(last) append(last)
} }
!inBackslash && c == '%' -> { !inBackslash && c == '%' -> {
val virtualFile = EditorHelper.getVirtualFile(editor.ij) val virtualFile = EditorHelper.getVirtualFile(editor.ij)
if (virtualFile == null) { if (virtualFile == null) {
@ -60,6 +65,7 @@ internal data class CmdFilterCommand(val range: Range, val modifier: CommandModi
} }
append(virtualFile.path) append(virtualFile.path)
} }
else -> append(c) else -> append(c)
} }

View File

@ -29,7 +29,11 @@ internal data class HelpCommand(val range: Range, val modifier: CommandModifier,
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY) override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult { override fun processCommand(
editor: VimEditor,
context: ExecutionContext,
operatorArguments: OperatorArguments,
): ExecutionResult {
BrowserUtil.browse(helpTopicUrl(argument)) BrowserUtil.browse(helpTopicUrl(argument))
return ExecutionResult.Success return ExecutionResult.Success
} }

View File

@ -14,5 +14,6 @@ import com.maddyhome.idea.vim.vimscript.model.functions.IntellijFunctionProvider
import com.maddyhome.idea.vim.vimscript.model.functions.VimscriptFunctionProvider import com.maddyhome.idea.vim.vimscript.model.functions.VimscriptFunctionProvider
internal class FunctionStorage : VimScriptFunctionServiceBase() { internal class FunctionStorage : VimScriptFunctionServiceBase() {
override val functionProviders: List<VimscriptFunctionProvider> = listOf(EngineFunctionProvider, IntellijFunctionProvider) override val functionProviders: List<VimscriptFunctionProvider> =
listOf(EngineFunctionProvider, IntellijFunctionProvider)
} }

View File

@ -28,9 +28,18 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.Scope
import com.maddyhome.idea.vim.vimscript.model.expressions.Variable import com.maddyhome.idea.vim.vimscript.model.expressions.Variable
import org.jdom.Element import org.jdom.Element
@State(name = "VimVariables", storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]) @State(
name = "VimVariables",
storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]
)
internal class IjVariableService : VimVariableServiceBase(), PersistentStateComponent<Element?> { internal class IjVariableService : VimVariableServiceBase(), PersistentStateComponent<Element?> {
override fun storeVariable(variable: Variable, value: VimDataType, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext) { override fun storeVariable(
variable: Variable,
value: VimDataType,
editor: VimEditor,
context: ExecutionContext,
vimContext: VimLContext,
) {
super.storeVariable(variable, value, editor, context, vimContext) super.storeVariable(variable, value, editor, context, vimContext)
val scope = variable.scope ?: getDefaultVariableScope(vimContext) val scope = variable.scope ?: getDefaultVariableScope(vimContext)
@ -92,6 +101,7 @@ internal class IjVariableService : VimVariableServiceBase(), PersistentStateComp
"string" -> { "string" -> {
vimVariables[variableElement.getAttributeValue("key")] = VimString(variableElement.getAttributeValue("value")) vimVariables[variableElement.getAttributeValue("key")] = VimString(variableElement.getAttributeValue("value"))
} }
"int" -> { "int" -> {
vimVariables[variableElement.getAttributeValue("key")] = VimInt(variableElement.getAttributeValue("value")) vimVariables[variableElement.getAttributeValue("key")] = VimInt(variableElement.getAttributeValue("value"))
} }

View File

@ -99,7 +99,8 @@
</aliases> </aliases>
</vimExtension> </vimExtension>
<vimExtension implementation="com.maddyhome.idea.vim.extension.paragraphmotion.ParagraphMotion" name="vim-paragraph-motion"> <vimExtension implementation="com.maddyhome.idea.vim.extension.paragraphmotion.ParagraphMotion"
name="vim-paragraph-motion">
<aliases> <aliases>
<alias name="https://github.com/dbakker/vim-paragraph-motion"/> <alias name="https://github.com/dbakker/vim-paragraph-motion"/>
<alias name="dbakker/vim-paragraph-motion"/> <alias name="dbakker/vim-paragraph-motion"/>

View File

@ -13,5 +13,6 @@
<stop offset="100%" stop-color="#087CFA"/> <stop offset="100%" stop-color="#087CFA"/>
</linearGradient> </linearGradient>
</defs> </defs>
<polygon fill="url(#ideavim_plugin-a)" fill-rule="evenodd" points="28.019 4 15.988 24.119 15.988 4 4 4 4 36 17.953 36 36 4"/> <polygon fill="url(#ideavim_plugin-a)" fill-rule="evenodd"
points="28.019 4 15.988 24.119 15.988 4 4 4 4 36 17.953 36 36 4"/>
</svg> </svg>

Before

(image error) Size: 667 B

After

(image error) Size: 678 B

View File

@ -6,6 +6,7 @@
- https://opensource.org/licenses/MIT. - https://opensource.org/licenses/MIT.
--> -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 40 40" fill-opacity="0" stroke="#6E6E6E" stroke-width="3"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 40 40" fill-opacity="0" stroke="#6E6E6E"
stroke-width="3">
<path d="M 28.019 4 L 15.988 24.119 L 15.988 4 L 4 4 L 4 36 L 17.953 36 L 36 4z"/> <path d="M 28.019 4 L 15.988 24.119 L 15.988 4 L 4 4 L 4 36 L 17.953 36 L 36 4z"/>
</svg> </svg>

Before

(image error) Size: 446 B

After

(image error) Size: 449 B

View File

@ -8,5 +8,6 @@
--> -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26 26" width="16" height="16" fill="#000000"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26 26" width="16" height="16" fill="#000000">
<path fill="#1DA1F2" d="M 25.855469 5.574219 C 24.914063 5.992188 23.902344 6.273438 22.839844 6.402344 C 23.921875 5.75 24.757813 4.722656 25.148438 3.496094 C 24.132813 4.097656 23.007813 4.535156 21.8125 4.769531 C 20.855469 3.75 19.492188 3.113281 17.980469 3.113281 C 15.082031 3.113281 12.730469 5.464844 12.730469 8.363281 C 12.730469 8.773438 12.777344 9.175781 12.867188 9.558594 C 8.503906 9.339844 4.636719 7.246094 2.046875 4.070313 C 1.59375 4.847656 1.335938 5.75 1.335938 6.714844 C 1.335938 8.535156 2.261719 10.140625 3.671875 11.082031 C 2.808594 11.054688 2 10.820313 1.292969 10.425781 C 1.292969 10.449219 1.292969 10.46875 1.292969 10.492188 C 1.292969 13.035156 3.101563 15.15625 5.503906 15.640625 C 5.0625 15.761719 4.601563 15.824219 4.121094 15.824219 C 3.78125 15.824219 3.453125 15.792969 3.132813 15.730469 C 3.800781 17.8125 5.738281 19.335938 8.035156 19.375 C 6.242188 20.785156 3.976563 21.621094 1.515625 21.621094 C 1.089844 21.621094 0.675781 21.597656 0.265625 21.550781 C 2.585938 23.039063 5.347656 23.90625 8.3125 23.90625 C 17.96875 23.90625 23.25 15.90625 23.25 8.972656 C 23.25 8.742188 23.246094 8.515625 23.234375 8.289063 C 24.261719 7.554688 25.152344 6.628906 25.855469 5.574219"/> <path fill="#1DA1F2"
d="M 25.855469 5.574219 C 24.914063 5.992188 23.902344 6.273438 22.839844 6.402344 C 23.921875 5.75 24.757813 4.722656 25.148438 3.496094 C 24.132813 4.097656 23.007813 4.535156 21.8125 4.769531 C 20.855469 3.75 19.492188 3.113281 17.980469 3.113281 C 15.082031 3.113281 12.730469 5.464844 12.730469 8.363281 C 12.730469 8.773438 12.777344 9.175781 12.867188 9.558594 C 8.503906 9.339844 4.636719 7.246094 2.046875 4.070313 C 1.59375 4.847656 1.335938 5.75 1.335938 6.714844 C 1.335938 8.535156 2.261719 10.140625 3.671875 11.082031 C 2.808594 11.054688 2 10.820313 1.292969 10.425781 C 1.292969 10.449219 1.292969 10.46875 1.292969 10.492188 C 1.292969 13.035156 3.101563 15.15625 5.503906 15.640625 C 5.0625 15.761719 4.601563 15.824219 4.121094 15.824219 C 3.78125 15.824219 3.453125 15.792969 3.132813 15.730469 C 3.800781 17.8125 5.738281 19.335938 8.035156 19.375 C 6.242188 20.785156 3.976563 21.621094 1.515625 21.621094 C 1.089844 21.621094 0.675781 21.597656 0.265625 21.550781 C 2.585938 23.039063 5.347656 23.90625 8.3125 23.90625 C 17.96875 23.90625 23.25 15.90625 23.25 8.972656 C 23.25 8.742188 23.246094 8.515625 23.234375 8.289063 C 24.261719 7.554688 25.152344 6.628906 25.855469 5.574219"/>
</svg> </svg>

Before

(image error) Size: 1.6 KiB

After

(image error) Size: 1.6 KiB

View File

@ -159,14 +159,16 @@ class MacroActionTest : VimTestCase() {
) )
assertRegister('b', "6@a") assertRegister('b', "6@a")
assertState(""" assertState(
"""
Lorem Ipsum Lorem Ipsum
Lorem ipsum dolor ${c}sit amet, Lorem ipsum dolor ${c}sit amet,
consectetur adipiscing elit consectetur adipiscing elit
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent()) """.trimIndent()
)
} }
@Test @Test
@ -191,14 +193,16 @@ class MacroActionTest : VimTestCase() {
assertRegister('b', "3@a") assertRegister('b', "3@a")
assertRegister('c', "2@b") assertRegister('c', "2@b")
assertState(""" assertState(
"""
Lorem Ipsum Lorem Ipsum
Lorem ipsum dolor ${c}sit amet, Lorem ipsum dolor ${c}sit amet,
consectetur adipiscing elit consectetur adipiscing elit
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent()) """.trimIndent()
)
} }
@Test @Test

View File

@ -45,7 +45,10 @@ class MacroWithEditingTest : VimTestCase() {
typeTextInFile(injector.parser.parseKeys("^v\$h\"wy"), "\u0001") typeTextInFile(injector.parser.parseKeys("^v\$h\"wy"), "\u0001")
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
kotlin.test.assertEquals(injector.parser.parseKeys("<C-A>"), injector.registerGroup.getRegister(vimEditor, context, 'w')!!.keys) kotlin.test.assertEquals(
injector.parser.parseKeys("<C-A>"),
injector.registerGroup.getRegister(vimEditor, context, 'w')!!.keys
)
setText("1") setText("1")
typeText(injector.parser.parseKeys("@w")) typeText(injector.parser.parseKeys("@w"))
waitAndAssert { waitAndAssert {

View File

@ -2181,7 +2181,14 @@ rtyfg${c}hzxc"""
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
injector.registerGroup.storeText(vimEditor, context, '*', "fgh") injector.registerGroup.storeText(vimEditor, context, '*', "fgh")
VimPlugin.getRegister() VimPlugin.getRegister()
.storeText(IjVimEditor(editor), context, editor.vim.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false) .storeText(
IjVimEditor(editor),
context,
editor.vim.primaryCaret(),
TextRange(16, 19),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("\"*P")) typeText(injector.parser.parseKeys("\"*P"))
val after = "fg${c}hqfg${c}hwe asd zxc rty fg${c}hfgh vbn" val after = "fg${c}hqfg${c}hwe asd zxc rty fg${c}hfgh vbn"
assertState(after) assertState(after)

View File

@ -29,77 +29,93 @@ class OperatorActionTest : VimTestCase() {
@Test @Test
fun `test operator action with function name`() { fun `test operator action with function name`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"xxxxx ipsum dolor sit amet" "xxxxx ipsum dolor sit amet"
) { ) {
executeVimscript("""function! Redact(type) executeVimscript(
"""function! Redact(type)
| execute "normal `[v`]rx" | execute "normal `[v`]rx"
|endfunction |endfunction
""".trimMargin()) """.trimMargin()
)
enterCommand("noremap gx :set opfunc=Redact<CR>g@") enterCommand("noremap gx :set opfunc=Redact<CR>g@")
} }
} }
@Test @Test
fun `test operator action with character wise motion`() { fun `test operator action with character wise motion`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"charlorem ipsum dolor sit amet" "charlorem ipsum dolor sit amet"
) { ) {
executeVimscript("""function! Redact(type) executeVimscript(
"""function! Redact(type)
| execute "normal i" . a:type | execute "normal i" . a:type
|endfunction |endfunction
""".trimMargin()) """.trimMargin()
)
enterCommand("noremap gx :set opfunc=Redact<CR>g@") enterCommand("noremap gx :set opfunc=Redact<CR>g@")
} }
} }
@Test @Test
fun `test operator action with linewise motion`() { fun `test operator action with linewise motion`() {
doTest("Vgx", doTest(
"Vgx",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"linelorem ipsum dolor sit amet" "linelorem ipsum dolor sit amet"
) { ) {
executeVimscript("""function! Redact(type) executeVimscript(
"""function! Redact(type)
| execute "normal i" . a:type | execute "normal i" . a:type
|endfunction |endfunction
""".trimMargin()) """.trimMargin()
)
enterCommand("noremap gx <Esc>:set opfunc=Redact<CR>gvg@") enterCommand("noremap gx <Esc>:set opfunc=Redact<CR>gvg@")
} }
} }
@Test @Test
fun `test operator action with blockwise motion`() { fun `test operator action with blockwise motion`() {
doTest("<C-V>gx", doTest(
"<C-V>gx",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"blocklorem ipsum dolor sit amet" "blocklorem ipsum dolor sit amet"
) { ) {
executeVimscript("""function! Redact(type) executeVimscript(
"""function! Redact(type)
| execute "normal i" . a:type | execute "normal i" . a:type
|endfunction |endfunction
""".trimMargin()) """.trimMargin()
)
enterCommand("noremap gx <Esc>:set opfunc=Redact<CR>gvg@") enterCommand("noremap gx <Esc>:set opfunc=Redact<CR>gvg@")
} }
} }
@Test @Test
fun `test operator action with function`() { fun `test operator action with function`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"xxxxx ipsum dolor sit amet" "xxxxx ipsum dolor sit amet"
) { ) {
executeVimscript("""function! Redact(type) executeVimscript(
"""function! Redact(type)
| execute "normal `[v`]rx" | execute "normal `[v`]rx"
|endfunction |endfunction
""".trimMargin()) """.trimMargin()
)
enterCommand("noremap gx :set opfunc=function('Redact')<CR>g@") enterCommand("noremap gx :set opfunc=function('Redact')<CR>g@")
} }
} }
@Test @Test
fun `test operator action throws error with unknown function`() { fun `test operator action throws error with unknown function`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"lorem ipsum dolor sit amet" "lorem ipsum dolor sit amet"
) { ) {
@ -110,21 +126,25 @@ class OperatorActionTest : VimTestCase() {
@Test @Test
fun `test operator function with funcref`() { fun `test operator function with funcref`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"xxxxx ipsum dolor sit amet" "xxxxx ipsum dolor sit amet"
) { ) {
executeVimscript("""function! Redact(type) executeVimscript(
"""function! Redact(type)
| execute "normal `[v`]rx" | execute "normal `[v`]rx"
|endfunction |endfunction
""".trimMargin()) """.trimMargin()
)
enterCommand("noremap gx :set opfunc=funcref('Redact')<CR>g@") enterCommand("noremap gx :set opfunc=funcref('Redact')<CR>g@")
} }
} }
@Test @Test
fun `test operator action throws error with unknown function ref`() { fun `test operator action throws error with unknown function ref`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"lorem ipsum dolor sit amet" "lorem ipsum dolor sit amet"
) { ) {
@ -140,7 +160,8 @@ class OperatorActionTest : VimTestCase() {
// The map command is properly handled - the `<CR>g@` is correctly understood, and the full lambda is passed to the // The map command is properly handled - the `<CR>g@` is correctly understood, and the full lambda is passed to the
// parser, but the parser does not fully handle the text // parser, but the parser does not fully handle the text
fun `test operator function with lambda`() { fun `test operator function with lambda`() {
doTest("gxe", doTest(
"gxe",
"lorem ipsum dolor sit amet", "lorem ipsum dolor sit amet",
"lorem ipsum dolor sit amet" "lorem ipsum dolor sit amet"
) { ) {

View File

@ -351,7 +351,8 @@ class RepeatChangeActionTest : VimTestCase() {
@Test @Test
@TestFor(issues = ["VIM-481"]) @TestFor(issues = ["VIM-481"])
fun `test dot after overwrite mode`() { fun `test dot after overwrite mode`() {
configureByText(""" configureByText(
"""
/** /**
* @param array ${'$'}arr_footers * @param array ${'$'}arr_footers
* @param array ${'$'}arr_totals_data * @param array ${'$'}arr_totals_data
@ -361,9 +362,11 @@ class RepeatChangeActionTest : VimTestCase() {
* *
* @return array * @return array
*/ */
""".trimIndent()) """.trimIndent()
)
typeText("Rarray<C-[>", "jgell.") typeText("Rarray<C-[>", "jgell.")
assertState(""" assertState(
"""
/** /**
* @param array ${'$'}arr_footers * @param array ${'$'}arr_footers
* @param array ${'$'}arr_totals_data * @param array ${'$'}arr_totals_data
@ -373,6 +376,7 @@ class RepeatChangeActionTest : VimTestCase() {
* *
* @return array * @return array
*/ */
""".trimIndent()) """.trimIndent()
)
} }
} }

View File

@ -198,12 +198,14 @@ Mode.INSERT,
// VIM-3729 // VIM-3729
@Test @Test
fun `test change with count applies only to motion when repeated`() { fun `test change with count applies only to motion when repeated`() {
doTest(listOf("2c3l", "foo<Esc>", "w", "."), doTest(
listOf("2c3l", "foo<Esc>", "w", "."),
""" """
banana banana banana banana
""".trimIndent(), """.trimIndent(),
""" """
foo foo foo foo
""".trimIndent()) """.trimIndent()
)
} }
} }

View File

@ -34,7 +34,14 @@ class IdeaPutNotificationsTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("p")) typeText(injector.parser.parseKeys("p"))
val notification = notifications().last() val notification = notifications().last()
@ -55,7 +62,14 @@ class IdeaPutNotificationsTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("p")) typeText(injector.parser.parseKeys("p"))
val notifications = notifications() val notifications = notifications()
@ -74,7 +88,14 @@ class IdeaPutNotificationsTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("p")) typeText(injector.parser.parseKeys("p"))
val notifications = EventLog.getLogModel(fixture.project).notifications val notifications = EventLog.getLogModel(fixture.project).notifications

View File

@ -88,7 +88,14 @@ class PutTestAfterCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("p")) typeText(injector.parser.parseKeys("p"))
val after = """ val after = """
A Discovery A Discovery
@ -161,7 +168,14 @@ class PutTestAfterCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("vep")) typeText(injector.parser.parseKeys("vep"))
val after = """ val after = """
A Discovery A Discovery

View File

@ -33,7 +33,14 @@ class PutTextBeforeCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "P")) typeText(injector.parser.parseKeys("V" + "P"))
typeText(injector.parser.parseKeys("V" + "P")) typeText(injector.parser.parseKeys("V" + "P"))
val after = """ val after = """

View File

@ -58,7 +58,14 @@ class PutViaIdeaTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText("ppp") typeText("ppp")
val after = "Ilegendarylegendarylegendar${c}y found it in a legendary land" val after = "Ilegendarylegendarylegendar${c}y found it in a legendary land"

View File

@ -78,7 +78,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "p")) typeText(injector.parser.parseKeys("ve" + "p"))
val after = "legendar${c}y it in a legendary land" val after = "legendar${c}y it in a legendary land"
assertState(after) assertState(after)
@ -94,7 +101,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("v2e" + "2p")) typeText(injector.parser.parseKeys("v2e" + "2p"))
val after = "legendarylegendar${c}y in a legendary land" val after = "legendarylegendar${c}y in a legendary land"
assertState(after) assertState(after)
@ -110,7 +124,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("v$" + "2p")) typeText(injector.parser.parseKeys("v$" + "2p"))
val after = "legendarylegendar${c}y" val after = "legendarylegendar${c}y"
assertState(after) assertState(after)
@ -152,7 +173,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "legendary", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "legendary",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("vb" + "p")) typeText(injector.parser.parseKeys("vb" + "p"))
val after = "I legendar${c}y it in a legendary land" val after = "I legendar${c}y it in a legendary land"
assertState(after) assertState(after)
@ -177,7 +205,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "p")) typeText(injector.parser.parseKeys("ve" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -209,7 +244,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "p")) typeText(injector.parser.parseKeys("ve" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -241,7 +283,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "p")) typeText(injector.parser.parseKeys("ve" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -273,7 +322,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("v$" + "p")) typeText(injector.parser.parseKeys("v$" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -506,7 +562,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "p")) typeText(injector.parser.parseKeys("ve" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -546,7 +609,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "p")) typeText(injector.parser.parseKeys("ve" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -588,7 +658,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("ve" + "2p")) typeText(injector.parser.parseKeys("ve" + "2p"))
val after = """ val after = """
A Discovery A Discovery
@ -707,7 +784,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "p")) typeText(injector.parser.parseKeys("V" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -737,7 +821,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "2p")) typeText(injector.parser.parseKeys("V" + "2p"))
val after = """ val after = """
A Discovery A Discovery
@ -778,7 +869,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "p")) typeText(injector.parser.parseKeys("V" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -963,7 +1061,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "p")) typeText(injector.parser.parseKeys("V" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -993,7 +1098,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "2p")) typeText(injector.parser.parseKeys("V" + "2p"))
val after = """ val after = """
A Discovery A Discovery
@ -1034,7 +1146,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "p")) typeText(injector.parser.parseKeys("V" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1224,7 +1343,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "p")) typeText(injector.parser.parseKeys("V" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1283,7 +1409,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "p")) typeText(injector.parser.parseKeys("V" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1348,7 +1481,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "2p")) typeText(injector.parser.parseKeys("V" + "2p"))
val after = """ val after = """
A Discovery A Discovery
@ -1532,7 +1672,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e2j" + "p")) typeText(injector.parser.parseKeys("<C-V>2e2j" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1562,7 +1709,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>3e2k" + "p")) typeText(injector.parser.parseKeys("<C-V>3e2k" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1592,7 +1746,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e2j" + "2p")) typeText(injector.parser.parseKeys("<C-V>2e2j" + "2p"))
val after = """ val after = """
A Discovery A Discovery
@ -1622,7 +1783,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "Discovery",
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>3j$" + "p")) typeText(injector.parser.parseKeys("<C-V>3j$" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1665,7 +1833,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e2j" + "p")) typeText(injector.parser.parseKeys("<C-V>2e2j" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1697,7 +1872,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e2j" + "P")) typeText(injector.parser.parseKeys("<C-V>2e2j" + "P"))
val after = """ val after = """
A Discovery A Discovery
@ -1740,7 +1922,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e2j" + "2p")) typeText(injector.parser.parseKeys("<C-V>2e2j" + "2p"))
val after = """ val after = """
A Discovery A Discovery
@ -1784,7 +1973,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e3j" + "p")) typeText(injector.parser.parseKeys("<C-V>2e3j" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1827,7 +2023,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
before rangeOf "A Discovery\n",
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2j$" + "p")) typeText(injector.parser.parseKeys("<C-V>2j$" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1866,7 +2069,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e2j" + "p")) typeText(injector.parser.parseKeys("<C-V>2e2j" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1906,7 +2116,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2e3j" + "p")) typeText(injector.parser.parseKeys("<C-V>2e3j" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1946,7 +2163,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2ej" + "p")) typeText(injector.parser.parseKeys("<C-V>2ej" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -1985,7 +2209,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>elj" + "p")) typeText(injector.parser.parseKeys("<C-V>elj" + "p"))
val after = """ val after = """
A Discovery A Discovery
@ -2026,7 +2257,14 @@ class PutVisualTextActionTest : VimTestCase() {
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
editor.rangeOf("|found|", 2),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("<C-V>2j$" + "p")) typeText(injector.parser.parseKeys("<C-V>2j$" + "p"))
val after = """ val after = """
A Discovery A Discovery

View File

@ -34,7 +34,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("v2e" + "2gp")) typeText(injector.parser.parseKeys("v2e" + "2gp"))
val after = "legendarylegendary$c in a legendary land" val after = "legendarylegendary$c in a legendary land"
assertState(after) assertState(after)
@ -48,7 +55,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("v2e" + "gp")) typeText(injector.parser.parseKeys("v2e" + "gp"))
val after = """ val after = """
@ -66,7 +80,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "gp")) typeText(injector.parser.parseKeys("V" + "gp"))
val after = "legendary\n$c" val after = "legendary\n$c"
assertState(after) assertState(after)
@ -95,7 +116,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(2, 11), SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(2, 11),
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "gp")) typeText(injector.parser.parseKeys("V" + "gp"))
assertState(newFile) assertState(newFile)
} }
@ -143,7 +171,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("v2e" + "gP")) typeText(injector.parser.parseKeys("v2e" + "gP"))
val after = """ val after = """
@ -161,7 +196,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("v2e" + "2gP")) typeText(injector.parser.parseKeys("v2e" + "2gP"))
val after = "legendarylegendary$c in a legendary land" val after = "legendarylegendary$c in a legendary land"
assertState(after) assertState(after)
@ -175,7 +217,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("v$" + "2gP")) typeText(injector.parser.parseKeys("v$" + "2gP"))
val after = "legendarylegendar${c}y" val after = "legendarylegendar${c}y"
assertState(after) assertState(after)
@ -189,7 +238,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 25), SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 25),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("V" + "gP")) typeText(injector.parser.parseKeys("V" + "gP"))
val after = "legendary\n$c" val after = "legendary\n$c"
assertState(after) assertState(after)
@ -294,7 +350,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.BLOCK_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 19),
SelectionType.BLOCK_WISE,
false
)
typeText(injector.parser.parseKeys("<S-v>" + "gp")) typeText(injector.parser.parseKeys("<S-v>" + "gp"))
val after = """ val after = """
${c}fgh ${c}fgh
@ -322,7 +385,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.LINE_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 19),
SelectionType.LINE_WISE,
false
)
typeText(injector.parser.parseKeys("<C-v>" + "h" + "gp")) typeText(injector.parser.parseKeys("<C-v>" + "h" + "gp"))
val after = """ val after = """
q q
@ -345,7 +415,14 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
val vimEditor = editor.vim val vimEditor = editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
registerService.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false) registerService.storeText(
vimEditor,
context,
vimEditor.primaryCaret(),
TextRange(16, 19),
SelectionType.CHARACTER_WISE,
false
)
typeText(injector.parser.parseKeys("v2e" + "2gp")) typeText(injector.parser.parseKeys("v2e" + "2gp"))
val after = "fghfgh$c fghfgh$c fghfgh$c" val after = "fghfgh$c fghfgh$c fghfgh$c"
assertState(after) assertState(after)

View File

@ -64,7 +64,12 @@ class YankAndPutTest : VimTestCase() {
) )
} }
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamedplus + "," + OptionConstants.clipboard_ideaput])) @OptionTest(
VimOption(
TestOptionConstants.clipboard,
limitedValues = [OptionConstants.clipboard_unnamedplus + "," + OptionConstants.clipboard_ideaput]
)
)
fun `test yank to number register with unnamedplus and ideaput`() { fun `test yank to number register with unnamedplus and ideaput`() {
val before = """ val before = """
I ${c}found it in a legendary land I ${c}found it in a legendary land
@ -86,7 +91,12 @@ class YankAndPutTest : VimTestCase() {
) )
} }
@OptionTest(VimOption(TestOptionConstants.clipboard, limitedValues = [OptionConstants.clipboard_unnamed + "," + OptionConstants.clipboard_ideaput])) @OptionTest(
VimOption(
TestOptionConstants.clipboard,
limitedValues = [OptionConstants.clipboard_unnamed + "," + OptionConstants.clipboard_ideaput]
)
)
@TestWithoutPrimaryClipboard @TestWithoutPrimaryClipboard
fun `test yank to number register with unnamed and ideaput`() { fun `test yank to number register with unnamed and ideaput`() {
val before = """ val before = """

View File

@ -28,7 +28,8 @@ class YankMotionActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val text = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val text =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals("and", text) kotlin.test.assertEquals("and", text)
} }
@ -127,7 +128,8 @@ class YankMotionActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val text = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val text =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals("", text) kotlin.test.assertEquals("", text)
} }
@ -147,7 +149,8 @@ class YankMotionActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val text = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val text =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals("legendary", text) kotlin.test.assertEquals("legendary", text)
} }
@ -185,7 +188,8 @@ class YankMotionActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val text = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val text =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals("hard by the torrent of a mountain pass.\n", text) kotlin.test.assertEquals("hard by the torrent of a mountain pass.\n", text)
} }

View File

@ -38,7 +38,8 @@ class YankVisualLinesActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val savedText = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val savedText =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals(yankedTest, savedText) kotlin.test.assertEquals(yankedTest, savedText)
} }
@ -69,7 +70,8 @@ class YankVisualLinesActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val savedText = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val savedText =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals(yankedTest, savedText) kotlin.test.assertEquals(yankedTest, savedText)
} }
@ -93,7 +95,8 @@ class YankVisualLinesActionTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val registerService = injector.registerGroup val registerService = injector.registerGroup
val savedText = registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail() val savedText =
registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text ?: kotlin.test.fail()
kotlin.test.assertEquals(yankedTest, savedText) kotlin.test.assertEquals(yankedTest, savedText)
} }
} }

View File

@ -146,7 +146,7 @@ class MotionDownActionTest : VimTestCase() {
wh|ere it was settled on some sodden sand[additional Chars] wh|ere it was settled on some sodden sand[additional Chars]
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
val after = """ """
A Discovery A Discovery
I |${s}found it in a legendary lan${c}d${se} I |${s}found it in a legendary lan${c}d${se}
@ -172,7 +172,7 @@ class MotionDownActionTest : VimTestCase() {
wh|ere it was settled on some sodden sand[additional Chars] wh|ere it was settled on some sodden sand[additional Chars]
hard by the torrent of a mountain pass. hard by the torrent of a mountain pass.
""".trimIndent() """.trimIndent()
val after = """ """
A Discovery A Discovery
I |${s}found it in a legendary lan${c}d${se} I |${s}found it in a legendary lan${c}d${se}

View File

@ -343,24 +343,32 @@ class MotionPercentOrMatchActionTest : VimTestCase() {
@Test @Test
@TestFor(issues = ["VIM-3294"]) @TestFor(issues = ["VIM-3294"])
fun `test matching with braces inside of string`() { fun `test matching with braces inside of string`() {
configureByText(""" configureByText(
"""
$c("("")") $c("("")")
""".trimIndent()) """.trimIndent()
)
typeText("%") typeText("%")
assertState(""" assertState(
"""
("("")"$c) ("("")"$c)
""".trimIndent()) """.trimIndent()
)
} }
@Test @Test
@TestFor(issues = ["VIM-3294"]) @TestFor(issues = ["VIM-3294"])
fun `test matching with braces inside of string 2`() { fun `test matching with braces inside of string 2`() {
configureByText(""" configureByText(
"""
("("")"$c) ("("")"$c)
""".trimIndent()) """.trimIndent()
)
typeText("%") typeText("%")
assertState(""" assertState(
"""
$c("("")") $c("("")")
""".trimIndent()) """.trimIndent()
)
} }
} }

View File

@ -19,20 +19,24 @@ class CallCommandTest : VimTestCase() {
d d
endfunction endfunction
""".trimIndent() """.trimIndent()
configureByText(""" configureByText(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
executeVimscript(function) executeVimscript(function)
enterCommand("call DeleteLine()") enterCommand("call DeleteLine()")
assertState(""" assertState(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
${c}Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu ${c}Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
} }
} }

View File

@ -92,9 +92,11 @@ class ClearJumpsCommandTest : VimTestCase() {
enterCommand("clearju") enterCommand("clearju")
enterCommand("jumps") enterCommand("jumps")
assertExOutput(""" assertExOutput(
"""
| jump line col file/text | jump line col file/text
|> |>
""".trimMargin()) """.trimMargin()
)
} }
} }

View File

@ -16,20 +16,24 @@ import org.junit.jupiter.api.Test
class CopyCommandTest : VimTestCase() { class CopyCommandTest : VimTestCase() {
@Test @Test
fun `test duplicate line below`() { fun `test duplicate line below`() {
configureByText(""" configureByText(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
enterCommand("copy .") enterCommand("copy .")
assertState(""" assertState(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
Nunc tincidunt viverra ligula non scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. Nunc tincidunt viverra ligula non scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
${c}Nunc tincidunt viverra ligula non scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. ${c}Nunc tincidunt viverra ligula non scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
} }
@VimBehaviorDiffers( @VimBehaviorDiffers(

View File

@ -15,18 +15,22 @@ import org.junit.jupiter.api.Test
class DeleteLinesCommandTest : VimTestCase() { class DeleteLinesCommandTest : VimTestCase() {
@Test @Test
fun `test delete command without range`() { fun `test delete command without range`() {
configureByText(""" configureByText(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
enterCommand("d") enterCommand("d")
assertState(""" assertState(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
${c}Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu ${c}Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
} }
@Test @Test
@ -431,8 +435,10 @@ class DeleteLinesCommandTest : VimTestCase() {
|Pellentesque orci dolor, tristique quis rutrum non, scelerisque id dui. |Pellentesque orci dolor, tristique quis rutrum non, scelerisque id dui.
""".trimMargin() """.trimMargin()
) )
assertRegister('a', "Morbi nec luctus tortor, id venenatis lacus.^J" + assertRegister(
'a', "Morbi nec luctus tortor, id venenatis lacus.^J" +
"Nunc sit amet tellus vel purus cursus posuere et at purus.^J" + "Nunc sit amet tellus vel purus cursus posuere et at purus.^J" +
"Ut id dapibus augue.^J") "Ut id dapibus augue.^J"
)
} }
} }

View File

@ -117,7 +117,8 @@ class DigraphsCommandTest : VimTestCase() {
// * `LF` is represented by `^@` in Vim, although it's output as a LF. Weird Vim NL/null handling // * `LF` is represented by `^@` in Vim, although it's output as a LF. Weird Vim NL/null handling
// * Additional Unicode control characters to ensure that RTL doesn't affect the rest of the line. We add the RLI // * Additional Unicode control characters to ensure that RTL doesn't affect the rest of the line. We add the RLI
// RIGHT_TO_LEFT_ISOLATE code to start an isolated run of RTL chars, then POP_DIRECTIONAL_ISOLATE to restore // RIGHT_TO_LEFT_ISOLATE code to start an isolated run of RTL chars, then POP_DIRECTIONAL_ISOLATE to restore
assertCommandOutput("digraphs", assertCommandOutput(
"digraphs",
""" """
|NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5 |NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5
|AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11 |AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11
@ -347,12 +348,14 @@ class DigraphsCommandTest : VimTestCase() {
|2c 12833 3c 12834 4c 12835 5c 12836 6c 12837 7c 12838 |2c 12833 3c 12834 4c 12835 5c 12836 6c 12837 7c 12838
|8c 12839 9c 12840 ff 64256 fi 64257 fl 64258 ft 64261 |8c 12839 9c 12840 ff 64256 fi 64257 fl 64258 ft 64261
|st 64262 |st 64262
""".trimMargin()) """.trimMargin()
)
} }
@Test @Test
fun `test digraph output with headers`() { fun `test digraph output with headers`() {
assertCommandOutput("digraphs!", assertCommandOutput(
"digraphs!",
""" """
|NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5 |NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5
|AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11 |AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11
@ -620,13 +623,15 @@ class DigraphsCommandTest : VimTestCase() {
|1c 12832 2c 12833 3c 12834 4c 12835 5c 12836 6c 12837 |1c 12832 2c 12833 3c 12834 4c 12835 5c 12836 6c 12837
|7c 12838 8c 12839 9c 12840 ff 64256 fi 64257 fl 64258 |7c 12838 8c 12839 9c 12840 ff 64256 fi 64257 fl 64258
|ft 64261 st 64262 |ft 64261 st 64262
""".trimMargin()) """.trimMargin()
)
} }
@Test @Test
fun `test digraph output with custom digraphs output in entered order`() { fun `test digraph output with custom digraphs output in entered order`() {
enterCommand("digraphs (0 9450 (2 9313 (1 9312") enterCommand("digraphs (0 9450 (2 9313 (1 9312")
assertCommandOutput("digraphs", assertCommandOutput(
"digraphs",
""" """
|NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5 |NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5
|AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11 |AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11
@ -856,13 +861,15 @@ class DigraphsCommandTest : VimTestCase() {
|2c 12833 3c 12834 4c 12835 5c 12836 6c 12837 7c 12838 |2c 12833 3c 12834 4c 12835 5c 12836 6c 12837 7c 12838
|8c 12839 9c 12840 ff 64256 fi 64257 fl 64258 ft 64261 |8c 12839 9c 12840 ff 64256 fi 64257 fl 64258 ft 64261
|st 64262 (0 9450 (2 9313 (1 9312 |st 64262 (0 9450 (2 9313 (1 9312
""".trimMargin()) """.trimMargin()
)
} }
@Test @Test
fun `test digraph output with headers and custom digraphs`() { fun `test digraph output with headers and custom digraphs`() {
enterCommand("digraphs (0 9450 (2 9313 (1 9312") enterCommand("digraphs (0 9450 (2 9313 (1 9312")
assertCommandOutput("digraphs!", assertCommandOutput(
"digraphs!",
""" """
|NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5 |NU ^@ 10 SH ^A 1 SX ^B 2 EX ^C 3 ET ^D 4 EQ ^E 5
|AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11 |AK ^F 6 BL ^G 7 BS ^H 8 HT ^I 9 LF ^J 10 VT ^K 11
@ -1132,6 +1139,7 @@ class DigraphsCommandTest : VimTestCase() {
|ft 64261 st 64262 |ft 64261 st 64262
|Custom |Custom
|(0 9450 (2 9313 (1 9312 |(0 9450 (2 9313 (1 9312
""".trimMargin()) """.trimMargin()
)
} }
} }

View File

@ -287,9 +287,11 @@ class GlobalCommandTest : VimTestCase() {
initialText, initialText,
initialText, initialText,
) )
assertExOutput(""" assertExOutput(
"""
g/found g/found
I found it in a legendary land""".trimIndent()) I found it in a legendary land""".trimIndent()
)
} }
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT) @TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@ -300,11 +302,13 @@ class GlobalCommandTest : VimTestCase() {
initialText, initialText,
initialText, initialText,
) )
assertExOutput(""" assertExOutput(
"""
|g/it |g/it
|I found it in a legendary land |I found it in a legendary land
|where it was settled on some sodden sand |where it was settled on some sodden sand
""".trimMargin()) """.trimMargin()
)
} }
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT) @TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@ -314,11 +318,13 @@ class GlobalCommandTest : VimTestCase() {
val editor = fixture.editor.vim val editor = fixture.editor.vim
injector.options(editor).number = true injector.options(editor).number = true
typeText(commandToKeys(":g/it")) typeText(commandToKeys(":g/it"))
assertExOutput(""" assertExOutput(
"""
|g/it |g/it
|3 I found it in a legendary land |3 I found it in a legendary land
|5 where it was settled on some sodden sand |5 where it was settled on some sodden sand
""".trimMargin()) """.trimMargin()
)
injector.options(editor).number = false injector.options(editor).number = false
} }
@ -330,9 +336,11 @@ class GlobalCommandTest : VimTestCase() {
initialText, initialText,
initialText, initialText,
) )
assertExOutput(""" assertExOutput(
"""
g/found/ g/found/
I found it in a legendary land""".trimIndent()) I found it in a legendary land""".trimIndent()
)
} }
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT) @TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@ -342,9 +350,11 @@ class GlobalCommandTest : VimTestCase() {
val editor = fixture.editor.vim val editor = fixture.editor.vim
injector.options(editor).number = true injector.options(editor).number = true
typeText(commandToKeys(":g/found/")) typeText(commandToKeys(":g/found/"))
assertExOutput(""" assertExOutput(
"""
g/found/ g/found/
3 I found it in a legendary land""".trimIndent()) 3 I found it in a legendary land""".trimIndent()
)
injector.options(editor).number = false injector.options(editor).number = false
} }

View File

@ -45,19 +45,23 @@ class GotoCharacterCommandTest : VimTestCase() {
@Test @Test
fun `go to 10th character`() { fun `go to 10th character`() {
configureByText(""" configureByText(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. Nunc tincidunt viverra ligula non ${c}scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
enterCommand("goto 10") enterCommand("goto 10")
assertState(""" assertState(
"""
Lorem ips${c}um dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada. Lorem ips${c}um dolor sit amet, consectetur adipiscing elit. Maecenas efficitur nec odio vel malesuada.
Nunc tincidunt viverra ligula non scelerisque. Aliquam erat volutpat. Praesent in fermentum orci. Nunc tincidunt viverra ligula non scelerisque. Aliquam erat volutpat. Praesent in fermentum orci.
Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu Fusce sit amet mi ut purus volutpat vulputate vitae sed tortor. Aliquam felis neque, varius eu
accumsan vitae, facilisis ac nulla. accumsan vitae, facilisis ac nulla.
""".trimIndent()) """.trimIndent()
)
} }
@Test @Test

View File

@ -141,9 +141,10 @@ class LetCommandTest : VimTestCase() {
val localValue = injector.optionGroup.getOptionValue(option, OptionAccessScope.LOCAL(fixture.editor.vim)) val localValue = injector.optionGroup.getOptionValue(option, OptionAccessScope.LOCAL(fixture.editor.vim))
assertEquals(12, globalValue.value) assertEquals(12, globalValue.value)
assertEquals(12, localValue.value) assertEquals(12, localValue.value)
assertTrue(injector.optionGroup.getOptionValue(option, OptionAccessScope.EFFECTIVE(fixture.editor.vim)).asBoolean()) assertTrue(
} injector.optionGroup.getOptionValue(option, OptionAccessScope.EFFECTIVE(fixture.editor.vim)).asBoolean()
finally { )
} finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -161,9 +162,10 @@ class LetCommandTest : VimTestCase() {
val localValue = injector.optionGroup.getOptionValue(option, OptionAccessScope.LOCAL(fixture.editor.vim)) val localValue = injector.optionGroup.getOptionValue(option, OptionAccessScope.LOCAL(fixture.editor.vim))
assertEquals(0, globalValue.value) assertEquals(0, globalValue.value)
assertEquals(12, localValue.value) assertEquals(12, localValue.value)
assertTrue(injector.optionGroup.getOptionValue(option, OptionAccessScope.EFFECTIVE(fixture.editor.vim)).asBoolean()) assertTrue(
} injector.optionGroup.getOptionValue(option, OptionAccessScope.EFFECTIVE(fixture.editor.vim)).asBoolean()
finally { )
} finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -184,8 +186,7 @@ class LetCommandTest : VimTestCase() {
assertFalse( assertFalse(
injector.optionGroup.getOptionValue(option, OptionAccessScope.EFFECTIVE(fixture.editor.vim)).asBoolean() injector.optionGroup.getOptionValue(option, OptionAccessScope.EFFECTIVE(fixture.editor.vim)).asBoolean()
) )
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }

View File

@ -1014,14 +1014,16 @@ class MapCommandTest : VimTestCase() {
) )
enterCommand("map <Enter> <Action>(EditorSelectWord)") enterCommand("map <Enter> <Action>(EditorSelectWord)")
typeText("<Enter>") typeText("<Enter>")
assertState(""" assertState(
"""
Lorem Ipsum Lorem Ipsum
Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet,
${s}${c}consectetur${se} adipiscing elit ${s}${c}consectetur${se} adipiscing elit
Sed in orci mauris. Sed in orci mauris.
Cras id tellus in ex imperdiet egestas. Cras id tellus in ex imperdiet egestas.
""".trimIndent()) """.trimIndent()
)
} }
@TestFor(issues = ["VIM-2929"]) @TestFor(issues = ["VIM-2929"])

View File

@ -64,7 +64,8 @@ class PrintCommandTest : VimTestCase() {
| Cras id tellus in ex imperdiet egestas. | Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
) )
assertExOutput(""" assertExOutput(
"""
| |
| Lorem ipsum dolor sit amet, | Lorem ipsum dolor sit amet,
| consectetur adipiscing elit | consectetur adipiscing elit
@ -79,7 +80,8 @@ class PrintCommandTest : VimTestCase() {
val editor = fixture.editor.vim val editor = fixture.editor.vim
injector.options(editor).number = true injector.options(editor).number = true
typeText(commandToKeys("2,5p")) typeText(commandToKeys("2,5p"))
assertExOutput(""" assertExOutput(
"""
|2 |2
|3 Lorem ipsum dolor sit amet, |3 Lorem ipsum dolor sit amet,
|4 consectetur adipiscing elit |4 consectetur adipiscing elit
@ -103,7 +105,8 @@ class PrintCommandTest : VimTestCase() {
| Cras id tellus in ex imperdiet egestas. | Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
) )
assertExOutput(""" assertExOutput(
"""
| Lorem Ipsum | Lorem Ipsum
| |
| Lorem ipsum dolor sit amet, | Lorem ipsum dolor sit amet,
@ -144,7 +147,8 @@ class PrintCommandTest : VimTestCase() {
| ${c}Cras id tellus in ex imperdiet egestas. | ${c}Cras id tellus in ex imperdiet egestas.
""".trimMargin() """.trimMargin()
) )
assertExOutput(""" assertExOutput(
"""
| Lorem ipsum dolor sit amet, | Lorem ipsum dolor sit amet,
| consectetur adipiscing elit | consectetur adipiscing elit
| Sed in orci mauris. | Sed in orci mauris.

View File

@ -241,7 +241,12 @@ class RegistersCommandTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
injector.registerGroup.saveRegister(vimEditor, context, '+', Register('+', injector.clipboardManager.dumbCopiedText("Lorem ipsum dolor"), SelectionType.LINE_WISE)) injector.registerGroup.saveRegister(
vimEditor,
context,
'+',
Register('+', injector.clipboardManager.dumbCopiedText("Lorem ipsum dolor"), SelectionType.LINE_WISE)
)
val clipboardContent = injector.clipboardManager.dumbCopiedText("clipboard content") val clipboardContent = injector.clipboardManager.dumbCopiedText("clipboard content")
injector.clipboardManager.setClipboardContent(vimEditor, context, clipboardContent) injector.clipboardManager.setClipboardContent(vimEditor, context, clipboardContent)
typeText("V<Esc>") typeText("V<Esc>")
@ -448,7 +453,12 @@ class RegistersCommandTest : VimTestCase() {
val vimEditor = fixture.editor.vim val vimEditor = fixture.editor.vim
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor) val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
val clipboardContent = injector.clipboardManager.dumbCopiedText("clipboard content") val clipboardContent = injector.clipboardManager.dumbCopiedText("clipboard content")
injector.registerGroup.saveRegister(vimEditor, context, '+', Register('+', injector.clipboardManager.dumbCopiedText("Lorem ipsum dolor"), SelectionType.LINE_WISE)) injector.registerGroup.saveRegister(
vimEditor,
context,
'+',
Register('+', injector.clipboardManager.dumbCopiedText("Lorem ipsum dolor"), SelectionType.LINE_WISE)
)
injector.clipboardManager.setClipboardContent(vimEditor, context, clipboardContent) injector.clipboardManager.setClipboardContent(vimEditor, context, clipboardContent)
typeText("V<Esc>") typeText("V<Esc>")

View File

@ -70,14 +70,23 @@ class SetCommandTest : VimTestCase() {
@Test @Test
fun `test toggle option as a number`() { fun `test toggle option as a number`() {
enterCommand("set digraph&") // Local to window. Reset local + per-window "global" value to default: nodigraph enterCommand("set digraph&") // Local to window. Reset local + per-window "global" value to default: nodigraph
assertEquals(0, injector.optionGroup.getOptionValue(Options.digraph, OptionAccessScope.LOCAL(fixture.editor.vim)).asDouble().toInt()) assertEquals(0,
injector.optionGroup.getOptionValue(Options.digraph, OptionAccessScope.LOCAL(fixture.editor.vim)).asDouble()
.toInt()
)
assertCommandOutput("set digraph?", "nodigraph") assertCommandOutput("set digraph?", "nodigraph")
// Should have the same effect as `:set` (although `:set` doesn't allow assigning a number to a boolean) // Should have the same effect as `:set` (although `:set` doesn't allow assigning a number to a boolean)
// I.e. this sets the local value and the per-window "global" value // I.e. this sets the local value and the per-window "global" value
enterCommand("let &dg=1000") enterCommand("let &dg=1000")
assertEquals(1000, injector.optionGroup.getOptionValue(Options.digraph, OptionAccessScope.GLOBAL(fixture.editor.vim)).asDouble().toInt()) assertEquals(1000,
assertEquals(1000, injector.optionGroup.getOptionValue(Options.digraph, OptionAccessScope.LOCAL(fixture.editor.vim)).asDouble().toInt()) injector.optionGroup.getOptionValue(Options.digraph, OptionAccessScope.GLOBAL(fixture.editor.vim)).asDouble()
.toInt()
)
assertEquals(1000,
injector.optionGroup.getOptionValue(Options.digraph, OptionAccessScope.LOCAL(fixture.editor.vim)).asDouble()
.toInt()
)
assertCommandOutput("set digraph?", " digraph") assertCommandOutput("set digraph?", " digraph")
} }
@ -156,19 +165,22 @@ class SetCommandTest : VimTestCase() {
enterCommand("set number relativenumber scrolloff nrformats") enterCommand("set number relativenumber scrolloff nrformats")
assertExOutput(" nrformats=hex scrolloff=0") assertExOutput(" nrformats=hex scrolloff=0")
injector.outputPanel.getCurrentOutputPanel()?.close() injector.outputPanel.getCurrentOutputPanel()?.close()
assertCommandOutput("set", assertCommandOutput(
"set",
""" """
|--- Options --- |--- Options ---
| number relativenumber | number relativenumber
| fileencoding=utf-8 | fileencoding=utf-8
""".trimMargin()) """.trimMargin()
)
} }
@Test @Test
fun `test show all effective option values`() { fun `test show all effective option values`() {
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
setOsSpecificOptionsToSafeValues() setOsSpecificOptionsToSafeValues()
assertCommandOutput("set all", assertCommandOutput(
"set all",
""" """
|--- Options --- |--- Options ---
|noargtextobj ideamarks scroll=0 nosurround |noargtextobj ideamarks scroll=0 nosurround
@ -202,12 +214,14 @@ class SetCommandTest : VimTestCase() {
| shell=/dummy/path/to/bash | shell=/dummy/path/to/bash
|novim-paragraph-motion |novim-paragraph-motion
| viminfo='100,<50,s10,h | viminfo='100,<50,s10,h
""".trimMargin()) """.trimMargin()
)
} }
@Test @Test
fun `test show named options`() { fun `test show named options`() {
assertCommandOutput("set number? relativenumber? scrolloff? nrformats?", """ assertCommandOutput(
"set number? relativenumber? scrolloff? nrformats?", """
| nrformats=hex nonumber norelativenumber scrolloff=0 | nrformats=hex nonumber norelativenumber scrolloff=0
""".trimMargin() """.trimMargin()
) )
@ -223,7 +237,8 @@ class SetCommandTest : VimTestCase() {
enterCommand("set number relativenumber scrolloff nrformats") enterCommand("set number relativenumber scrolloff nrformats")
assertExOutput(" nrformats=hex scrolloff=0") assertExOutput(" nrformats=hex scrolloff=0")
injector.outputPanel.getCurrentOutputPanel()?.close() injector.outputPanel.getCurrentOutputPanel()?.close()
assertCommandOutput("set!", assertCommandOutput(
"set!",
""" """
|--- Options --- |--- Options ---
| fileencoding=utf-8 | fileencoding=utf-8
@ -237,7 +252,8 @@ class SetCommandTest : VimTestCase() {
fun `test show all option values in single column`() { fun `test show all option values in single column`() {
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
setOsSpecificOptionsToSafeValues() setOsSpecificOptionsToSafeValues()
assertCommandOutput("set! all", """ assertCommandOutput(
"set! all", """
|--- Options --- |--- Options ---
|noargtextobj |noargtextobj
|nobomb |nobomb
@ -318,7 +334,8 @@ class SetCommandTest : VimTestCase() {
@Test @Test
fun `test show named options in single column`() { fun `test show named options in single column`() {
assertCommandOutput("set! number? relativenumber? scrolloff? nrformats?", """ assertCommandOutput(
"set! number? relativenumber? scrolloff? nrformats?", """
| nrformats=hex | nrformats=hex
|nonumber |nonumber
|norelativenumber |norelativenumber

View File

@ -151,8 +151,7 @@ class SetglobalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", "notest") assertCommandOutput("setglobal test?", "notest")
assertCommandOutput("setlocal test?", "notest") assertCommandOutput("setlocal test?", "notest")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -173,8 +172,7 @@ class SetglobalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test") assertCommandOutput("setglobal test?", " test")
assertCommandOutput("setlocal test?", "notest") assertCommandOutput("setlocal test?", "notest")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -269,8 +267,7 @@ class SetglobalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test=10") assertCommandOutput("setglobal test?", " test=10")
assertCommandOutput("setlocal test?", " test=30") assertCommandOutput("setlocal test?", " test=30")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -291,8 +288,7 @@ class SetglobalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test=20") assertCommandOutput("setglobal test?", " test=20")
assertCommandOutput("setlocal test?", " test=30") assertCommandOutput("setlocal test?", " test=30")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -379,8 +375,7 @@ class SetglobalCommandTest : VimTestCase() {
enterCommand("setglobal test&") enterCommand("setglobal test&")
assertCommandOutput("setglobal test?", " test=testValue") assertCommandOutput("setglobal test?", " test=testValue")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -398,8 +393,7 @@ class SetglobalCommandTest : VimTestCase() {
enterCommand("setglobal test<") enterCommand("setglobal test<")
assertCommandOutput("setglobal test?", " test=globalValue") assertCommandOutput("setglobal test?", " test=globalValue")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -413,7 +407,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show all modified global option values`() { fun `test show all modified global option values`() {
assertCommandOutput("setglobal", """ assertCommandOutput(
"setglobal", """
|--- Global option values --- |--- Global option values ---
""".trimMargin() """.trimMargin()
) )
@ -422,7 +417,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show all modified global option values 2`() { fun `test show all modified global option values 2`() {
enterCommand("setglobal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10") enterCommand("setglobal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10")
assertCommandOutput("setglobal", """ assertCommandOutput(
"setglobal", """
|--- Global option values --- |--- Global option values ---
| number relativenumber scrolloff=10 sidescrolloff=10 | number relativenumber scrolloff=10 sidescrolloff=10
| nrformats=alpha,hex,octal | nrformats=alpha,hex,octal
@ -433,7 +429,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show all global option values`() { fun `test show all global option values`() {
setOsSpecificOptionsToSafeValues() setOsSpecificOptionsToSafeValues()
assertCommandOutput("setglobal all", """ assertCommandOutput(
"setglobal all", """
|--- Global option values --- |--- Global option values ---
|noargtextobj ideamarks scrolljump=1 notextobj-indent |noargtextobj ideamarks scrolljump=1 notextobj-indent
|nobomb ideawrite=all scrolloff=0 textwidth=0 |nobomb ideawrite=all scrolloff=0 textwidth=0
@ -472,7 +469,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show named options`() { fun `test show named options`() {
assertCommandOutput("setglobal number? relativenumber? scrolloff? nrformats?", """ assertCommandOutput(
"setglobal number? relativenumber? scrolloff? nrformats?", """
| nrformats=hex nonumber norelativenumber scrolloff=0 | nrformats=hex nonumber norelativenumber scrolloff=0
""".trimMargin() """.trimMargin()
) )
@ -480,7 +478,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show all modified global option values in single column`() { fun `test show all modified global option values in single column`() {
assertCommandOutput("setglobal!", """ assertCommandOutput(
"setglobal!", """
|--- Global option values --- |--- Global option values ---
""".trimMargin() """.trimMargin()
) )
@ -489,7 +488,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show all modified global option values in single column 2`() { fun `test show all modified global option values in single column 2`() {
enterCommand("setglobal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10") enterCommand("setglobal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10")
assertCommandOutput("setglobal!", """ assertCommandOutput(
"setglobal!", """
|--- Global option values --- |--- Global option values ---
| nrformats=alpha,hex,octal | nrformats=alpha,hex,octal
| number | number
@ -503,7 +503,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show all global option values in single column`() { fun `test show all global option values in single column`() {
setOsSpecificOptionsToSafeValues() setOsSpecificOptionsToSafeValues()
assertCommandOutput("setglobal! all", """ assertCommandOutput(
"setglobal! all", """
|--- Global option values --- |--- Global option values ---
|noargtextobj |noargtextobj
|nobomb |nobomb
@ -584,7 +585,8 @@ class SetglobalCommandTest : VimTestCase() {
@Test @Test
fun `test show named options in single column`() { fun `test show named options in single column`() {
assertCommandOutput("setglobal! number? relativenumber? scrolloff? nrformats?", """ assertCommandOutput(
"setglobal! number? relativenumber? scrolloff? nrformats?", """
| nrformats=hex | nrformats=hex
|nonumber |nonumber
|norelativenumber |norelativenumber

View File

@ -120,8 +120,7 @@ class SetlocalCommandTest : VimTestCase() {
injector.optionGroup.addOption(option) injector.optionGroup.addOption(option)
assertCommandOutput("setlocal test?", "--test") assertCommandOutput("setlocal test?", "--test")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -163,8 +162,7 @@ class SetlocalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", "notest") assertCommandOutput("setglobal test?", "notest")
assertCommandOutput("setlocal test?", "notest") assertCommandOutput("setlocal test?", "notest")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -187,8 +185,7 @@ class SetlocalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", "notest") assertCommandOutput("setglobal test?", "notest")
assertCommandOutput("setlocal test?", "--test") assertCommandOutput("setlocal test?", "--test")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -254,8 +251,7 @@ class SetlocalCommandTest : VimTestCase() {
injector.optionGroup.addOption(option) injector.optionGroup.addOption(option)
assertCommandOutput("setlocal test?", " test=-1") assertCommandOutput("setlocal test?", " test=-1")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -293,8 +289,7 @@ class SetlocalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test=15") assertCommandOutput("setglobal test?", " test=15")
assertCommandOutput("setlocal test?", " test=10") assertCommandOutput("setlocal test?", " test=10")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -319,8 +314,7 @@ class SetlocalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test=15") assertCommandOutput("setglobal test?", " test=15")
assertCommandOutput("setlocal test?", " test=-1") assertCommandOutput("setlocal test?", " test=-1")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -383,8 +377,7 @@ class SetlocalCommandTest : VimTestCase() {
injector.optionGroup.addOption(option) injector.optionGroup.addOption(option)
assertCommandOutput("setlocal test?", " test=") assertCommandOutput("setlocal test?", " test=")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -417,8 +410,7 @@ class SetlocalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test=globalValue") assertCommandOutput("setglobal test?", " test=globalValue")
assertCommandOutput("setlocal test?", " test=testValue") assertCommandOutput("setlocal test?", " test=testValue")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -440,8 +432,7 @@ class SetlocalCommandTest : VimTestCase() {
assertCommandOutput("setglobal test?", " test=globalValue") assertCommandOutput("setglobal test?", " test=globalValue")
assertCommandOutput("setlocal test?", " test=globalValue") assertCommandOutput("setlocal test?", " test=globalValue")
} } finally {
finally {
injector.optionGroup.removeOption(option.name) injector.optionGroup.removeOption(option.name)
} }
} }
@ -453,7 +444,8 @@ class SetlocalCommandTest : VimTestCase() {
enterCommand("setlocal fileformat&") enterCommand("setlocal fileformat&")
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
assertCommandOutput("setlocal", """ assertCommandOutput(
"setlocal", """
|--- Local option values --- |--- Local option values ---
|--ideajoin idearefactormode= scrolloff=-1 sidescrolloff=-1 |--ideajoin idearefactormode= scrolloff=-1 sidescrolloff=-1
| fileencoding=utf-8 | fileencoding=utf-8
@ -471,7 +463,8 @@ class SetlocalCommandTest : VimTestCase() {
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
enterCommand("setlocal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10") enterCommand("setlocal number relativenumber scrolloff=10 nrformats=alpha,hex,octal sidescrolloff=10")
assertCommandOutput("setlocal", """ assertCommandOutput(
"setlocal", """
|--- Local option values --- |--- Local option values ---
|--ideajoin number scrolloff=10 |--ideajoin number scrolloff=10
| idearefactormode= relativenumber sidescrolloff=10 | idearefactormode= relativenumber sidescrolloff=10
@ -487,7 +480,8 @@ class SetlocalCommandTest : VimTestCase() {
fun `test show all local option values`() { fun `test show all local option values`() {
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
setOsSpecificOptionsToSafeValues() setOsSpecificOptionsToSafeValues()
assertCommandOutput("setlocal all", """ assertCommandOutput(
"setlocal all", """
|--- Local option values --- |--- Local option values ---
|noargtextobj ideamarks norelativenumber startofline |noargtextobj ideamarks norelativenumber startofline
|nobomb idearefactormode= scroll=0 nosurround |nobomb idearefactormode= scroll=0 nosurround
@ -526,7 +520,8 @@ class SetlocalCommandTest : VimTestCase() {
@Test @Test
fun `test show named options`() { fun `test show named options`() {
assertCommandOutput("setlocal number? relativenumber? scrolloff? nrformats?", """ assertCommandOutput(
"setlocal number? relativenumber? scrolloff? nrformats?", """
| nrformats=hex nonumber norelativenumber scrolloff=-1 | nrformats=hex nonumber norelativenumber scrolloff=-1
""".trimMargin() """.trimMargin()
) )
@ -539,7 +534,8 @@ class SetlocalCommandTest : VimTestCase() {
enterCommand("setlocal fileformat&") enterCommand("setlocal fileformat&")
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
assertCommandOutput("setlocal!", """ assertCommandOutput(
"setlocal!", """
|--- Local option values --- |--- Local option values ---
| fileencoding=utf-8 | fileencoding=utf-8
|--ideacopypreprocess |--ideacopypreprocess
@ -556,7 +552,8 @@ class SetlocalCommandTest : VimTestCase() {
fun `test show all local option values in single column`() { fun `test show all local option values in single column`() {
// 'fileencoding' defaults to "", but is automatically detected as UTF-8 // 'fileencoding' defaults to "", but is automatically detected as UTF-8
setOsSpecificOptionsToSafeValues() setOsSpecificOptionsToSafeValues()
assertCommandOutput("setlocal! all", """ assertCommandOutput(
"setlocal! all", """
|--- Local option values --- |--- Local option values ---
|noargtextobj |noargtextobj
|nobomb |nobomb
@ -637,7 +634,8 @@ class SetlocalCommandTest : VimTestCase() {
@Test @Test
fun `test show named options in single column`() { fun `test show named options in single column`() {
assertCommandOutput("setlocal! number? relativenumber? scrolloff? nrformats?", """ assertCommandOutput(
"setlocal! number? relativenumber? scrolloff? nrformats?", """
| nrformats=hex | nrformats=hex
|nonumber |nonumber
|norelativenumber |norelativenumber

View File

@ -30,10 +30,12 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
enterCommand("y") enterCommand("y")
assertRegisterString(RegisterConstants.UNNAMED_REGISTER, assertRegisterString(
RegisterConstants.UNNAMED_REGISTER,
""" """
|Morbi nec luctus tortor, id venenatis lacus. |Morbi nec luctus tortor, id venenatis lacus.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test
@ -72,7 +74,8 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
enterCommand("4y") enterCommand("4y")
assertRegisterString(RegisterConstants.UNNAMED_REGISTER, assertRegisterString(
RegisterConstants.UNNAMED_REGISTER,
""" """
|Ut id dapibus augue. |Ut id dapibus augue.
|""".trimMargin() |""".trimMargin()
@ -92,7 +95,8 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
typeText(commandToKeys("3,4y")) typeText(commandToKeys("3,4y"))
assertRegisterString(RegisterConstants.UNNAMED_REGISTER, assertRegisterString(
RegisterConstants.UNNAMED_REGISTER,
""" """
|Nunc sit amet tellus vel purus cursus posuere et at purus. |Nunc sit amet tellus vel purus cursus posuere et at purus.
|Ut id dapibus augue. |Ut id dapibus augue.
@ -144,10 +148,12 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
enterCommand("y a") enterCommand("y a")
assertRegisterString('a', assertRegisterString(
'a',
""" """
|Morbi nec luctus tortor, id venenatis lacus. |Morbi nec luctus tortor, id venenatis lacus.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test
@ -164,11 +170,13 @@ class YankLinesCommandTest : VimTestCase() {
) )
typeText("\"ayy") typeText("\"ayy")
enterCommand("y A") enterCommand("y A")
assertRegisterString('a', assertRegisterString(
'a',
""" """
|Morbi nec luctus tortor, id venenatis lacus. |Morbi nec luctus tortor, id venenatis lacus.
|Morbi nec luctus tortor, id venenatis lacus. |Morbi nec luctus tortor, id venenatis lacus.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test
@ -218,12 +226,14 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
enterCommand("y 3") enterCommand("y 3")
assertRegisterString(RegisterConstants.UNNAMED_REGISTER, assertRegisterString(
RegisterConstants.UNNAMED_REGISTER,
""" """
|Morbi nec luctus tortor, id venenatis lacus. |Morbi nec luctus tortor, id venenatis lacus.
|Nunc sit amet tellus vel purus cursus posuere et at purus. |Nunc sit amet tellus vel purus cursus posuere et at purus.
|Ut id dapibus augue. |Ut id dapibus augue.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test
@ -256,12 +266,14 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
enterCommand("2,3y 3") enterCommand("2,3y 3")
assertRegisterString(RegisterConstants.UNNAMED_REGISTER, assertRegisterString(
RegisterConstants.UNNAMED_REGISTER,
""" """
|Nunc sit amet tellus vel purus cursus posuere et at purus. |Nunc sit amet tellus vel purus cursus posuere et at purus.
|Ut id dapibus augue. |Ut id dapibus augue.
|Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. |Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test
@ -277,12 +289,14 @@ class YankLinesCommandTest : VimTestCase() {
""".trimMargin() """.trimMargin()
) )
enterCommand("y c 3") enterCommand("y c 3")
assertRegisterString('c', assertRegisterString(
'c',
""" """
|Morbi nec luctus tortor, id venenatis lacus. |Morbi nec luctus tortor, id venenatis lacus.
|Nunc sit amet tellus vel purus cursus posuere et at purus. |Nunc sit amet tellus vel purus cursus posuere et at purus.
|Ut id dapibus augue. |Ut id dapibus augue.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test
@ -299,12 +313,14 @@ class YankLinesCommandTest : VimTestCase() {
) )
typeText("vjj") typeText("vjj")
enterCommand("y") enterCommand("y")
assertRegisterString(RegisterConstants.UNNAMED_REGISTER, assertRegisterString(
RegisterConstants.UNNAMED_REGISTER,
""" """
|Nunc sit amet tellus vel purus cursus posuere et at purus. |Nunc sit amet tellus vel purus cursus posuere et at purus.
|Ut id dapibus augue. |Ut id dapibus augue.
|Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. |Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
|""".trimMargin()) |""".trimMargin()
)
} }
@Test @Test

View File

@ -484,12 +484,14 @@ class FunctionDeclarationTest : VimTestCase() {
) )
typeText(commandToKeys("1,4call F1()")) typeText(commandToKeys("1,4call F1()"))
assertPluginError(false) assertPluginError(false)
assertExOutput(""" assertExOutput(
"""
1:4 1:4
1:4 1:4
1:4 1:4
1:4 1:4
""".trimIndent()) """.trimIndent()
)
assertState( assertState(
""" """
----- -----

View File

@ -48,9 +48,13 @@ class LambdaTests {
@ParameterizedTest @ParameterizedTest
@MethodSource("arg6") @MethodSource("arg6")
fun `lambda with multiple args test`(sp1: String, sp2: String, sp3: String, sp4: String, sp5: String, sp6: String) { fun `lambda with multiple args test`(sp1: String, sp2: String, sp3: String, sp4: String, sp5: String, sp6: String) {
val lambdaExpression = VimscriptParser.parseExpression("{${sp1}a$sp2,${sp3}b$sp4->${sp5}a+b$sp6}") as LambdaExpression val lambdaExpression =
VimscriptParser.parseExpression("{${sp1}a$sp2,${sp3}b$sp4->${sp5}a+b$sp6}") as LambdaExpression
assertEquals(listOf("a", "b"), lambdaExpression.args) assertEquals(listOf("a", "b"), lambdaExpression.args)
assertEquals(BinExpression(Variable(null, "a"), Variable(null, "b"), BinaryOperator.ADDITION), lambdaExpression.expr) assertEquals(
BinExpression(Variable(null, "a"), Variable(null, "b"), BinaryOperator.ADDITION),
lambdaExpression.expr
)
} }
@Test @Test
@ -64,7 +68,8 @@ class LambdaTests {
@ParameterizedTest @ParameterizedTest
@MethodSource("arg4") @MethodSource("arg4")
fun `lambda function call with multiple args test`(sp1: String, sp2: String, sp3: String, sp4: String) { fun `lambda function call with multiple args test`(sp1: String, sp2: String, sp3: String, sp4: String) {
val functionCall = VimscriptParser.parseExpression("{->'error'}(${sp1}a$sp2,${sp3}b$sp4)") as LambdaFunctionCallExpression val functionCall =
VimscriptParser.parseExpression("{->'error'}(${sp1}a$sp2,${sp3}b$sp4)") as LambdaFunctionCallExpression
assertEquals(2, functionCall.arguments.size) assertEquals(2, functionCall.arguments.size)
assertEquals(listOf(Variable(null, "a"), Variable(null, "b")), functionCall.arguments) assertEquals(listOf(Variable(null, "a"), Variable(null, "b")), functionCall.arguments)
assertEquals(0, functionCall.lambda.args.size) assertEquals(0, functionCall.lambda.args.size)

View File

@ -87,7 +87,14 @@ class SublistExpressionTests {
@ParameterizedTest @ParameterizedTest
@MethodSource("args6") @MethodSource("args6")
fun `sublist with non int expressions in ranges`(sp1: String, sp2: String, sp3: String, sp4: String, sp5: String, sp6: String) { fun `sublist with non int expressions in ranges`(
sp1: String,
sp2: String,
sp3: String,
sp4: String,
sp5: String,
sp6: String,
) {
val ex = VimscriptParser.parseExpression("[1, 2, 3, 4, 5, 6][${sp1}1$sp2+${sp3}5$sp4:$sp5'asd'$sp6]") val ex = VimscriptParser.parseExpression("[1, 2, 3, 4, 5, 6][${sp1}1$sp2+${sp3}5$sp4:$sp5'asd'$sp6]")
assertTrue(ex is SublistExpression) assertTrue(ex is SublistExpression)
assertEquals( assertEquals(

Some files were not shown because too many files have changed in this diff Show More