Bug 446144 - [typing] Escape when paste: Stop escaping at quote mark if replaced selection overlaps end-of-string
Summary: [typing] Escape when paste: Stop escaping at quote mark if replaced selection...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-07 05:26 EDT by Timo Kinnunen CLA
Modified: 2023-03-21 10:55 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Kinnunen CLA 2014-10-07 05:26:23 EDT
Using this code:

	static void orgEclipseUiIdePrefs() {
		ArrayList<String> lines = new ArrayList<>();
		lines.add("MAX_RECENT_WORKSPACES=5");
		lines.add(
		"RECENT_WORKSPACES=C\\:\\\\Users\\\\Timo\\\\workspaceEVE\n" + 
		"RECENT_WORKSPACES_PROTOCOL=3\n" + 
		"SHOW_WORKSPACE_SELECTION_DIALOG=false\n" + 
		"eclipse.preferences.version=1\n" + 
		"");
	}

1. Select and copy text from the first lines.add-line so that the selection (without the '-quote marks) is '");<line-break><tab><tab>lines.add(' or as multi-line:
");
		lines.add(
2. Select the following text from the next line: '\n" + '
3. Paste the text selected in step 1.

The result is
	static void orgEclipseUiIdePrefs() {
		ArrayList<String> lines = new ArrayList<>();
		lines.add("MAX_RECENT_WORKSPACES=5");
		lines.add(
		"RECENT_WORKSPACES=C\\:\\\\Users\\\\Timo\\\\workspaceEVE\");\n" + 
		"		lines.add(
		"RECENT_WORKSPACES_PROTOCOL=3\n" + 
		"SHOW_WORKSPACE_SELECTION_DIALOG=false\n" + 
		"eclipse.preferences.version=1\n" + 
		"");
	}
which doesn't compile anymore.

The result should be:
	static void orgEclipseUiIdePrefs() {
		ArrayList<String> lines = new ArrayList<>();
		lines.add("MAX_RECENT_WORKSPACES=5");
		lines.add(
		"RECENT_WORKSPACES=C\\:\\\\Users\\\\Timo\\\\workspaceEVE");
		lines.add(
		"RECENT_WORKSPACES_PROTOCOL=3\n" + 
		"SHOW_WORKSPACE_SELECTION_DIALOG=false\n" + 
		"eclipse.preferences.version=1\n" + 
		"");
	}
which compiles fine.
Comment 1 Timo Kinnunen CLA 2014-10-07 06:14:17 EDT
Actually, I think a simpler heuristic than what is suggested in the summary would be to do a plain-old paste without any escaping if both the start and the end locations of the replaced selection are not within a String literal.
Comment 2 Eclipse Genie CLA 2021-03-11 14:48:22 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2023-03-21 10:55:36 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.