Issue Details (XML | Word | Printable)

Key: GROOVY-2205
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Paul King
Reporter: Evan Slatis
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Multiline text selection not handled correctly in GroovyConsole on execution (Windows only bug)

Created: 13/Oct/07 07:51 PM   Updated: 13/Oct/07 10:43 PM
Component/s: Groovysh
Affects Version/s: 1.1-rc-1
Fix Version/s: 1.1-rc-2

Time Tracking:
Not Specified

File Attachments: 1. File Console.groovy (28 kB)

Environment: Windows bug only

Patch Submitted: Yes


 Description  « Hide
Internally, java.text.Document stores text per *nix style (i.e. '\n' only line separator), but the getText() method returns the text using the operating systems line separator ('\r\n' on windows). The console stores whatever text is in the buffer for each execution, and instead of storing the selected text it stores the indexes of the start and end of the current selection. Unfortunately, those latter values are lost in translation. The solution I used was to replace the OS line separator with a standard '\n' for the purpose of history tracking, and this cleared up the problem.

Old code in Console.groovy:
void runScript(EventObject evt = null) {
def record = new HistoryRecord( allText: inputArea.getText(), selectionStart: textSelectionStart, selectionEnd: textSelectionEnd)
addToHistory(record)
// ... executes script after this

Proposed new code:

void runScript(EventObject evt = null) {
def endLine = System.getProperty('line.separator')
def record = new HistoryRecord( allText: inputArea.getText().replace(endLine, '\n'),
selectionStart: textSelectionStart,
selectionEnd: textSelectionEnd)
addToHistory(record)
// ... executes script after this



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King added a comment - 13/Oct/07 10:43 PM
Fixed in HEAD