Comments (5)
According to :help undojoin
, calling getchar()
should start a new change. That does not seem to be the case if the code using getchar()
is in a callback.
from vim.
According to
:help undojoin
, callinggetchar()
should start a new change. That does not seem to be the case if the code usinggetchar()
is in a callback.
I don't think that's the case. It just recommends that you use :undojoin
before calling getchar()
.
from vim.
I agree with @zeertzjq reading of the help.
from vim.
I beg to disagree. The help describes a case where undojoin
is necessary to merge two changes with a getchar()
in between exactly because
the next key press will start a new change
In fact, that is what happens:
vim9script
def Foo()
normal aX
getchar()
normal aY
undo
enddef
Foo()
X
remains in the buffer after the undo. But if the function is used as a callback, it behaves as if undojoin
has been added. That is, in the following script:
vim9script
def Foo()
normal aX
getchar()
normal aY
undo
enddef
job_start(['ls'], {'close_cb': (_) => Foo()})
Foo()
behaves the same as in:
vim9script
def Foo()
normal aX
getchar()
undojoin
normal aY
undo
enddef
Foo()
I would like the function invoked as a job_start()
's callback to behave the same as if invoked directly.
[Edited for clarity]
from vim.
A workaround for this issue is to force a new change:
def Foo()
normal aX
getchar()
execute "normal" "i\<c-g>u"
normal aY
undo
enddef
Similarly, my original example is fixed by adding execute "normal" "i\<c-g>u"
before (or after) getcharstr()
.
from vim.
Related Issues (20)
- :Termdebug returns E1012: Type mismatch (expected string got list<string>) if g:termdebugger set HOT 8
- vim.vim: Outermost _foreign_ comments after :endfun _or_ :endef are not recognised HOT 1
- The execution result of enum variable in `==` is incorrect in vim9script HOT 6
- cursormovedc didnot work when c-w or c-u HOT 13
- let g:netrw_liststyle = 2 clobbers registers HOT 8
- Built in full vim syntax support for Podman Quadlet unit files
- [vim9class] `echo obj` puts vim into infinite loop requiring force kill
- [vim9class] incorrect type checking modifying list in class from outside class
- The `ps` output is truncated in the terminal HOT 4
- xxd.exe is detected by an awful lot of virus scanners HOT 5
- Fuzzy completion does not allow cycle back to original, wrong highlight, and Ctrl-P Ctrl-N issues HOT 1
- Add `get({func}, 'arity')` to determine the number of expected arguments to a funcref
- Termdebug: use conpty with Windows. HOT 3
- mousemodel=popup not working properly with many items on PopUp menu
- manpager.vim emits a "Changing a readonly file" error/warning
- foldexpr '<1' results in a level-3 fold HOT 2
- Clarification on expected behavior of <S-CR>
- A correction to the docs
- Clipboard and primary selection registers not working despite +clipboard HOT 7
- incsearch option to highlight matches without moving the cursor HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim.