Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into jline-1103
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Dec 10, 2024
2 parents c48e114 + 99b5b6c commit 799d9cb
Show file tree
Hide file tree
Showing 30 changed files with 341 additions and 129 deletions.
80 changes: 80 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: $NEXT_PATCH_VERSION
tag-template: $NEXT_PATCH_VERSION
version-template: $MAJOR.$MINOR.$PATCH

# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: ":boom: Breaking changes"
labels:
- breaking
- title: 🚨 Removed
label: removed
- title: ":tada: Major features and improvements"
labels:
- major-enhancement
- major-rfe
- title: 🐛 Major bug fixes
labels:
- major-bug
- title: ⚠️ Deprecated
label: deprecated
- title: 🚀 New features and improvements
labels:
- enhancement
- feature
- rfe
- title: 🐛 Bug Fixes
labels:
- bug
- fix
- bugfix
- regression
- title: ":construction_worker: Changes for developers"
labels:
- developer
# Default label used by Dependabot
- title: 📦 Dependency updates
label: dependencies
- title: 📝 Documentation updates
label: documentation
- title: 👻 Maintenance
labels:
- chore
- internal
- maintenance
- title: 🔧 Build
label: build
- title: 🚦 Tests
labels:
- test
- tests
exclude-labels:
- reverted
- no-changelog
- skip-changelog
- invalid

change-template: '- $TITLE ([#$NUMBER]($URL)) @$AUTHOR'

template: |
<!-- Optional: add a release summary here -->
$CHANGES
45 changes: 45 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Release drafter
#

