Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2205

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1-rc-1
    • 1.1-rc-2
    • Groovysh
    • None
    • Windows bug only
    • Patch

    Description

      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

      Attachments

        1. Console.groovy
          28 kB
          Evan Slatis

        Activity

          People

            paulk Paul King
            hippyod Evan Slatis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: