Ejemplo n.º 1
0
        public static string GetWhitespaces(Ide.Editor.TextEditor editor, int insertionOffset)
        {
            StringBuilder result = new StringBuilder();

            for (int i = insertionOffset; i < editor.Length; i++)
            {
                char ch = editor.GetCharAt(i);
                if (ch == ' ' || ch == '\t')
                {
                    result.Append(ch);
                }
                else
                {
                    break;
                }
            }
            return(result.ToString());
        }
Ejemplo n.º 2
0
        string GetIndentationString(DocumentLocation loc)
        {
            var line = data.GetLine(loc.Line);

            if (line == null)
            {
                return("");
            }
            // Get context to the end of the line w/o changing the main engine's state
            var    offset    = line.Offset;
            string curIndent = line.GetIndentation(data);

            try {
                stateTracker.Update(data, Math.Min(data.Length, offset + Math.Min(line.Length, loc.Column - 1)));
                int nlwsp = curIndent.Length;
                if (!stateTracker.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && data.GetCharAt(offset + nlwsp) == '*'))
                {
                    return(stateTracker.ThisLineIndent);
                }
            } catch (Exception e) {
                LoggingService.LogError("Error while indenting at " + loc, e);
            }
            return(curIndent);
        }