Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-05-25 08:59:29 -0400
committerAlexander Kurtakov2017-05-25 08:59:29 -0400
commite4022fd1a879d9b197b07f7f983b0e6483c6134f (patch)
treed9825d53ae70b8d85144e42d9db99f2e77347e59
parent0fb4f7743645692ead1221a5f8f8853d13d745f9 (diff)
downloadorg.eclipse.dltk.sh-e4022fd1a879d9b197b07f7f983b0e6483c6134f.tar.gz
org.eclipse.dltk.sh-e4022fd1a879d9b197b07f7f983b0e6483c6134f.tar.xz
org.eclipse.dltk.sh-e4022fd1a879d9b197b07f7f983b0e6483c6134f.zip
Bug 515908 - Fix / Turn off auto indentation for } in shell ed when
typing ${var} Use the rule for variables in the edit strategy and exclude it from indent/dedent. Change-Id: I98bb973c621002e30f7c5087d398f90533d72383 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/editor/ShellSourceViewerConfiguration.java4
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/ScriptAutoIndentStrategy.java20
2 files changed, 14 insertions, 10 deletions
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/editor/ShellSourceViewerConfiguration.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/editor/ShellSourceViewerConfiguration.java
index bb2b8fb..a7d50c4 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/editor/ShellSourceViewerConfiguration.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/editor/ShellSourceViewerConfiguration.java
@@ -18,6 +18,7 @@ import org.eclipse.dltk.sh.internal.ui.Activator;
import org.eclipse.dltk.sh.internal.ui.IShellColorConstants;
import org.eclipse.dltk.sh.internal.ui.ShellContentAssistPreference;
import org.eclipse.dltk.sh.internal.ui.completion.ShellCompletionProcessor;
+import org.eclipse.dltk.sh.internal.ui.text.DollarBraceCountingRule;
import org.eclipse.dltk.sh.internal.ui.text.DoubleQuoteScanner;
import org.eclipse.dltk.sh.internal.ui.text.EvalScanner;
import org.eclipse.dltk.sh.internal.ui.text.IShellPartitions;
@@ -95,13 +96,14 @@ public class ShellSourceViewerConfiguration extends ScriptSourceViewerConfigurat
ArrayList<IRule> rules = new ArrayList<>();
rules.add(new WhitespaceRule(new WhitespaceDetector()));
+ rules.add(new DollarBraceCountingRule('{', '}', new Token(IShellPartitions.EVAL_CONTENT_TYPE), '\\'));
rules.add(getKeywords(new Token(IndentType.INCREMENT), new String[] { "do", "case", "{", "then" },
Token.UNDEFINED));
rules.add(getKeywords(new Token(IndentType.DECREMENT), new String[] { "done", "esac", "}", "fi" },
Token.UNDEFINED));
rules.add(getKeywords(new Token(IndentType.INFLEXION), new String[] { "else" }, Token.UNDEFINED));
- strategy.setRules(rules.toArray(new IRule[0]));
+ strategy.setRules(rules.toArray(new IRule[rules.size()]));
return new IAutoEditStrategy[] { strategy };
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/ScriptAutoIndentStrategy.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/ScriptAutoIndentStrategy.java
index 19d73b7..19cb4fb 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/ScriptAutoIndentStrategy.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/ScriptAutoIndentStrategy.java
@@ -207,15 +207,17 @@ public class ScriptAutoIndentStrategy implements IAutoEditStrategy {
}
if (token.isOther()) {
- IndentType type = (IndentType) token.getData();
- if (type == IndentType.INCREMENT) {
- ++bracketcount;
- } else if (type == IndentType.DECREMENT) {
- --bracketcount;
- } else if ((type == IndentType.INFLEXION) && ignoreInflexions) {
- ++bracketcount;
- } else if ((type == IndentType.INFLEXION) && !ignoreInflexions) {
- --bracketcount;
+ if (token.getData() instanceof IndentType) {
+ IndentType type = (IndentType) token.getData();
+ if (type == IndentType.INCREMENT) {
+ ++bracketcount;
+ } else if (type == IndentType.DECREMENT) {
+ --bracketcount;
+ } else if ((type == IndentType.INFLEXION) && ignoreInflexions) {
+ ++bracketcount;
+ } else if ((type == IndentType.INFLEXION) && !ignoreInflexions) {
+ --bracketcount;
+ }
}
}
}

Back to the top