|
From: SVN by r. <sv...@ca...> - 2008-07-16 20:47:50
|
Author: roy
Date: 2008-07-16 22:47:38 +0200 (Wed, 16 Jul 2008)
New Revision: 263
Modified:
ChangeLog
src/main/java/nl/improved/sqlclient/SQLShell.java
src/main/java/nl/improved/sqlclient/SQLUtil.java
Log:
fix array indexout of bounds..
a try for better quit..
Modified: ChangeLog
===================================================================
--- ChangeLog 2008-05-19 20:55:11 UTC (rev 262)
+++ ChangeLog 2008-07-16 20:47:38 UTC (rev 263)
@@ -3,6 +3,7 @@
* Fix desc table for columns containing numbers
* Added tab completion for connect @
* Fix tabcompletion when using LIKE comparisons
+ * Fix for index out of bounds for strings without spaces
0.5 (2008-03-14)
* Allow for commands to start in the background, this will allow to continue
Modified: src/main/java/nl/improved/sqlclient/SQLShell.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLShell.java 2008-05-19 20:55:11 UTC (rev 262)
+++ src/main/java/nl/improved/sqlclient/SQLShell.java 2008-07-16 20:47:38 UTC (rev 263)
@@ -258,7 +258,10 @@
actionKeys.put("", new KeyAction() {
public void execute() {
StringBuilder lineBuffer = commandLines.getEditableLines().get(cursorPosition.y);
- int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x));
+ int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x-1));
+ if (lineBuffer.charAt(previousBreak) == ' ' || lineBuffer.charAt(previousBreak) == '\t') {
+ previousBreak++;
+ }
lineBuffer.delete(previousBreak, cursorPosition.x);
cursorPosition.x = previousBreak;
}
@@ -484,7 +487,10 @@
// check if the new line is becoming too long
if (currentLine.length() > MAX_LINE_LENGTH) {
// TODO search for lastspace that is not between '' ??
- int lastSpace = currentLine.lastIndexOf(" ");
+ int lastSpace = SQLUtil.getLastBreakIndex(currentLine.toString());//currentLine.lastIndexOf(" ");
+ if (lastSpace == -1) {
+ lastSpace = currentLine.length();
+ }
// check if there are enough 'next' lines
// if not.. add one
if (editableLines.size()-1 == cursorPosition.y) {
@@ -574,6 +580,7 @@
e.printStackTrace(new PrintWriter(sw));
sw.flush();
lastExceptionDetails = sw.toString();
+ output(sw.toString());
}
/**
@@ -1159,7 +1166,9 @@
}
@Override
public CharSequence execute(SQLCommand command) {
- hide(); // quit
+ //close();
+ hide();
+ Window.closeAllWindows();
return "Application terminated.";
}
@Override
@@ -1605,7 +1614,9 @@
public static void main(String[] args) {
SQLShell shell = new SQLShell();
- shell.show();
+ shell.setVisible(false);
+ shell.setVisible(true);
+ //shell.show();
//Interpret first argument as a connect argument
if (args.length > 0) {
Modified: src/main/java/nl/improved/sqlclient/SQLUtil.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLUtil.java 2008-05-19 20:55:11 UTC (rev 262)
+++ src/main/java/nl/improved/sqlclient/SQLUtil.java 2008-07-16 20:47:38 UTC (rev 263)
@@ -293,6 +293,10 @@
}
+ /**
+ * Returns the index of last spacing in the string.
+ * this method is used for clearing or breaking lines.
+ */
public static int getLastBreakIndex(String s) {
int spaceIndex = 0;
char[] breakCharacters = new char[]{' ', '\t', '.', ','};
|