mirror of
				https://github.com/chylex/IntelliJ-IdeaVim.git
				synced 2025-11-04 01:40:12 +01:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			customized
			...
			2e8f0da0e4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						2e8f0da0e4
	
				 | 
					
					
						|||
| 
						
						
							
						
						3659aabb70
	
				 | 
					
					
						|||
| 
						
						
							
						
						7490c270d4
	
				 | 
					
					
						|||
| 
						
						
							
						
						e2f6f0d5bc
	
				 | 
					
					
						|||
| 
						
						
							
						
						15124fd7dd
	
				 | 
					
					
						|||
| 
						
						
							
						
						4de683db34
	
				 | 
					
					
						|||
| 
						
						
							
						
						5a9c8345cc
	
				 | 
					
					
						|||
| 
						
						
							
						
						69229fca8c
	
				 | 
					
					
						|||
| 
						
						
							
						
						03bcceb09b
	
				 | 
					
					
						
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
* text=auto eol=lf
 | 
			
		||||
							
								
								
									
										1
									
								
								.idea/codeStyles/Project.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								.idea/codeStyles/Project.xml
									
									
									
										generated
									
									
									
								
							@@ -6,6 +6,7 @@
 | 
			
		||||
        <option name="CONTINUATION_INDENT_SIZE" value="4" />
 | 
			
		||||
      </value>
 | 
			
		||||
    </option>
 | 
			
		||||
    <option name="LINE_SEPARATOR" value="
" />
 | 
			
		||||
    <JavaCodeStyleSettings>
 | 
			
		||||
      <option name="FIELD_NAME_PREFIX" value="my" />
 | 
			
		||||
      <option name="STATIC_FIELD_NAME_PREFIX" value="our" />
 | 
			
		||||
 
 | 
			
		||||
@@ -8,15 +8,14 @@
 | 
			
		||||
 | 
			
		||||
# suppress inspection "UnusedProperty" for whole file
 | 
			
		||||
 | 
			
		||||
ideaVersion=2023.1.2
 | 
			
		||||
ideaVersion=2023.2.1
 | 
			
		||||
downloadIdeaSources=true
 | 
			
		||||
instrumentPluginCode=true
 | 
			
		||||
version=SNAPSHOT
 | 
			
		||||
version=chylex-16
 | 
			
		||||
javaVersion=17
 | 
			
		||||
remoteRobotVersion=0.11.17
 | 
			
		||||
antlrVersion=4.10.1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Please don't forget to update kotlin version in buildscript section
 | 
			
		||||
kotlinVersion=1.8.21
 | 
			
		||||
publishToken=token
 | 
			
		||||
@@ -32,4 +31,4 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8'
 | 
			
		||||
kotlin.stdlib.default.dependency=false
 | 
			
		||||
 | 
			
		||||
# Disable incremental annotation processing
 | 
			
		||||
ksp.incremental=false
 | 
			
		||||
ksp.incremental=false
 | 
			
		||||
 
 | 
			
		||||
