mirror of
				https://github.com/chylex/IntelliJ-IdeaVim.git
				synced 2025-11-04 01:40:12 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			customized
			...
			VIM-2227
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						f2b532a8dc
	
				 | 
					
					
						
@@ -122,9 +122,13 @@ class VimSurroundExtension : VimExtension {
 | 
			
		||||
      fun change(editor: Editor, charFrom: Char, newSurround: Pair<String, String>?) {
 | 
			
		||||
        // We take over the " register, so preserve it
 | 
			
		||||
        val oldValue: List<KeyStroke>? = getRegister(REGISTER)
 | 
			
		||||
        // Empty the " register
 | 
			
		||||
        setRegister(REGISTER, null)
 | 
			
		||||
        // Extract the inner value
 | 
			
		||||
        perform("di" + pick(charFrom), editor)
 | 
			
		||||
        val innerValue: MutableList<KeyStroke> = getRegister(REGISTER)?.toMutableList() ?: mutableListOf()
 | 
			
		||||
        // If the surrounding characters were not found, the register will be empty
 | 
			
		||||
        if (innerValue.isNotEmpty()) {
 | 
			
		||||
          // Delete the surrounding
 | 
			
		||||
          perform("da" + pick(charFrom), editor)
 | 
			
		||||
          // Insert the surrounding characters and paste
 | 
			
		||||
@@ -133,11 +137,12 @@ class VimSurroundExtension : VimExtension {
 | 
			
		||||
            innerValue.addAll(injector.parser.parseKeys(newSurround.second))
 | 
			
		||||
          }
 | 
			
		||||
          pasteSurround(innerValue, editor)
 | 
			
		||||
        // Restore the old value
 | 
			
		||||
        setRegister(REGISTER, oldValue)
 | 
			
		||||
          // Jump back to start
 | 
			
		||||
          executeNormalWithoutMapping(injector.parser.parseKeys("`["), editor)
 | 
			
		||||
        }
 | 
			
		||||
        // Restore the old value
 | 
			
		||||
        setRegister(REGISTER, oldValue)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      private fun perform(sequence: String, editor: Editor) {
 | 
			
		||||
        ClipboardOptionHelper.IdeaputDisabler()
 | 
			
		||||
 
 | 
			
		||||
@@ -313,6 +313,17 @@ class VimSurroundExtensionTest : VimTestCase() {
 | 
			
		||||
    doTest(listOf("dsb"), before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // VIM-2227
 | 
			
		||||
  @TestWithoutNeovim(SkipNeovimReason.PLUGIN)
 | 
			
		||||
  fun testDeleteInvalidSurroundingCharacter() {
 | 
			
		||||
    val text = "if (${c}condition) {"
 | 
			
		||||
    
 | 
			
		||||
    doTest("yibds]", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
    doTest("yibds[", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
    doTest("yibds}", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
    doTest("yibds{", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @TestWithoutNeovim(SkipNeovimReason.PLUGIN)
 | 
			
		||||
  fun testRepeatDeleteSurroundParens() {
 | 
			
		||||
    val before = "if ((${c}condition)) {\n}\n"
 | 
			
		||||
@@ -371,6 +382,17 @@ class VimSurroundExtensionTest : VimTestCase() {
 | 
			
		||||
    doTest(listOf("csbrE."), before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // VIM-2227
 | 
			
		||||
  @TestWithoutNeovim(SkipNeovimReason.PLUGIN)
 | 
			
		||||
  fun testChangeInvalidSurroundingCharacter() {
 | 
			
		||||
    val text = "if (${c}condition) {"
 | 
			
		||||
 | 
			
		||||
    doTest("yibcs]}", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
    doTest("yibcs[}", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
    doTest("yibcs}]", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
    doTest("yibcs{]", text, text, CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @VimBehaviorDiffers(
 | 
			
		||||
    """
 | 
			
		||||
      <h1>Title</h1>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user