From 2f1d350f9ac80f094e038a4a7f1b7ad496225e0e Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Thu, 26 Jun 2008 16:03:52 +0000 Subject: [PATCH] [236458] Fix addition of the last history entry --- .../META-INF/MANIFEST.MF | 2 +- .../control/CommandInputFieldWithHistory.java | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF index f1d4ddecb35..536fe146d05 100644 --- a/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal; singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.1.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java index e461f6979ae..90c232e986e 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/CommandInputFieldWithHistory.java @@ -10,7 +10,8 @@ * Michael Scharf (Wing River) - [211659] Add field assist to terminal input field * Michael Scharf (Wing River) - [196447] The optional terminal input line should be resizeable * Martin Oberhuber (Wind River) - [168197] Fix Terminal for CDC-1.1/Foundation-1.1 - * Michael Scharf (Wing River) - [236458] Fix 168197 lost the last entry + * Michael Scharf (Wing River) - [236458] Fix 168197 lost the last entry + * Martin Oberhuber (Wing River) - [236458] Fix addition of the last history entry *******************************************************************************/ package org.eclipse.tm.internal.terminal.control; import java.util.ArrayList; @@ -18,7 +19,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; -import java.util.StringTokenizer; import org.eclipse.jface.fieldassist.IContentProposal; import org.eclipse.jface.fieldassist.IContentProposalProvider; @@ -148,9 +148,19 @@ public class CommandInputFieldWithHistory implements ICommandInputField { // add history entries separated by '\n' // fHistory.addAll(Arrays.asList(history.split("\n"))); //$NON-NLS-1$ // - StringTokenizer tok=new StringTokenizer(history,"\n"); //$NON-NLS-1$ - while(tok.hasMoreElements()) - fHistory.add(tok.nextElement()); + int i = 0; + int j = history.indexOf('\n'); + while (j > i) { + fHistory.add(history.substring(i, j)); + do { + j++; + } while (j < history.length() && history.charAt(j) == '\n'); + i = j; + j = history.indexOf('\n', i); + } + if (i < history.length()) { + fHistory.add(history.substring(i)); + } // } /**