-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into improve-foldfix
- Loading branch information
Showing
10 changed files
with
216 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { configuration } from './../configuration/configuration'; | ||
import { VimState } from './../state/vimState'; | ||
import { ModeName } from './../mode/mode'; | ||
|
||
const modes = {}; | ||
|
||
modes[ModeName.Normal] = { | ||
'<left>': '<', | ||
'<right>': '>', | ||
}; | ||
|
||
modes[ModeName.Visual] = modes[ModeName.Normal]; | ||
|
||
modes[ModeName.Insert] = { | ||
'<left>': '[', | ||
'<right>': ']', | ||
}; | ||
|
||
const translateMovementKey = (mode: ModeName, key: string) => { | ||
return (modes[mode] || {})[key] || key; | ||
}; | ||
|
||
export const shouldWrapKey = (vimState: VimState, keysPressed: string[]): boolean => { | ||
const key = translateMovementKey(vimState.currentMode, keysPressed[0]); | ||
return !!configuration.wrapKeys[key]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { Configuration } from './testConfiguration'; | ||
import { getTestingFunctions } from './testSimplifier'; | ||
import { cleanUpWorkspace, setupWorkspace } from './testUtils'; | ||
|
||
suite('motion line wrapping', () => { | ||
let { newTest, newTestOnly } = getTestingFunctions(); | ||
|
||
teardown(cleanUpWorkspace); | ||
|
||
suite('whichwrap enabled', () => { | ||
setup(async () => { | ||
let configuration = new Configuration(); | ||
configuration.tabstop = 4; | ||
configuration.expandtab = false; | ||
configuration.whichwrap = 'h,l,<,>,[,]'; | ||
|
||
await setupWorkspace(configuration); | ||
}); | ||
|
||
suite('normal mode', () => { | ||
newTest({ | ||
title: 'h wraps to previous line', | ||
start: ['line 1', '|line 2'], | ||
keysPressed: 'h', | ||
end: ['line |1', 'line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: 'l wraps to next line', | ||
start: ['line |1', 'line 2'], | ||
keysPressed: 'l', | ||
end: ['line 1', '|line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<left> wraps to previous line', | ||
start: ['line 1', '|line 2'], | ||
keysPressed: '<left>', | ||
end: ['line |1', 'line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<right> wraps to next line', | ||
start: ['line |1', 'line 2'], | ||
keysPressed: '<right>', | ||
end: ['line 1', '|line 2'], | ||
}); | ||
}); | ||
|
||
suite('insert mode', () => { | ||
newTest({ | ||
title: '<left> wraps to previous line', | ||
start: ['line 1', '|line 2'], | ||
// insert mode moves cursor one space to the left, | ||
// but not at beginning of line | ||
keysPressed: 'i<left>', | ||
end: ['line 1|', 'line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<right> once goes to end of line', | ||
start: ['line |1', 'line 2'], | ||
// insert mode moves cursor one space to the left | ||
// so <right> once should go to eol | ||
keysPressed: 'i<right>', | ||
end: ['line 1|', 'line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<right> twice wraps to next line', | ||
start: ['line |1', 'line 2'], | ||
// insert mode moves cursor one space to the left | ||
// so need to go right twice to wrap | ||
keysPressed: 'i<right><right>', | ||
end: ['line 1', '|line 2'], | ||
}); | ||
}); | ||
}); | ||
|
||
suite('whichwrap disabled', () => { | ||
setup(async () => { | ||
let configuration = new Configuration(); | ||
configuration.tabstop = 4; | ||
configuration.expandtab = false; | ||
|
||
await setupWorkspace(configuration); | ||
}); | ||
|
||
suite('normal mode', () => { | ||
newTest({ | ||
title: 'h does not wrap to previous line', | ||
start: ['line 1', '|line 2'], | ||
keysPressed: 'h', | ||
end: ['line 1', '|line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: 'l does not wrap to next line', | ||
start: ['line |1', 'line 2'], | ||
keysPressed: 'l', | ||
end: ['line |1', 'line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<left> does not wrap to previous line', | ||
start: ['line 1', '|line 2'], | ||
keysPressed: '<left>', | ||
end: ['line 1', '|line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<right> does not wrap to next line', | ||
start: ['line |1', 'line 2'], | ||
keysPressed: '<right>', | ||
end: ['line |1', 'line 2'], | ||
}); | ||
}); | ||
|
||
suite('insert mode', () => { | ||
newTest({ | ||
title: '<left> does not wrap to previous line', | ||
start: ['line 1', '|line 2'], | ||
keysPressed: 'i<left>', | ||
end: ['line 1', '|line 2'], | ||
}); | ||
|
||
newTest({ | ||
title: '<right> does not wrap to next line', | ||
start: ['line |1', 'line 2'], | ||
keysPressed: 'i<right><right>', | ||
end: ['line 1|', 'line 2'], | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters