From 1118bfdf71ac0683bd2150e6c719c7ea3bcd0555 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 20 May 2024 15:54:09 -0700 Subject: [PATCH] Add clang format to action (#73) --- .github/workflows/check.yml | 27 ++++++++++++++++----------- src/libime/pinyin/pinyinencoder.cpp | 3 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3b01fe1..15297f7 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,5 +1,4 @@ name: CI - on: push: branches: @@ -7,10 +6,21 @@ on: pull_request: branches: - master - jobs: + clang-format: + name: Check clang-format + runs-on: ubuntu-latest + container: archlinux:latest + steps: + - name: Install dependencies + run: | + pacman -Syu --noconfirm git clang diffutils + git config --global --add safe.directory $GITHUB_WORKSPACE + - uses: actions/checkout@v4 + - uses: fcitx/github-actions@clang-format check: name: Build and test + needs: clang-format runs-on: ubuntu-latest container: archlinux:latest strategy: @@ -37,20 +47,15 @@ jobs: uses: actions/cache@v4 with: path: 'fcitx5/**/*.tar.*' - key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') }} + key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') + }} - name: Build and Install fcitx5 uses: fcitx/github-actions@cmake with: path: fcitx5 cmake-option: >- - -DENABLE_KEYBOARD=Off - -DENABLE_X11=Off - -DENABLE_WAYLAND=Off - -DENABLE_ENCHANT=Off - -DENABLE_DBUS=Off - -DENABLE_SERVER=Off - -DENABLE_EMOJI=Off - -DUSE_SYSTEMD=Off + -DENABLE_KEYBOARD=Off -DENABLE_X11=Off -DENABLE_WAYLAND=Off -DENABLE_ENCHANT=Off + -DENABLE_DBUS=Off -DENABLE_SERVER=Off -DENABLE_EMOJI=Off -DUSE_SYSTEMD=Off - uses: actions/checkout@v4 with: path: libime diff --git a/src/libime/pinyin/pinyinencoder.cpp b/src/libime/pinyin/pinyinencoder.cpp index f814c15..671b47b 100644 --- a/src/libime/pinyin/pinyinencoder.cpp +++ b/src/libime/pinyin/pinyinencoder.cpp @@ -226,7 +226,8 @@ PinyinEncoder::parseUserPinyin(std::string userPinyin, str.back() == 'o' || str.back() == 'r' || str.back() == 'h' || fuzzyFlags.test(PinyinFuzzyFlag::Correction)) && - hasMatchInMap(pinyinMap, str.substr(0, str.size() - 1), fuzzyFlags)) { + hasMatchInMap(pinyinMap, str.substr(0, str.size() - 1), + fuzzyFlags)) { // str[0:-1] is also a full pinyin, check next pinyin auto nextMatch = longestMatch(iter + str.size(), end, fuzzyFlags, pinyinMap);