diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 91533085..0899efee 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -2,17 +2,18 @@ name: CICD env: PROJECT_NAME: bat + PROJECT_VERSION: "0.17.1" PROJECT_DESC: "A `cat` clone with wings" PROJECT_MAINTAINER: "David Peter " PROJECT_HOMEPAGE: "https://github.com/sharkdp/bat" - MIN_SUPPORTED_RUST_VERSION: "1.40.0" + MIN_SUPPORTED_RUST_VERSION: "1.42.0" on: [push, pull_request] jobs: min_version: name: Minimum supported rust version - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 steps: - name: Git checkout uses: actions/checkout@v2 @@ -27,7 +28,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --all-targets --all-features -- --allow clippy::style + args: --all-targets --all-features - name: Test uses: actions-rs/cargo@v1 with: @@ -35,7 +36,7 @@ jobs: test_with_new_syntaxes_and_themes: name: Test with new syntaxes and themes - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 steps: - name: Git checkout uses: actions/checkout@v2 @@ -83,19 +84,17 @@ jobs: fail-fast: false matrix: job: - # { os, target, cargo-options, features, use-cross } - - { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , use-cross: true } - - { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: true } - - { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: true } - - { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: true } - - { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu } - - { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: true } - - { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu } - - { os: macos-latest , target: x86_64-apple-darwin } - # - { os: windows-latest , target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found - - { os: windows-latest , target: i686-pc-windows-msvc } - - { os: windows-latest , target: x86_64-pc-windows-gnu } - - { os: windows-latest , target: x86_64-pc-windows-msvc } + - { os: ubuntu-18.04 , target: arm-unknown-linux-gnueabihf , use-cross: true } + - { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: true } + - { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: true } + - { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: true } + - { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu } + - { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: true } + - { os: macos-10.15 , target: x86_64-apple-darwin } + # - { os: windows-2019 , target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found + - { os: windows-2019 , target: i686-pc-windows-msvc } + - { os: windows-2019 , target: x86_64-pc-windows-gnu } + - { os: windows-2019 , target: x86_64-pc-windows-msvc } steps: - name: Git checkout uses: actions/checkout@v2 @@ -116,26 +115,14 @@ jobs: # determine EXE suffix EXE_suffix="" ; case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac; echo ::set-output name=EXE_suffix::${EXE_suffix} - # parse commit reference info - unset REF_TAG ; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac; - REF_SHAS=${GITHUB_SHA:0:8} - # parse target - unset TARGET_ARCH ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac; - echo ::set-output name=TARGET_ARCH::${TARGET_ARCH} - unset TARGET_OS ; case ${{ matrix.job.target }} in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac; - echo ::set-output name=TARGET_OS::${TARGET_OS} # package name PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; - PKG_BASENAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.job.target }} + PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }} PKG_NAME=${PKG_BASENAME}${PKG_suffix} - echo ::set-output name=PKG_suffix::${PKG_suffix} echo ::set-output name=PKG_BASENAME::${PKG_BASENAME} echo ::set-output name=PKG_NAME::${PKG_NAME} - # deployable tag? (ie, leading "vM" or "M"; M == version number) - unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi - # unset deploy on ubuntu-18.04 x64 - we will deploy the tarball/deb built on ubuntu-16.04 x64 - if [ "${{ matrix.job.os }}" = "ubuntu-18.04" ] && [ "${{ matrix.job.target }}" = "x86_64-unknown-linux-gnu" ]; then unset DEPLOY; fi - echo ::set-output name=DEPLOY::${DEPLOY} + unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi + echo ::set-output name=IS_RELEASE::${IS_RELEASE} # DPKG architecture? unset DPKG_ARCH case ${{ matrix.job.target }} in @@ -145,8 +132,7 @@ jobs: x86_64-*-linux-*) DPKG_ARCH=amd64 ;; esac; echo ::set-output name=DPKG_ARCH::${DPKG_ARCH} - # DPKG version? - unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi + DPKG_VERSION=${PROJECT_VERSION} echo ::set-output name=DPKG_VERSION::${DPKG_VERSION} # DPKG base name/conflicts? DPKG_BASENAME=${PROJECT_NAME} @@ -159,10 +145,6 @@ jobs: if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi echo ::set-output name=DPKG_NAME::${DPKG_NAME} # target-specific options - # # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host) - JOB_DO_TESTING="true" - case ${{ matrix.job.target }} in arm-*) unset JOB_DO_TESTING ;; esac; - echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING} # # * test only library unit tests and binary for arm-type targets unset CARGO_TEST_OPTIONS unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}" ;; esac; @@ -241,11 +223,6 @@ jobs: use-cross: ${{ matrix.job.use-cross }} command: check args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git,paging - - name: Upload build artifacts - uses: actions/upload-artifact@master - with: - name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }} - path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }} - name: Package shell: bash run: | @@ -358,9 +335,20 @@ jobs: # build dpkg fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}" fi + - name: Upload package artifact + uses: actions/upload-artifact@master + with: + name: ${{ steps.vars.outputs.PKG_NAME }} + path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }} + - name: Upload Debian package artifact + uses: actions/upload-artifact@master + if: steps.vars.outputs.DPKG_NAME + with: + name: ${{ steps.vars.outputs.DPKG_NAME }} + path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }} - name: Publish archives and packages uses: softprops/action-gh-release@v1 - if: steps.vars.outputs.DEPLOY + if: steps.vars.outputs.IS_RELEASE with: files: | ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }} @@ -375,11 +363,10 @@ jobs: strategy: fail-fast: true matrix: - # job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ] job: - - { os: ubuntu-latest , toolchain: nightly-2020-04-29 } - - { os: macos-latest , toolchain: nightly-2020-04-29 } - - { os: windows-latest , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu } + - { os: ubuntu-18.04 , toolchain: nightly-2020-04-29 } + - { os: macos-10.15 , toolchain: nightly-2020-04-29 } + - { os: windows-2019 , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu } steps: - uses: actions/checkout@v2 - name: Initialize workflow variables diff --git a/.gitmodules b/.gitmodules index 99364ba6..3dcbc519 100644 --- a/.gitmodules +++ b/.gitmodules @@ -213,3 +213,6 @@ [submodule "assets/syntaxes/02_Extra/Zig"] path = assets/syntaxes/02_Extra/Zig url = https://github.com/ziglang/sublime-zig-language.git +[submodule "assets/syntaxes/02_Extra/gnuplot"] + path = assets/syntaxes/02_Extra/gnuplot + url = https://github.com/hesstobi/sublime_gnuplot diff --git a/CHANGELOG.md b/CHANGELOG.md index 322418ec..c9a24d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,23 +12,26 @@ - Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic) - VimL syntax highlighting fix, see #1450 (@esensar) - Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic) +- If plain mode is set and wrap is not explicitly opted in, long lines will no be truncated, see #1426 - If `PAGER` (but not `BAT_PAGER` or `--pager`) is `more` or `most`, silently use `less` instead to ensure support for colors, see #1063 (@Enselic) ## Other - Performance improvements, see #1421 (@LovecraftianHorror) - Added a new `--diagnostic` option to collect information for bug reports, see #1459 (@sharkdp) +- Upped min required Rust version to 1.42 ## Syntaxes - Added Zig syntax, see #1470 (@paulsmith) - Added Lean syntax, see #1446 (@Julian) - Added `.resource` extension for Robot Framework files, see #1386 +- Added `gnuplot` syntax, see #1431 (@sharkdp) ## New themes -- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12) -- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously usuing `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead. +- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12). **Breaking change:** users that were previously using one of the `ansi-*` themes should switch to `ansi`. +- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously using `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead. ## `bat` as a library diff --git a/Cargo.lock b/Cargo.lock index 4cf166fd..2521d7aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,9 +186,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "cc" @@ -589,9 +589,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" [[package]] name = "libgit2-sys" @@ -628,9 +628,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" @@ -903,9 +903,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -915,9 +915,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "remove_dir_all" @@ -1058,9 +1058,9 @@ checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" [[package]] name = "smallvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "snailquote" @@ -1190,9 +1190,9 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" dependencies = [ "lazy_static", ] diff --git a/README.md b/README.md index 9a31db62..4e953b1c 100644 --- a/README.md +++ b/README.md @@ -356,7 +356,7 @@ binaries are also available: look for archives with `musl` in the file name. ### From source -If you want to build `bat` from source, you need Rust 1.40 or +If you want to build `bat` from source, you need Rust 1.42 or higher. You can then use `cargo` to build everything: ```bash @@ -700,6 +700,7 @@ Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide. - [sharkdp](https://github.com/sharkdp) - [eth-p](https://github.com/eth-p) - [keith-hall](https://github.com/keith-hall) +- [Enselic](https://github.com/Enselic) ## Project goals and alternatives diff --git a/assets/syntaxes/02_Extra/gnuplot b/assets/syntaxes/02_Extra/gnuplot new file mode 160000 index 00000000..04743470 --- /dev/null +++ b/assets/syntaxes/02_Extra/gnuplot @@ -0,0 +1 @@ +Subproject commit 04743470ff90237ba3fb34ccf77c2d256d611262 diff --git a/assets/syntaxes/02_Extra/gnuplot.sublime-syntax b/assets/syntaxes/02_Extra/gnuplot.sublime-syntax new file mode 100644 index 00000000..65ca5621 --- /dev/null +++ b/assets/syntaxes/02_Extra/gnuplot.sublime-syntax @@ -0,0 +1,182 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: gnuplot +file_extensions: + - gp + - gpl + - gnuplot + - gnu + - plot + - plt +scope: source.gnuplot +contexts: + main: + - include: number + - include: string_single + - include: string_double + - match: '\b(for)\b\s*(\[)' + comment: | + gnuplot iteration statement. + There are two forms: + numeric [n = 1:2{:inc}] + string based [str in "x y z"] + but both can also iterate over lists etc, so this is kept loose. + captures: + 1: keyword.other.iteration.gnuplot + 2: punctuation.definition.range.begin.gnuplot + push: + - meta_scope: meta.structure.iteration.gnuplot + - match: '\]' + captures: + 0: punctuation.definition.range.end.gnuplot + pop: true + - include: number + - include: operator + - include: string_double + - include: string_single + - match: ":" + scope: punctuation.separator.range.gnuplot + - match: '\b([a-zA-Z]\w*)\b\s*(=|in)' + scope: variable-assignment.range.gnuplot + - match: '(?i:[^\s(pi|e)\]])' + scope: invalid.illegal.expected-range-separator.gnuplot + - match: '\[' + comment: "gnuplot range statement [a:b]. Lots of things are legal, still more make no sense!" + captures: + 0: punctuation.definition.range.begin.gnuplot + push: + - meta_scope: meta.structure.range.gnuplot + - match: '\]' + captures: + 0: punctuation.definition.range.end.gnuplot + pop: true + - include: number + - include: operator + - match: ":" + scope: punctuation.separator.range.gnuplot + - match: '(?i:[^\s(pi|e)\]])' + scope: invalid.illegal.expected-range-separator.gnuplot + - match: \\. + scope: constant.character.escape.gnuplot + - match: '(?|>=|<|<=|&|&&|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s* + comment: Operator symbols + scope: keyword.operator.symbols.matlab + string_double: + - match: '"' + captures: + 0: punctuation.definition.string.begin.gnuplot + push: + - meta_scope: string.quoted.double.gnuplot + - match: '"' + captures: + 0: punctuation.definition.string.end.gnuplot + pop: true + - match: '\\[\$`"\\\n]' + scope: constant.character.escape.gnuplot + string_single: + - match: "'" + captures: + 0: punctuation.definition.string.begin.gnuplot + push: + - meta_scope: string.quoted.single.gnuplot + - match: "'" + captures: + 0: punctuation.definition.string.end.gnuplot + pop: true diff --git a/doc/README-ru.md b/doc/README-ru.md index 552fff24..321d3c8c 100644 --- a/doc/README-ru.md +++ b/doc/README-ru.md @@ -341,7 +341,7 @@ ansible-galaxy install aeimer.install_bat ### Из исходников -Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.40 или выше. После этого используйте `cargo`, чтобы все скомпилировать: +Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.42 или выше. После этого используйте `cargo`, чтобы все скомпилировать: ```bash cargo install --locked bat diff --git a/doc/assets.md b/doc/assets.md index 9aa2a87c..d30d3ab8 100644 --- a/doc/assets.md +++ b/doc/assets.md @@ -23,7 +23,7 @@ in the `.sublime-syntax` format. 5. Use `bat --list-languages` to check if the new languages are available. -6. Add a syntax test for the new language. See [#Syntax-tests](below) for details. +6. Add a syntax test for the new language. See [below](#Syntax-tests) for details. 7. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin` file. A new binary cache file will be created once before every new release of `bat`. diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 3d0df0ec..34f3f76c 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -150,10 +150,10 @@ impl App { wrapping_mode: if self.interactive_output || maybe_term_width.is_some() { match self.matches.value_of("wrap") { Some("character") => WrappingMode::Character, - Some("never") => WrappingMode::NoWrapping, + Some("never") => WrappingMode::NoWrapping(true), Some("auto") | None => { if style_components.plain() { - WrappingMode::NoWrapping + WrappingMode::NoWrapping(false) } else { WrappingMode::Character } @@ -163,7 +163,7 @@ impl App { } else { // We don't have the tty width when piping to another program. // There's no point in wrapping when this is the case. - WrappingMode::NoWrapping + WrappingMode::NoWrapping(false) }, colored_output: self.matches.is_present("force-colorization") || match self.matches.value_of("color") { diff --git a/src/bin/bat/input.rs b/src/bin/bat/input.rs index 9b596274..8e65d800 100644 --- a/src/bin/bat/input.rs +++ b/src/bin/bat/input.rs @@ -2,7 +2,7 @@ use bat::input::Input; use std::ffi::OsStr; pub fn new_file_input<'a>(file: &'a OsStr, name: Option<&'a OsStr>) -> Input<'a> { - named(Input::ordinary_file(file), name.or_else(|| Some(file))) + named(Input::ordinary_file(file), name.or(Some(file))) } pub fn new_stdin_input(name: Option<&OsStr>) -> Input { diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index e2862fe9..13d5ddb5 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -205,7 +205,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> { and are added to the cache with `bat cache --build`. \ For more information, see:\n\n \ https://github.com/sharkdp/bat#adding-new-themes", - config_file().join("themes").to_string_lossy() + PROJECT_DIRS.config_dir().join("themes").to_string_lossy() )?; } else { for theme in assets.themes() { @@ -237,10 +237,10 @@ fn run() -> Result { .info(EnvironmentVariables::list(&[ "SHELL", "PAGER", + "BAT_PAGER", "BAT_CACHE_PATH", "BAT_CONFIG_PATH", "BAT_OPTS", - "BAT_PAGER", "BAT_STYLE", "BAT_TABS", "BAT_THEME", @@ -248,6 +248,7 @@ fn run() -> Result { "XDG_CACHE_HOME", "COLORTERM", "NO_COLOR", + "MANPAGER", ])) .info(FileContent::new("Config file", config_file())) .info(CompileTimeInformation::default()) diff --git a/src/input.rs b/src/input.rs index 5b6a4e67..1e7aec2f 100644 --- a/src/input.rs +++ b/src/input.rs @@ -137,11 +137,7 @@ impl<'a> Input<'a> { } pub fn is_stdin(&self) -> bool { - if let InputKind::StdIn = self.kind { - true - } else { - false - } + matches!(self.kind, InputKind::StdIn) } pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self { diff --git a/src/output.rs b/src/output.rs index f0662060..539ea645 100644 --- a/src/output.rs +++ b/src/output.rs @@ -81,7 +81,7 @@ impl OutputType { p.arg("--quit-if-one-screen"); } - if wrapping_mode == WrappingMode::NoWrapping { + if wrapping_mode == WrappingMode::NoWrapping(true) { p.arg("--chop-long-lines"); } @@ -121,11 +121,7 @@ impl OutputType { #[cfg(feature = "paging")] pub(crate) fn is_pager(&self) -> bool { - if let OutputType::Pager(_) = self { - true - } else { - false - } + matches!(self, OutputType::Pager(_)) } #[cfg(not(feature = "paging"))] diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index cdf22df9..272e073b 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -320,6 +320,12 @@ impl<'a> PrettyPrinter<'a> { } } +impl Default for PrettyPrinter<'_> { + fn default() -> Self { + Self::new() + } +} + /// An input source for the pretty printer. pub struct Input<'a> { input: input::Input<'a>, diff --git a/src/printer.rs b/src/printer.rs index a4b143d4..45caf157 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -424,7 +424,7 @@ impl<'a> Printer for InteractivePrinter<'a> { } // Line contents. - if self.config.wrapping_mode == WrappingMode::NoWrapping { + if matches!(self.config.wrapping_mode, WrappingMode::NoWrapping(_)) { let true_color = self.config.true_color; let colored_output = self.config.colored_output; let italics = self.config.use_italic_text; diff --git a/src/wrapping.rs b/src/wrapping.rs index 6138606e..57201750 100644 --- a/src/wrapping.rs +++ b/src/wrapping.rs @@ -1,11 +1,12 @@ #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum WrappingMode { Character, - NoWrapping, + // The bool specifies whether wrapping has been explicitly disabled by the user via --wrap=never + NoWrapping(bool), } impl Default for WrappingMode { fn default() -> Self { - WrappingMode::NoWrapping + WrappingMode::NoWrapping(false) } } diff --git a/tests/assets.rs b/tests/assets.rs index d5de9015..fc01d9e8 100644 --- a/tests/assets.rs +++ b/tests/assets.rs @@ -8,7 +8,7 @@ fn all_themes_are_present() { let assets = HighlightingAssets::from_binary(); let mut themes: Vec<_> = assets.themes().collect(); - themes.sort(); + themes.sort_unstable(); assert_eq!( themes, diff --git a/tests/snapshot_tests.rs b/tests/snapshot_tests.rs index 8abb8414..14c3eee1 100644 --- a/tests/snapshot_tests.rs +++ b/tests/snapshot_tests.rs @@ -7,7 +7,7 @@ macro_rules! snapshot_tests { $( #[test] fn $test_name() { - let bat_tester = BatTester::new(); + let bat_tester = BatTester::default(); bat_tester.test_snapshot(stringify!($test_name), $style); } )* diff --git a/tests/syntax-tests/highlighted/gnuplot/test.gp b/tests/syntax-tests/highlighted/gnuplot/test.gp new file mode 100644 index 00000000..bb96f60d --- /dev/null +++ b/tests/syntax-tests/highlighted/gnuplot/test.gp @@ -0,0 +1,19 @@ +set terminal pngcairo enhanced +set output "/tmp/polynomial.png" + +set grid + +set xrange [-5:5] +set yrange [-5:10] + +set samples 10000 + +set key bottom right + +f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5 + +plot \ + f(x) title "polynomial of degree 4" \ + with lines \ + linewidth 2 \ + linetype rgb '#0077ff' diff --git a/tests/syntax-tests/source/gnuplot/test.gp b/tests/syntax-tests/source/gnuplot/test.gp new file mode 100644 index 00000000..411cf134 --- /dev/null +++ b/tests/syntax-tests/source/gnuplot/test.gp @@ -0,0 +1,19 @@ +set terminal pngcairo enhanced +set output "/tmp/polynomial.png" + +set grid + +set xrange [-5:5] +set yrange [-5:10] + +set samples 10000 + +set key bottom right + +f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5 + +plot \ + f(x) title "polynomial of degree 4" \ + with lines \ + linewidth 2 \ + linetype rgb '#0077ff' diff --git a/tests/tester.rs b/tests/tester.rs index 9c52459f..8a1a0f3b 100644 --- a/tests/tester.rs +++ b/tests/tester.rs @@ -19,23 +19,6 @@ pub struct BatTester { } impl BatTester { - pub fn new() -> Self { - let temp_dir = create_sample_directory().expect("sample directory"); - - let root = env::current_exe() - .expect("tests executable") - .parent() - .expect("tests executable directory") - .parent() - .expect("bat executable directory") - .to_path_buf(); - - let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" }; - let exe = root.join(exe_name); - - BatTester { temp_dir, exe } - } - pub fn test_snapshot(&self, name: &str, style: &str) { let output = Command::new(&self.exe) .current_dir(self.temp_dir.path()) @@ -66,6 +49,25 @@ impl BatTester { } } +impl Default for BatTester { + fn default() -> Self { + let temp_dir = create_sample_directory().expect("sample directory"); + + let root = env::current_exe() + .expect("tests executable") + .parent() + .expect("tests executable directory") + .parent() + .expect("bat executable directory") + .to_path_buf(); + + let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" }; + let exe = root.join(exe_name); + + BatTester { temp_dir, exe } + } +} + fn create_sample_directory() -> Result { // Create temp directory and initialize repository let temp_dir = TempDir::new("bat-tests").expect("Temp directory");