IDEA-71404 Strange behavior when typing over selected text

Looks like the problem is fixed already (suppose auto-completion is involved). So, the only change is to add the test
This commit is contained in:
Denis Zhdanov
2011-07-14 15:16:30 +04:00
parent 36c8f3f8ea
commit cd6539d503
2 changed files with 60 additions and 1 deletions
@@ -0,0 +1,59 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.editorActions
import com.intellij.openapi.editor.impl.AbstractEditorProcessingOnDocumentModificationTest
import com.intellij.testFramework.TestFileType
import com.intellij.codeInsight.CodeInsightSettings
/**
* @author Denis Zhdanov
* @since 7/14/11 2:15 PM
*/
class SelectionQuotingTest extends AbstractEditorProcessingOnDocumentModificationTest {
void testBuggySelection() {
def initial = '''\
var a = "a test";
var b = <selection>[a]</selection><caret>;
var c = "test test test";\
'''
def action = { type('"abc')}
def expected = '''\
var a = "a test";
var b = abc<caret>;
var c = "test test test";\
'''
doTest(initial, expected, action, TestFileType.JS)
}
def void doTest(initial, expected, action, fileType = TestFileType.JAVA) {
configureFromFileText("${getTestName(false)}.$fileType.extension", initial)
def settings = CodeInsightSettings.getInstance()
def old = settings.SURROUND_SELECTION_ON_QUOTE_TYPED
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = true
try {
action()
}
finally {
settings.SURROUND_SELECTION_ON_QUOTE_TYPED = old
}
checkResultByText(expected)
}
}