Skip to content

Commit 8e15a55

Browse files
author
Nicolas Laurent
committed
fix uses of StringOperations#createString and ArrayHelpers#createArray in ReadlineNodes
1 parent 0f0b3af commit 8e15a55

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/org/truffleruby/stdlib/readline/ReadlineNodes.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.graalvm.shadowed.org.jline.reader.UserInterruptException;
2121
import org.jcodings.specific.UTF8Encoding;
2222
import org.truffleruby.RubyContext;
23+
import org.truffleruby.RubyLanguage;
2324
import org.truffleruby.builtins.CoreMethod;
2425
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
2526
import org.truffleruby.builtins.CoreMethodNode;
@@ -93,7 +94,7 @@ public abstract static class CompletionProcSetNode extends PrimitiveArrayArgumen
9394
@TruffleBoundary
9495
@Specialization
9596
protected RubyProc setCompletionProc(RubyProc proc) {
96-
final ProcCompleter completer = new ProcCompleter(getContext(), proc);
97+
final ProcCompleter completer = new ProcCompleter(getContext(), getLanguage(), proc);
9798
getContext().getConsoleHolder().setCompleter(completer);
9899
return proc;
99100
}
@@ -112,7 +113,7 @@ protected RubyArray getScreenSize() {
112113
readline.getTerminal().getWidth()
113114
};
114115

115-
return ArrayHelpers.createArray(getContext(), store);
116+
return ArrayHelpers.createArray(getContext(), getLanguage(), store);
116117
}
117118

118119
}
@@ -276,10 +277,12 @@ protected int setOutput(int fd, RubyIO io) {
276277
private static class ProcCompleter implements Completer {
277278

278279
private final RubyContext context;
280+
private final RubyLanguage language;
279281
private final RubyProc proc;
280282

281-
public ProcCompleter(RubyContext context, RubyProc proc) {
283+
public ProcCompleter(RubyContext context, RubyLanguage language, RubyProc proc) {
282284
this.context = context;
285+
this.language = language;
283286
this.proc = proc;
284287
}
285288

@@ -290,7 +293,7 @@ public void complete(LineReader lineReader, ParsedLine commandLine, List<Candida
290293
boolean complete = lineReader.getBuffer().cursor() == lineReader.getBuffer().length();
291294

292295
RubyString string = StringOperations
293-
.createString(context, StringOperations.encodeRope(buffer, UTF8Encoding.INSTANCE));
296+
.createString(context, language, StringOperations.encodeRope(buffer, UTF8Encoding.INSTANCE));
294297
RubyArray completions = (RubyArray) context.send(proc, "call", string);
295298
for (Object element : ArrayOperations.toIterable(completions)) {
296299
final String completion = ((RubyString) element).getJavaString();

0 commit comments

Comments
 (0)