name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
# pull_request_target:
# types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v6
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 14 additions & 14 deletions builtins/src/main/java/org/jline/builtins/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ public static void history(LineReader reader, PrintStream out, PrintStream err,
} else if (opt.isSet("save")) {
history.save();
} else if (opt.isSet("A")) {
Path file = opt.args().size() > 0 ? currentDir.resolve(opt.args().get(0)) : null;
Path file = !opt.args().isEmpty() ? currentDir.resolve(opt.args().get(0)) : null;
history.append(file, increment);
} else if (opt.isSet("R")) {
Path file = opt.args().size() > 0 ? currentDir.resolve(opt.args().get(0)) : null;
Path file = !opt.args().isEmpty() ? currentDir.resolve(opt.args().get(0)) : null;
history.read(file, increment);
} else if (opt.isSet("W")) {
Path file = opt.args().size() > 0 ? currentDir.resolve(opt.args().get(0)) : null;
Path file = !opt.args().isEmpty() ? currentDir.resolve(opt.args().get(0)) : null;
history.write(file, increment);
} else {
done = false;
Expand Down Expand Up @@ -361,7 +361,7 @@ public ReExecute(History history, Options opt) throws IOException {
if (edit) {
cmdFile = File.createTempFile("jline-history-", null);
cmdWriter = new FileWriter(cmdFile);
} else if (opt.args().size() > 0) {
} else if (!opt.args().isEmpty()) {
String[] s = opt.args().get(argId).split("=");
if (s.length == 2) {
argId = argId + 1;
Expand Down Expand Up @@ -640,7 +640,7 @@ public static void keymap(LineReader reader, PrintStream out, PrintStream err, S
if (opt.isSet("l")) {
boolean commands = opt.isSet("L");
// TODO: handle commands
if (opt.args().size() > 0) {
if (!opt.args().isEmpty()) {
for (String arg : opt.args()) {
KeyMap<Binding> map = keyMaps.get(arg);
if (map == null) {
Expand Down Expand Up @@ -704,7 +704,7 @@ public static void keymap(LineReader reader, PrintStream out, PrintStream err, S
err.println("keymap: keymap can not be selected with -N");
return;
}
if (opt.args().size() > 0) {
if (!opt.args().isEmpty()) {
err.println("keymap: too many arguments for -d");
return;
}
Expand Down Expand Up @@ -869,9 +869,9 @@ public static void keymap(LineReader reader, PrintStream out, PrintStream err, S
err.println("keymap: option -p requires a prefix string");
return;
}
if (opt.args().size() > 0 || !opt.isSet("e") && !opt.isSet("v")) {
if (!opt.args().isEmpty() || !opt.isSet("e") && !opt.isSet("v")) {
Map<String, Binding> bound = map.getBoundKeys();
String seq = opt.args().size() > 0 ? KeyMap.translate(opt.args().get(0)) : null;
String seq = !opt.args().isEmpty() ? KeyMap.translate(opt.args().get(0)) : null;
Map.Entry<String, Binding> begin = null;
String last = null;
Iterator<Entry<String, Binding>> iterator = bound.entrySet().iterator();
Expand Down Expand Up @@ -1682,21 +1682,21 @@ public static void highlighter(
pathStream.filter(pathMatcher::matches).forEach(p -> out.println(p.getFileName()));
}
} else {
File themeFile;
Path themeFile;
if (opt.isSet("view")) {
themeFile = new File(replaceFileName(currentTheme, opt.get("view")));
themeFile = Paths.get(replaceFileName(currentTheme, opt.get("view")));
} else {
themeFile = currentTheme.toFile();
themeFile = currentTheme;
}
out.println(themeFile.getAbsolutePath());
try (BufferedReader reader = new BufferedReader(new FileReader(themeFile))) {
out.println(themeFile.toAbsolutePath());
try (BufferedReader reader = Files.newBufferedReader(themeFile)) {
String line;
List<List<String>> tokens = new ArrayList<>();
int maxKeyLen = 0;
int maxValueLen = 0;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.length() > 0 && !line.startsWith("#")) {
if (!line.isEmpty() && !line.startsWith("#")) {
List<String> parts = Arrays.asList(line.split("\\s+", 2));
if (parts.get(0).matches(REGEX_TOKEN_NAME)) {
if (parts.get(0).length() > maxKeyLen) {
Expand Down
39 changes: 18 additions & 21 deletions builtins/src/main/java/org/jline/builtins/Less.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -218,11 +217,11 @@ public Less(Terminal terminal, Path currentDir, Options opts, ConfigurationPath
}

private void parseConfig(Path file) throws IOException {
try (BufferedReader reader = new BufferedReader(new FileReader(file.toFile()))) {
try (BufferedReader reader = Files.newBufferedReader(file)) {
String line = reader.readLine();
while (line != null) {
line = line.trim();
if (line.length() > 0 && !line.startsWith("#")) {
if (!line.isEmpty() && !line.startsWith("#")) {
List<String> parts = SyntaxHighlighter.RuleSplitter.split(line);
if (parts.get(0).equals(COMMAND_INCLUDE)) {
SyntaxHighlighter.nanorcInclude(parts.get(1), syntaxFiles);
Expand Down Expand Up @@ -840,20 +839,18 @@ private void addFile() throws IOException, InterruptedException {
LineEditor lineEditor = new LineEditor(begPos);
while (true) {
checkInterrupted();
Operation op;
switch (op = bindingReader.readBinding(fileKeyMap)) {
case ACCEPT:
String name = buffer.substring(begPos);
addSource(name);
try {
openSource();
} catch (Exception exp) {
ssp.restore(name);
}
return;
default:
curPos = lineEditor.editBuffer(op, curPos);
break;
Operation op = bindingReader.readBinding(fileKeyMap);
if (op == Operation.ACCEPT) {
String name = buffer.substring(begPos);
addSource(name);
try {
openSource();
} catch (Exception exp) {
ssp.restore(name);
}
return;
} else if (op != null) {
curPos = lineEditor.editBuffer(op, curPos);
}
if (curPos > begPos) {
display(false, curPos);
Expand Down Expand Up @@ -911,7 +908,7 @@ private boolean search() throws IOException, InterruptedException {
try {
String _pattern = buffer.substring(1);
if (type == '&') {
displayPattern = _pattern.length() > 0 ? _pattern : null;
displayPattern = !_pattern.isEmpty() ? _pattern : null;
getPattern(true);
} else {
pattern = _pattern;
Expand Down Expand Up @@ -1025,7 +1022,7 @@ protected void openSource() throws IOException {
if (displayMessage) {
AttributedStringBuilder asb = new AttributedStringBuilder();
asb.style(AttributedStyle.INVERSE);
asb.append(source.getName() + " (press RETURN)");
asb.append(source.getName()).append(" (press RETURN)");
asb.toAttributedString().println(terminal);
terminal.writer().flush();
terminal.reader().read();
Expand All @@ -1039,7 +1036,7 @@ protected void openSource() throws IOException {
throw exp;
} else {
AttributedStringBuilder asb = new AttributedStringBuilder();
asb.append(source.getName() + " not found!");
asb.append(source.getName()).append(" not found!");
asb.toAttributedString().println(terminal);
terminal.writer().flush();
open = false;
Expand Down Expand Up @@ -1384,7 +1381,7 @@ synchronized boolean display(boolean oneScreen, Integer curPos) throws IOExcepti
}
if (buffer.length() > 0) {
msg.append(" ").append(buffer);
} else if (bindingReader.getCurrentBuffer().length() > 0
} else if (!bindingReader.getCurrentBuffer().isEmpty()
&& terminal.reader().peek(1) == NonBlockingReader.READ_EXPIRED) {
msg.append(" ").append(printable(bindingReader.getCurrentBuffer()));
} else if (message != null) {
Expand Down
Loading

0 comments on commit 799d9cb

Please sign in to comment.