Skip to content

Commit

Permalink
Merge branch 'revert-marks'
Browse files Browse the repository at this point in the history
Close gh-59.
  • Loading branch information
kana committed Sep 28, 2017
2 parents faeecf5 + ef9df2d commit e231b65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
35 changes: 3 additions & 32 deletions autoload/textobj/user.vim
@@ -1,5 +1,5 @@
" textobj-user - Create your own text objects
" Version: 0.7.4
" Version: 0.7.5
" Copyright (C) 2007-2017 Kana Natsuno <http://whileimautomaton.net/>
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
Expand Down Expand Up @@ -443,24 +443,14 @@ endfunction

function! s:plugin.define_interface_key_mappings() "{{{3
let RHS_FORMAT =
\ '%s'
\ . ':<C-u>call g:__textobj_' . self.name . '.%s('
\ ':<C-u>call g:__textobj_' . self.name . '.%s('
\ . '"%s",'
\ . '"%s",'
\ . '"<mode>"'
\ . ')<Return>'
\ . '%s'

for [obj_name, specs] in items(self.obj_specs)
for spec_name in filter(keys(specs), 's:is_ui_property_name(v:val)')
if spec_name =~# '^move'
let save = ''
let restore = ''
else " spec_name =~# '^select'
let save = '<SID>(save-marks)'
let restore = '<SID>(restore-marks)'
endif

" lhs
let lhs = self.interface_mapping_name(obj_name, spec_name)

Expand All @@ -474,7 +464,7 @@ function! s:plugin.define_interface_key_mappings() "{{{3
" skip to allow to define user's own {rhs} of the interface mapping.
continue
endif
let rhs = printf(RHS_FORMAT, save, do, spec_name, obj_name, restore)
let rhs = printf(RHS_FORMAT, do, spec_name, obj_name)

" map
if spec_name =~# '^move'
Expand Down Expand Up @@ -781,25 +771,6 @@ function! s:fail(interface_key_mapping_lhs)
throw printf('Text object %s is not defined', a:interface_key_mapping_lhs)
endfunction

noremap <expr> <SID>(save-marks) <SID>save_marks()
noremap! <expr> <SID>(save-marks) <SID>save_marks()
noremap <expr> <SID>(restore-marks) <SID>restore_marks()
noremap! <expr> <SID>(restore-marks) <SID>restore_marks()
let s:original_marks = {}

function! s:save_marks()
let s:original_marks['<'] = getpos("'<")
let s:original_marks['>'] = getpos("'>")
return ''
endfunction

function! s:restore_marks()
call setpos("'<", s:original_marks['<'])
call setpos("'>", s:original_marks['>'])
return ''
endfunction




Expand Down
6 changes: 5 additions & 1 deletion doc/textobj-user.txt
@@ -1,6 +1,6 @@
*textobj-user.txt* Create your own text objects

Version 0.7.4
Version 0.7.5
Script ID: 2100
Copyright (C) 2007-2017 Kana Natsuno <http://whileimautomaton.net/>
License: MIT license {{{
Expand Down Expand Up @@ -565,6 +565,10 @@ KNOWN ISSUES *textobj-user-known-issues*
==============================================================================
CHANGELOG *textobj-user-changelog*

0.7.5 2017-09-28T20:38:39+09:00 *textobj-user-changelog-0.7.5*
- Revert changes from 0.7.3-0.7.4 for compatibility with custom
operators which use |getchar()|.

0.7.4 2017-09-25T20:42:58+09:00 *textobj-user-changelog-0.7.4*
- Fix a bug that random characters are inserted if custom text objects
are used with |c|.
Expand Down
6 changes: 6 additions & 0 deletions t/keep-marks.vim
Expand Up @@ -42,6 +42,8 @@ describe 'Custom text object'

context 'defined by a function'
it 'keeps ''< and ''> marks'
TODO

Expect @0 ==# '*nothing changed*'
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]
Expand All @@ -56,6 +58,8 @@ describe 'Custom text object'

context 'defined by a pattern'
it 'keeps ''< and ''> marks'
TODO

Expect @0 ==# '*nothing changed*'
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]
Expand All @@ -70,6 +74,8 @@ describe 'Custom text object'

context 'combined with operator c'
it 'also works fine'
TODO

Expect @" ==# '*nothing changed*'
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]
Expand Down

0 comments on commit e231b65

Please sign in to comment.