英文:
jline problems with escape character in completion
问题
以下是您提供的内容的翻译部分:
我正在使用Java中的jline version3进行项目开发,但在完成时,我需要使用“else if”,但它将\用作转义空格的转义字符,而我没有任何转义字符,我还尝试过将null
替换为char[]
,但它会崩溃并出现空指针异常。
另外,我查看了https://github.com/jline/jline3/issues/173
错误内容如下:
at org.jline.reader.impl.DefaultParser$ArgumentList.escape(DefaultParser.java:383)
at org.jline.reader.impl.LineReaderImpl$MenuSupport.update(LineReaderImpl.java:4403)
at org.jline.reader.impl.LineReaderImpl$MenuSupport.next(LineReaderImpl.java:4317)
at org.jline.reader.impl.LineReaderImpl.doMenu(LineReaderImpl.java:4471)
at org.jline.reader.impl.LineReaderImpl.doList(LineReaderImpl.java:4614)
at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4149)
at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:3875)
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:585)
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:443)
at REPLReader.readLine(REPLReader.java:99)
at Compiler.getInputCode(Compiler.java:24)
at CompilerMain.lex(CompilerMain.java:75)
at CompilerMain.compile(CompilerMain.java:15)
at Main.main(Main.java:59)
英文:
I am working on a project with jline version3 in java but in completion, I need to have "else if" but it puts \ to escape space as an escape character and I don't have any escape character also I tried null
instead of a char[]
but it crashes with null pointer exception
also, I checked https://github.com/jline/jline3/issues/173
Error is:
at org.jline.reader.impl.DefaultParser$ArgumentList.escape(DefaultParser.java:383)
at org.jline.reader.impl.LineReaderImpl$MenuSupport.update(LineReaderImpl.java:4403)
at org.jline.reader.impl.LineReaderImpl$MenuSupport.next(LineReaderImpl.java:4317)
at org.jline.reader.impl.LineReaderImpl.doMenu(LineReaderImpl.java:4471)
at org.jline.reader.impl.LineReaderImpl.doList(LineReaderImpl.java:4614)
at org.jline.reader.impl.LineReaderImpl.doComplete(LineReaderImpl.java:4149)
at org.jline.reader.impl.LineReaderImpl.expandOrComplete(LineReaderImpl.java:3875)
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:585)
at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:443)
at REPLReader.readLine(REPLReader.java:99)
at Compiler.getInputCode(Compiler.java:24)
at CompilerMain.lex(CompilerMain.java:75)
at CompilerMain.compile(CompilerMain.java:15)
at Main.main(Main.java:59)
答案1
得分: 0
我假设您正在使用JLine内置的StringsCompleter
和DefaultParser
作为自动补全功能。
如果您的自动补全候选包含空格字符,则:
- 如果
defaultParser.escapeChars != null
,则空格字符将被转义;
或者 - 如果
defaultParser.escapeChars == null
,则自动补全候选将被引用。
这就是StringsCompleter
的工作原理。
请参阅StringsCompleterTest.java中的方法:escapeCharsNull()
和escapeChars()
。
空指针异常(NPE)在提交68a9c1f中已修复。您应该使用JLine版本3.10或更高版本。
英文:
I assume that you are using JLine builtin completer StringsCompleter
and DefaultParser
.
If you have completion candidate that have space character(s) then either
- space chars are escaped if
defaultParser.escapeChars != null
or - completion candidate will be quoted if
defaultParser.escapeChars == null
.
That is how StringsCompleter
is supposed to work.
See StringsCompleterTest.java methods: escapeCharsNull()
and escapeChars()
.
NPE is fixed in commit 68a9c1f. You should use JLine version 3.10 or greater.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论