File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -103,15 +103,19 @@ public Optional<Integer> offset() {
103103 return Optional .of (pos .point ());
104104 }
105105 public Optional <Integer > pointer () {
106- return Optional .of (pos .point () - src .startOfLine (pos .point ()));
106+ if (!src .exists ()) return Optional .empty ();
107+ else return Optional .of (pos .point () - src .startOfLine (pos .point ()));
107108 }
108109 public Optional <String > pointerSpace () {
109- String lineContent = this .lineContent ();
110- int pointer = this .pointer ().get ();
111- StringBuilder result = new StringBuilder ();
112- for (int i = 0 ; i < pointer ; i ++)
113- result .append (lineContent .charAt (i ) == '\t' ? '\t' : ' ' );
114- return Optional .of (result .toString ());
110+ if (!src .exists ()) return Optional .empty ();
111+ else {
112+ String lineContent = this .lineContent ();
113+ int pointer = this .pointer ().get ();
114+ StringBuilder result = new StringBuilder ();
115+ for (int i = 0 ; i < pointer ; i ++)
116+ result .append (lineContent .charAt (i ) == '\t' ? '\t' : ' ' );
117+ return Optional .of (result .toString ());
118+ }
115119 }
116120 };
117121 } else {
You can’t perform that action at this time.
0 commit comments