Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows line endings #109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ jobs:
name: Unit Tests
strategy:
matrix:
# os: [ windows-2022, ubuntu-20.04 ]
os: [ ubuntu-20.04 ]
os: [ windows-2022, ubuntu-20.04 ]
include:
# - os: windows-2022
# NEOVIM_CONFIG_PATH: ~/AppData/Local/nvim
- os: windows-2022
NEOVIM_CONFIG_PATH: ~/AppData/Local/nvim
- os: ubuntu-20.04
NEOVIM_CONFIG_PATH: $HOME/.config/nvim
runs-on: ${{ matrix.os }}
Expand All @@ -45,11 +44,11 @@ jobs:
mkdir -p "$HOME/bin"
ln -s /bin/echo "$HOME/bin/code-minimap"
echo "$HOME/bin" >> $GITHUB_PATH
# - if: ${{ contains(matrix.os, 'windows') }}
# name: Create a fake code-minimap executable (Windows)
# run: |
# mkdir -p ~/bin
# cp C:/Windows/System32/doskey.exe ~/bin/code-minimap.exe
- if: ${{ contains(matrix.os, 'windows') }}
name: Create a fake code-minimap executable (Windows)
run: |
mkdir -p ~/bin
cp C:/Windows/System32/doskey.exe ~/bin/code-minimap.exe

- name: Checkout Testify
run: |
Expand Down
18 changes: 15 additions & 3 deletions autoload/minimap/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,17 @@ endfunction
function! s:minimap_color_git(win_info) abort
" Get git info
let git_call = 'git diff -U0 -- ' . expand('%')
let git_diff = substitute(system(git_call), '\n\+&', '', '') | silent echo strtrans(git_diff)
let newline_char = '\n'
if has('win32')
let newline_char = '\r\n'
endif
let git_diff = substitute(system(git_call), newline_char . '\+&', '', '') | silent echo strtrans(git_diff)

let lines = split(git_diff, '\n')
let split_char = '\n'
if has('win32')
let split_char = '\r\n'
endif
let lines = split(git_diff, split_char)
let diff_list = []
for line in lines
if line[0] ==? '@'
Expand Down Expand Up @@ -855,7 +863,11 @@ function! s:minimap_color_search_get_spans(win_info, query) abort
if type(a:query) != type(0)
let last_search = a:query
else
let tmp = split(execute('his /'), '\n')
let split_char = '\n'
if has('win32')
let split_char = '\r\n'
endif
let tmp = split(execute('his /'), split_char)
let tmp = split(tmp[len(tmp)-a:query], '', 1)
" echom 'tmp: ' . join(tmp)
let last_search = join(tmp[2:-1])
Expand Down
34 changes: 21 additions & 13 deletions t/search_tests.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ let s:testfile = expand('%')

" Search tests
function! s:minimap_test_search()
" Create the subjest of our search
" Create the subject of our search
let newline_char = '\n'
if has('win32')
let newline_char = '\r\n'
endif
let test_file = '/tmp/minimap_search_unit_test_file'
let text = 'This is a test line and it needs to be long enough to register as multiple braille characters.\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'pad height\n'
let text = text . 'And another, this one is shorter\n'
let text = 'This is a test line and it needs to be long enough to register as multiple braille characters.' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'pad height' . newline_char
let text = text . 'And another, this one is shorter' . newline_char
let text = text . 'and flows to the numbers line, this one, this one has some numbers 1234 numbers'
execute 'silent !echo "' . text . '" > ' . test_file
execute 'edit ' . test_file
Expand Down Expand Up @@ -61,7 +65,11 @@ function! s:minimap_test_search_multi_per_line()
endfunction
function! s:minimap_test_search_spanning_a_line()
" Spanning a line (should be empty, not supported yet)
let search = 'shorter\nand flows'
let newline_char = '\n'
if has('win32')
let newline_char = '\r\n'
endif
let search = 'shorter' . newline_char . 'and flows'
let expected_list = [ ]
let actual_list = minimap#vim#MinimapColorSearchGetSpans(s:win_info, search)
call testify#assert#equals(actual_list, expected_list)
Expand Down