@@ -159,6 +159,10 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
 | 
			
		||||
      if ((keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_ENTER) && editor.appCodeTemplateCaptured()) {
 | 
			
		||||
        return ActionEnableStatus.no("App code template is active", LogLevel.INFO)
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_HOME || keyCode == KeyEvent.VK_END) {
 | 
			
		||||
        return ActionEnableStatus.no("Special keys", LogLevel.INFO)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (editor.inInsertMode) {
 | 
			
		||||
        if (keyCode == KeyEvent.VK_TAB) {
 | 
			
		||||
@@ -378,4 +382,4 @@ private class ActionEnableStatus(
 | 
			
		||||
 | 
			
		||||
private enum class LogLevel {
 | 
			
		||||
  DEBUG, INFO,
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -231,7 +231,7 @@ private object FileTypePatterns {
 | 
			
		||||
    } else if (fileTypeName == "CMakeLists.txt" || fileName == "CMakeLists") {
 | 
			
		||||
      this.cMakePatterns
 | 
			
		||||
    } else {
 | 
			
		||||
      return null
 | 
			
		||||
      this.htmlPatterns
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.editor.Editor
 | 
			
		||||
import com.maddyhome.idea.vim.VimPlugin
 | 
			
		||||
import com.maddyhome.idea.vim.api.ExecutionContext
 | 
			
		||||
import com.maddyhome.idea.vim.api.VimCaret
 | 
			
		||||
import com.maddyhome.idea.vim.api.VimChangeGroup
 | 
			
		||||
import com.maddyhome.idea.vim.api.VimEditor
 | 
			
		||||
import com.maddyhome.idea.vim.api.endsWithNewLine
 | 
			
		||||
import com.maddyhome.idea.vim.api.getLeadingCharacterOffset
 | 
			
		||||
@@ -34,7 +35,10 @@ import com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingIfMissin
 | 
			
		||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setOperatorFunction
 | 
			
		||||
import com.maddyhome.idea.vim.extension.VimExtensionFacade.setRegisterForCaret
 | 
			
		||||
import com.maddyhome.idea.vim.state.mode.mode
 | 
			
		||||
import com.maddyhome.idea.vim.helper.runWithEveryCaretAndRestore
 | 
			
		||||
import com.maddyhome.idea.vim.key.OperatorFunction
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.ij
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.vim
 | 
			
		||||
import com.maddyhome.idea.vim.options.helpers.ClipboardOptionHelper
 | 
			
		||||
@@ -79,7 +83,7 @@ internal class VimSurroundExtension : VimExtension {
 | 
			
		||||
    override val isRepeatable = true
 | 
			
		||||
 | 
			
		||||
    override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
 | 
			
		||||
      setOperatorFunction(Operator())
 | 
			
		||||
      setOperatorFunction(Operator(supportsMultipleCursors = false)) // TODO
 | 
			
		||||
      executeNormalWithoutMapping(injector.parser.parseKeys("g@"), editor.ij)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@@ -120,15 +124,13 @@ internal class VimSurroundExtension : VimExtension {
 | 
			
		||||
 | 
			
		||||
  private class VSurroundHandler : ExtensionHandler {
 | 
			
		||||
    override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
 | 
			
		||||
      val selectionStart = editor.ij.caretModel.primaryCaret.selectionStart
 | 
			
		||||
      // NB: Operator ignores SelectionType anyway
 | 
			
		||||
      if (!Operator().apply(editor, context, editor.mode.selectionType)) {
 | 
			
		||||
      if (!Operator(supportsMultipleCursors = true).apply(editor, context, editor.mode.selectionType)) {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
      runWriteAction {
 | 
			
		||||
        // Leave visual mode
 | 
			
		||||
        executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij)
 | 
			
		||||
        editor.ij.caretModel.moveToOffset(selectionStart)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@@ -149,6 +151,10 @@ internal class VimSurroundExtension : VimExtension {
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
      fun change(editor: VimEditor, context: ExecutionContext, charFrom: Char, newSurround: Pair<String, String>?) {
 | 
			
		||||
        editor.ij.runWithEveryCaretAndRestore { changeAtCaret(editor, context, charFrom, newSurround) }
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      fun changeAtCaret(editor: VimEditor, context: ExecutionContext, charFrom: Char, newSurround: Pair<String, String>?) {
 | 
			
		||||
        // Save old register values for carets
 | 
			
		||||
        val surroundings = editor.sortedCarets()
 | 
			
		||||
          .map {
 | 
			
		||||
@@ -255,20 +261,44 @@ internal class VimSurroundExtension : VimExtension {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private class Operator : OperatorFunction {
 | 
			
		||||
    override fun apply(editor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
 | 
			
		||||
      val ijEditor = editor.ij
 | 
			
		||||
      val c = getChar(ijEditor)
 | 
			
		||||
  private class Operator(private val supportsMultipleCursors: Boolean) : OperatorFunction {
 | 
			
		||||
    override fun apply(vimEditor: VimEditor, context: ExecutionContext, selectionType: SelectionType?): Boolean {
 | 
			
		||||
      val editor = vimEditor.ij
 | 
			
		||||
      val c = getChar(editor)
 | 
			
		||||
      if (c.code == 0) return true
 | 
			
		||||
 | 
			
		||||
      val pair = getOrInputPair(c, ijEditor) ?: return false
 | 
			
		||||
      // XXX: Will it work with line-wise or block-wise selections?
 | 
			
		||||
      val range = getSurroundRange(editor.currentCaret()) ?: return false
 | 
			
		||||
      performSurround(pair, range, editor.currentCaret(), selectionType == SelectionType.LINE_WISE)
 | 
			
		||||
      // Jump back to start
 | 
			
		||||
      executeNormalWithoutMapping(injector.parser.parseKeys("`["), ijEditor)
 | 
			
		||||
      val pair = getOrInputPair(c, editor) ?: return false
 | 
			
		||||
 | 
			
		||||
      runWriteAction {
 | 
			
		||||
        val change = VimPlugin.getChange()
 | 
			
		||||
        if (supportsMultipleCursors) {
 | 
			
		||||
          editor.runWithEveryCaretAndRestore {
 | 
			
		||||
            applyOnce(editor, change, pair)
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
          applyOnce(editor, change, pair)
 | 
			
		||||
          // Jump back to start
 | 
			
		||||
          executeNormalWithoutMapping(injector.parser.parseKeys("`["), editor)
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return true
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private fun applyOnce(editor: Editor, change: VimChangeGroup, pair: Pair<String, String>) {
 | 
			
		||||
      // XXX: Will it work with line-wise or block-wise selections?
 | 
			
		||||
      val primaryCaret = editor.caretModel.primaryCaret
 | 
			
		||||
      val range = getSurroundRange(primaryCaret.vim)
 | 
			
		||||
      if (range != null) {
 | 
			
		||||
        change.insertText(IjVimEditor(editor), IjVimCaret(primaryCaret), range.startOffset, pair.first)
 | 
			
		||||
        change.insertText(
 | 
			
		||||
          IjVimEditor(editor),
 | 
			
		||||
          IjVimCaret(primaryCaret),
 | 
			
		||||
          range.endOffset + pair.first.length,
 | 
			
		||||
          pair.second
 | 
			
		||||
        )
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun getSurroundRange(caret: VimCaret): TextRange? {
 | 
			
		||||
      val editor = caret.editor
 | 
			
		||||
 
 | 
			
		||||
@@ -85,7 +85,7 @@ public class ProcessGroup extends VimProcessGroupBase {
 | 
			
		||||
    injector.getMarkService().setVisualSelectionMarks(editor);
 | 
			
		||||
    VimStateMachine.Companion.getInstance(editor).setMode(Mode.CMD_LINE.INSTANCE);
 | 
			
		||||
    ExEntryPanel panel = ExEntryPanel.getInstance();
 | 
			
		||||
    panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
 | 
			
		||||
    panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, cmd.getCount());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
@@ -116,7 +116,7 @@ public class ProcessGroup extends VimProcessGroupBase {
 | 
			
		||||
 | 
			
		||||
      logger.debug("processing command");
 | 
			
		||||
 | 
			
		||||
      final String text = panel.getText();
 | 
			
		||||
      String text = panel.getText();
 | 
			
		||||
 | 
			
		||||
      if (!panel.getLabel().equals(":")) {
 | 
			
		||||
        // Search is handled via Argument.Type.EX_STRING. Although ProcessExEntryAction is registered as the handler for
 | 
			
		||||
@@ -127,7 +127,15 @@ public class ProcessGroup extends VimProcessGroupBase {
 | 
			
		||||
 | 
			
		||||
      if (logger.isDebugEnabled()) logger.debug("swing=" + SwingUtilities.isEventDispatchThread());
 | 
			
		||||
 | 
			
		||||
      VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
 | 
			
		||||
      int repeat = 1;
 | 
			
		||||
      if (text.contains("raction ")) {
 | 
			
		||||
        text = text.replace("raction ", "action ");
 | 
			
		||||
        repeat = panel.getCount();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      for (int i = 0; i < repeat; i++) {
 | 
			
		||||
        VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    catch (ExException e) {
 | 
			
		||||
      VimPlugin.showMessage(e.getMessage());
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ package com.maddyhome.idea.vim.helper
 | 
			
		||||
 | 
			
		||||
import com.intellij.codeWithMe.ClientId
 | 
			
		||||
import com.intellij.openapi.editor.Caret
 | 
			
		||||
import com.intellij.openapi.editor.CaretState
 | 
			
		||||
import com.intellij.openapi.editor.Editor
 | 
			
		||||
import com.intellij.openapi.editor.ex.util.EditorUtil
 | 
			
		||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
 | 
			
		||||
@@ -19,6 +20,8 @@ import com.intellij.util.ui.table.JBTableRowEditor
 | 
			
		||||
import com.maddyhome.idea.vim.api.injector
 | 
			
		||||
import com.maddyhome.idea.vim.group.IjOptionConstants
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.globalIjOptions
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.vim
 | 
			
		||||
import com.maddyhome.idea.vim.state.mode.inBlockSelection
 | 
			
		||||
import java.awt.Component
 | 
			
		||||
import javax.swing.JComponent
 | 
			
		||||
import javax.swing.JTable
 | 
			
		||||
@@ -93,3 +96,41 @@ internal val Caret.vimLine: Int
 | 
			
		||||
 */
 | 
			
		||||
internal val Editor.vimLine: Int
 | 
			
		||||
  get() = this.caretModel.currentCaret.vimLine
 | 
			
		||||
 | 
			
		||||
internal inline fun Editor.runWithEveryCaretAndRestore(action: () -> Unit) {
 | 
			
		||||
  val caretModel = this.caretModel
 | 
			
		||||
  val carets = if (this.vim.inBlockSelection) null else caretModel.allCarets
 | 
			
		||||
  if (carets == null || carets.size == 1) {
 | 
			
		||||
    action()
 | 
			
		||||
  }
 | 
			
		||||
  else {
 | 
			
		||||
    var initialDocumentSize = this.document.textLength
 | 
			
		||||
    var documentSizeDifference = 0
 | 
			
		||||
 | 
			
		||||
    val caretOffsets = carets.map { it.selectionStart to it.selectionEnd }
 | 
			
		||||
    val restoredCarets = mutableListOf<CaretState>()
 | 
			
		||||
 | 
			
		||||
    caretModel.removeSecondaryCarets()
 | 
			
		||||
    
 | 
			
		||||
    for ((selectionStart, selectionEnd) in caretOffsets) {
 | 
			
		||||
      if (selectionStart == selectionEnd) {
 | 
			
		||||
        caretModel.primaryCaret.moveToOffset(selectionStart + documentSizeDifference)
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        caretModel.primaryCaret.setSelection(
 | 
			
		||||
          selectionStart + documentSizeDifference,
 | 
			
		||||
          selectionEnd + documentSizeDifference
 | 
			
		||||
        )
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      action()
 | 
			
		||||
      restoredCarets.add(caretModel.caretsAndSelections.single())
 | 
			
		||||
 | 
			
		||||
      val documentLength = this.document.textLength
 | 
			
		||||
      documentSizeDifference += documentLength - initialDocumentSize
 | 
			
		||||
      initialDocumentSize = documentLength
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    caretModel.caretsAndSelections = restoredCarets
 | 
			
		||||
  } 
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ import com.intellij.openapi.command.impl.UndoManagerImpl
 | 
			
		||||
import com.intellij.openapi.command.undo.UndoManager
 | 
			
		||||
import com.intellij.openapi.components.Service
 | 
			
		||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider
 | 
			
		||||
import com.maddyhome.idea.vim.VimPlugin
 | 
			
		||||
import com.maddyhome.idea.vim.api.ExecutionContext
 | 
			
		||||
import com.maddyhome.idea.vim.api.VimEditor
 | 
			
		||||
import com.maddyhome.idea.vim.api.injector
 | 
			
		||||
@@ -23,6 +24,8 @@ import com.maddyhome.idea.vim.group.IjOptions
 | 
			
		||||
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.globalIjOptions
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.ij
 | 
			
		||||
import com.maddyhome.idea.vim.state.mode.SelectionType
 | 
			
		||||
import com.maddyhome.idea.vim.state.mode.inVisualMode
 | 
			
		||||
import com.maddyhome.idea.vim.undo.UndoRedoBase
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -50,6 +53,7 @@ internal class UndoRedoHelper : UndoRedoBase() {
 | 
			
		||||
 | 
			
		||||
      if (injector.globalIjOptions().oldundo) {
 | 
			
		||||
        SelectionVimListenerSuppressor.lock().use { undoManager.undo(fileEditor) }
 | 
			
		||||
        restoreVisualMode(editor)
 | 
			
		||||
      } else {
 | 
			
		||||
        performUntilFileChanges(editor, { undoManager.isUndoAvailable(fileEditor) }, { undoManager.undo(fileEditor) })
 | 
			
		||||
 | 
			
		||||
@@ -81,6 +85,7 @@ internal class UndoRedoHelper : UndoRedoBase() {
 | 
			
		||||
    if (undoManager.isRedoAvailable(fileEditor)) {
 | 
			
		||||
      if (injector.globalIjOptions().oldundo) {
 | 
			
		||||
        SelectionVimListenerSuppressor.lock().use { undoManager.redo(fileEditor) }
 | 
			
		||||
        restoreVisualMode(editor)
 | 
			
		||||
      } else {
 | 
			
		||||
        performUntilFileChanges(editor, { undoManager.isRedoAvailable(fileEditor) }, { undoManager.redo(fileEditor) })
 | 
			
		||||
        CommandProcessor.getInstance().runUndoTransparentAction {
 | 
			
		||||
@@ -115,4 +120,21 @@ internal class UndoRedoHelper : UndoRedoBase() {
 | 
			
		||||
  private fun ifFilePathChanged(editor: VimEditor, oldPath: String?): Boolean {
 | 
			
		||||
    return editor.getPath() != oldPath
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private fun restoreVisualMode(editor: VimEditor) {
 | 
			
		||||
    if (!editor.inVisualMode && editor.getSelectionModel().hasSelection()) {
 | 
			
		||||
      val detectedMode = VimPlugin.getVisualMotion().autodetectVisualSubmode(editor)
 | 
			
		||||
      
 | 
			
		||||
      // Visual block selection is restored into multiple carets, so multi-carets that form a block are always
 | 
			
		||||
      // identified as visual block mode, leading to false positives.
 | 
			
		||||
      // Since I use visual block mode much less often than multi-carets, this is a judgment call to never restore
 | 
			
		||||
      // visual block mode.
 | 
			
		||||
      val wantedMode = if (detectedMode == SelectionType.BLOCK_WISE)
 | 
			
		||||
        SelectionType.CHARACTER_WISE
 | 
			
		||||
      else
 | 
			
		||||
        detectedMode
 | 
			
		||||
      
 | 
			
		||||
      VimPlugin.getVisualMotion().enterVisualMode(editor, wantedMode)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright 2003-2023 The IdeaVim authors
 | 
			
		||||
 *
 | 
			
		||||
 * Use of this source code is governed by an MIT-style
 | 
			
		||||
 * license that can be found in the LICENSE.txt file or at
 | 
			
		||||
 * https://opensource.org/licenses/MIT.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package com.maddyhome.idea.vim.helper
 | 
			
		||||
 | 
			
		||||
import com.intellij.ide.plugins.StandalonePluginUpdateChecker
 | 
			
		||||
import com.intellij.openapi.components.Service
 | 
			
		||||
import com.intellij.openapi.components.service
 | 
			
		||||
import com.maddyhome.idea.vim.VimPlugin
 | 
			
		||||
import com.maddyhome.idea.vim.group.NotificationService
 | 
			
		||||
import com.maddyhome.idea.vim.icons.VimIcons
 | 
			
		||||
 | 
			
		||||
@Service(Service.Level.APP)
 | 
			
		||||
internal class VimStandalonePluginUpdateChecker : StandalonePluginUpdateChecker(
 | 
			
		||||
  VimPlugin.getPluginId(),
 | 
			
		||||
  updateTimestampProperty = PROPERTY_NAME,
 | 
			
		||||
  NotificationService.IDEAVIM_STICKY_GROUP,
 | 
			
		||||
  VimIcons.IDEAVIM,
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  override fun skipUpdateCheck(): Boolean = !VimPlugin.isEnabled() || "dev" in VimPlugin.getVersion()
 | 
			
		||||
 | 
			
		||||
  companion object {
 | 
			
		||||
    private const val PROPERTY_NAME = "ideavim.statistics.timestamp"
 | 
			
		||||
    val instance: VimStandalonePluginUpdateChecker = service()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -72,7 +72,6 @@ import com.maddyhome.idea.vim.group.visual.moveCaretOneCharLeftFromSelectionEnd
 | 
			
		||||
import com.maddyhome.idea.vim.group.visual.vimSetSystemSelectionSilently
 | 
			
		||||
import com.maddyhome.idea.vim.helper.GuicursorChangeListener
 | 
			
		||||
import com.maddyhome.idea.vim.helper.StrictMode
 | 
			
		||||
import com.maddyhome.idea.vim.helper.VimStandalonePluginUpdateChecker
 | 
			
		||||
import com.maddyhome.idea.vim.helper.exitSelectMode
 | 
			
		||||
import com.maddyhome.idea.vim.helper.exitVisualMode
 | 
			
		||||
import com.maddyhome.idea.vim.helper.forceBarCursor
 | 
			
		||||
@@ -330,8 +329,6 @@ internal object VimListenerManager {
 | 
			
		||||
 | 
			
		||||
        event.editor.putUserData(openingEditorKey, OpeningEditor(openingEditor, owningEditorWindow, isPreview, canBeReused))
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      VimStandalonePluginUpdateChecker.instance.pluginUsed()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun editorReleased(event: EditorFactoryEvent) {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,49 @@
 | 
			
		||||
/*
 | 
			
		||||
 * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
 | 
			
		||||
 * Copyright (C) 2003-2021 The IdeaVim authors
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package com.maddyhome.idea.vim.vimscript.model.functions.handlers
 | 
			
		||||
 | 
			
		||||
import com.intellij.refactoring.rename.inplace.InplaceRefactoring
 | 
			
		||||
import com.intellij.vim.annotations.VimscriptFunction
 | 
			
		||||
import com.maddyhome.idea.vim.api.ExecutionContext
 | 
			
		||||
import com.maddyhome.idea.vim.api.VimEditor
 | 
			
		||||
import com.maddyhome.idea.vim.newapi.ij
 | 
			
		||||
import com.maddyhome.idea.vim.vimscript.model.VimLContext
 | 
			
		||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
 | 
			
		||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
 | 
			
		||||
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
 | 
			
		||||
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
 | 
			
		||||
 | 
			
		||||
@VimscriptFunction(name = "renaming")
 | 
			
		||||
internal class RenamingFunctionHandler : FunctionHandler() {
 | 
			
		||||
 | 
			
		||||
  override val minimumNumberOfArguments = 0
 | 
			
		||||
  override val maximumNumberOfArguments = 0
 | 
			
		||||
  
 | 
			
		||||
  override fun doFunction(
 | 
			
		||||
    argumentValues: List<Expression>,
 | 
			
		||||
    editor: VimEditor,
 | 
			
		||||
    context: ExecutionContext,
 | 
			
		||||
    vimContext: VimLContext,
 | 
			
		||||
  ): VimDataType {
 | 
			
		||||
    return if (InplaceRefactoring.getActiveInplaceRenamer(editor.ij) == null)
 | 
			
		||||
      VimInt.ZERO
 | 
			
		||||
    else
 | 
			
		||||
      VimInt.ONE
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -226,12 +226,12 @@
 | 
			
		||||
 | 
			
		||||
    <!-- Change -->
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseLowerMotionAction" mappingModes="N" keys="gu"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseLowerVisualAction" mappingModes="X" keys="u"/>
 | 
			
		||||
<!--    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseLowerVisualAction" mappingModes="X" keys="u"/>-->
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseToggleCharacterAction" mappingModes="N" keys="~"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseToggleMotionAction" mappingModes="N" keys="g~"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseToggleVisualAction" mappingModes="X" keys="~"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseUpperMotionAction" mappingModes="N" keys="gU"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseUpperVisualAction" mappingModes="X" keys="U"/>
 | 
			
		||||
<!--    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCaseUpperVisualAction" mappingModes="X" keys="U"/>-->
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCharacterAction" mappingModes="N" keys="r"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeCharactersAction" mappingModes="N" keys="s"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeEndOfLineAction" mappingModes="N" keys="C"/>
 | 
			
		||||
@@ -329,8 +329,8 @@
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.RepeatChangeAction" mappingModes="N" keys="."/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.ExEntryAction" mappingModes="NXO" keys=":"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.ResetModeAction" mappingModes="ALL" keys="«C-\»«C-N»"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.RedoAction" mappingModes="N" keys="«C-R»"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.UndoAction" mappingModes="N"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.RedoAction" mappingModes="NX" keys="U,«C-R»"/>
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.UndoAction" mappingModes="NX"/>
 | 
			
		||||
 | 
			
		||||
    <!-- Keys -->
 | 
			
		||||
    <vimAction implementation="com.maddyhome.idea.vim.action.change.OperatorAction" mappingModes="N" keys="g@"/>
 | 
			
		||||
 
 | 
			
		||||
@@ -24,5 +24,6 @@
 | 
			
		||||
    <vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.JoinFunctionHandler" name="join"/>
 | 
			
		||||
    <vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.SplitFunctionHandler" name="split"/>
 | 
			
		||||
    <vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.GetFunctionHandler" name="get"/>
 | 
			
		||||
    <vimLibraryFunction implementation="com.maddyhome.idea.vim.vimscript.model.functions.handlers.RenamingFunctionHandler" name="renaming"/>
 | 
			
		||||
  </extensions>
 | 
			
		||||
</idea-plugin>
 | 
			
		||||
</idea-plugin>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,4 @@
 | 
			
		||||
<!--
 | 
			
		||||
  ~ Copyright 2003-2023 The IdeaVim authors
 | 
			
		||||
  ~
 | 
			
		||||
  ~ Use of this source code is governed by an MIT-style
 | 
			
		||||
  ~ license that can be found in the LICENSE.txt file or at
 | 
			
		||||
  ~ https://opensource.org/licenses/MIT.
 | 
			
		||||
  -->
 | 
			
		||||
 | 
			
		||||
<idea-plugin url="https://plugins.jetbrains.com/plugin/164" xmlns:xi="http://www.w3.org/2001/XInclude">
 | 
			
		||||
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
 | 
			
		||||
  <name>IdeaVim</name>
 | 
			
		||||
  <id>IdeaVIM</id>
 | 
			
		||||
  <description><![CDATA[
 | 
			
		||||
@@ -21,7 +13,7 @@
 | 
			
		||||
        <li><a href="https://youtrack.jetbrains.com/issues/VIM">Issue tracker</a>: feature requests and bug reports</li>
 | 
			
		||||
      </ul>
 | 
			
		||||
    ]]></description>
 | 
			
		||||
  <version>SNAPSHOT</version>
 | 
			
		||||
  <version>chylex</version>
 | 
			
		||||
  <vendor>JetBrains</vendor>
 | 
			
		||||
 | 
			
		||||
  <!-- Please search for "[VERSION UPDATE]" in project in case you update the since-build version -->
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user