From 57e088fe6d0087631fcf78a56ca322a855c479b7 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 29 Jul 2016 21:04:30 +0300 Subject: [PATCH] SingleCharSequence::subSequence implemented (fixes latency free typing with Markdown) --- .../com/intellij/util/text/SingleCharSequence.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/text/SingleCharSequence.java b/platform/util/src/com/intellij/util/text/SingleCharSequence.java index d29fe18a5af1..3a69fd595590 100644 --- a/platform/util/src/com/intellij/util/text/SingleCharSequence.java +++ b/platform/util/src/com/intellij/util/text/SingleCharSequence.java @@ -15,6 +15,8 @@ */ package com.intellij.util.text; +import org.jetbrains.annotations.NotNull; + public class SingleCharSequence implements CharSequence { private final char myCh; @@ -37,6 +39,16 @@ public class SingleCharSequence implements CharSequence { @Override public CharSequence subSequence(int start, int end) { - throw new RuntimeException("Method subSequence not implemented"); + if (start == 0 && end == 1) return this; + if (start < 0) throw new IndexOutOfBoundsException("Start index out of range:" + start); + if (end > 1 || end < 0) throw new IndexOutOfBoundsException("End index out of range:" + end); + if (start > end) throw new IndexOutOfBoundsException("Start index should be less or equal to end index:" + start + " - " + end); + return ""; + } + + @Override + @NotNull + public String toString() { + return String.valueOf(myCh); } }