Handle \r line endings in plaintext j2k
#KT-35831 #EA-209568 Fixed
This commit is contained in:
+2
-2
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.idea.conversion.copy
|
||||
|
||||
import com.intellij.codeInsight.editorActions.CopyPastePostProcessor
|
||||
import com.intellij.codeInsight.editorActions.TextBlockTransferable
|
||||
import com.intellij.codeInsight.editorActions.TextBlockTransferableData
|
||||
import com.intellij.ide.highlighter.JavaFileType
|
||||
import com.intellij.openapi.diagnostic.ControlFlowException
|
||||
@@ -28,7 +29,6 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.util.LocalTimeCounter
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
@@ -108,7 +108,7 @@ class ConvertTextJavaCopyPasteProcessor : CopyPastePostProcessor<TextBlockTransf
|
||||
if (DumbService.getInstance(project).isDumb) return
|
||||
if (!KotlinEditorOptions.getInstance().isEnableJavaToKotlinConversion) return //TODO: use another option?
|
||||
|
||||
val text = (values.single() as MyTransferableData).text
|
||||
val text = TextBlockTransferable.convertLineSeparators(editor, (values.single() as MyTransferableData).text, values)
|
||||
|
||||
val psiDocumentManager = PsiDocumentManager.getInstance(project)
|
||||
val targetFile = psiDocumentManager.getPsiFile(editor.document) as? KtFile ?: return
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
public class BeatBox {
|
||||
private static final String TAG = "BeatBox";
|
||||
private static final String SOUNDS_FOLDER = "sample_sounds";
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
package org.jetbrains.kotlin.idea.conversion.copy
|
||||
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.ide.CopyPasteManager
|
||||
import org.jetbrains.kotlin.idea.editor.KotlinEditorOptions
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.awt.datatransfer.StringSelection
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractTextJavaToKotlinCopyPasteConversionTest : AbstractJ2kCopyPasteTest() {
|
||||
@@ -33,11 +35,11 @@ abstract class AbstractTextJavaToKotlinCopyPasteConversionTest : AbstractJ2kCopy
|
||||
val fileName = fileName()
|
||||
myFixture.configureByFile(fileName)
|
||||
|
||||
val fileText = myFixture.editor.document.text
|
||||
val fileText = testDataFile().readText()
|
||||
val noConversionExpected = InTextDirectivesUtils.findListWithPrefixes(fileText, "// NO_CONVERSION_EXPECTED").isNotEmpty()
|
||||
|
||||
myFixture.editor.selectionModel.setSelection(0, fileText.length)
|
||||
myFixture.performEditorAction(IdeActions.ACTION_COPY)
|
||||
// copy a file content directly to a buffer to keep it as is (keep original line endings etc)
|
||||
CopyPasteManager.getInstance().setContents(StringSelection(fileText))
|
||||
|
||||
configureByDependencyIfExists(fileName.replace(".txt", ".dependency.kt"))
|
||||
configureByDependencyIfExists(fileName.replace(".txt", ".dependency.java"))
|
||||
|
||||
Reference in New Issue
Block a user