mirror of
				https://github.com/chylex/IntelliJ-IdeaVim.git
				synced 2025-10-31 11:17:13 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			943ddeb5ab
			...
			VIM-2227
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f2b532a8dc | 
| @@ -122,21 +122,26 @@ 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() | ||||
|         // Delete the surrounding | ||||
|         perform("da" + pick(charFrom), editor) | ||||
|         // Insert the surrounding characters and paste | ||||
|         if (newSurround != null) { | ||||
|           innerValue.addAll(0, injector.parser.parseKeys(newSurround.first)) | ||||
|           innerValue.addAll(injector.parser.parseKeys(newSurround.second)) | ||||
|         // 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 | ||||
|           if (newSurround != null) { | ||||
|             innerValue.addAll(0, injector.parser.parseKeys(newSurround.first)) | ||||
|             innerValue.addAll(injector.parser.parseKeys(newSurround.second)) | ||||
|           } | ||||
|           pasteSurround(innerValue, editor) | ||||
|           // Jump back to start | ||||
|           executeNormalWithoutMapping(injector.parser.parseKeys("`["), editor) | ||||
|         } | ||||
|         pasteSurround(innerValue, editor) | ||||
|         // Restore the old value | ||||
|         setRegister(REGISTER, oldValue) | ||||
|         // Jump back to start | ||||
|         executeNormalWithoutMapping(injector.parser.parseKeys("`["), editor) | ||||
|       } | ||||
|  | ||||
|       private fun perform(sequence: String, editor: Editor) { | ||||
|   | ||||
| @@ -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