Merge pull request #191 from mkiken/gdefault
Supports Vim's gdefault option.
This commit is contained in:
commit
14f0c83261
4 changed files with 34 additions and 1 deletions
|
|
@ -50,3 +50,8 @@ module.exports = ExMode =
|
||||||
description: 'when splitting, split from right'
|
description: 'when splitting, split from right'
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
gdefault:
|
||||||
|
title: 'Gdefault'
|
||||||
|
description: 'When on, the ":substitute" flag \'g\' is default on'
|
||||||
|
type: 'boolean'
|
||||||
|
default: 'false'
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,9 @@ class Ex
|
||||||
try
|
try
|
||||||
flagsObj = {}
|
flagsObj = {}
|
||||||
flags.split('').forEach((flag) -> flagsObj[flag] = true)
|
flags.split('').forEach((flag) -> flagsObj[flag] = true)
|
||||||
|
# gdefault option
|
||||||
|
if atom.config.get('ex-mode.gdefault')
|
||||||
|
flagsObj.g = !flagsObj.g
|
||||||
patternRE = getSearchTerm(pattern, flagsObj)
|
patternRE = getSearchTerm(pattern, flagsObj)
|
||||||
catch e
|
catch e
|
||||||
if e.message.indexOf('Invalid flags supplied to RegExp constructor') is 0
|
if e.message.indexOf('Invalid flags supplied to RegExp constructor') is 0
|
||||||
|
|
|
||||||
|
|
@ -56,4 +56,10 @@ class VimOption
|
||||||
noscs: =>
|
noscs: =>
|
||||||
@nosmartcase()
|
@nosmartcase()
|
||||||
|
|
||||||
|
gdefault: =>
|
||||||
|
atom.config.set("ex-mode.gdefault", true)
|
||||||
|
|
||||||
|
nogdefault: =>
|
||||||
|
atom.config.set("ex-mode.gdefault", false)
|
||||||
|
|
||||||
module.exports = VimOption
|
module.exports = VimOption
|
||||||
|
|
|
||||||
|
|
@ -715,6 +715,17 @@ describe "the commands", ->
|
||||||
submitNormalModeInputText(':%substitute/abc/ghi/ig')
|
submitNormalModeInputText(':%substitute/abc/ghi/ig')
|
||||||
expect(editor.getText()).toEqual('ghiaghi\ndefdDEF\nghiaghi')
|
expect(editor.getText()).toEqual('ghiaghi\ndefdDEF\nghiaghi')
|
||||||
|
|
||||||
|
it "set gdefault option", ->
|
||||||
|
openEx()
|
||||||
|
atom.config.set('ex-mode.gdefault', true)
|
||||||
|
submitNormalModeInputText(':substitute/a/x')
|
||||||
|
expect(editor.getText()).toEqual('xbcxABC\ndefdDEF\nabcaABC')
|
||||||
|
|
||||||
|
atom.commands.dispatch(editorElement, 'ex-mode:open')
|
||||||
|
atom.config.set('ex-mode.gdefault', true)
|
||||||
|
submitNormalModeInputText(':substitute/a/x/g')
|
||||||
|
expect(editor.getText()).toEqual('xbcaABC\ndefdDEF\nabcaABC')
|
||||||
|
|
||||||
describe ":yank", ->
|
describe ":yank", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.setText('abc\ndef\nghi\njkl')
|
editor.setText('abc\ndef\nghi\njkl')
|
||||||
|
|
@ -944,6 +955,14 @@ describe "the commands", ->
|
||||||
submitNormalModeInputText(':set nosmartcase')
|
submitNormalModeInputText(':set nosmartcase')
|
||||||
expect(atom.config.get('vim-mode.useSmartcaseForSearch')).toBe(false)
|
expect(atom.config.get('vim-mode.useSmartcaseForSearch')).toBe(false)
|
||||||
|
|
||||||
|
it "sets (no)gdefault", ->
|
||||||
|
openEx()
|
||||||
|
submitNormalModeInputText(':set gdefault')
|
||||||
|
expect(atom.config.get('ex-mode.gdefault')).toBe(true)
|
||||||
|
atom.commands.dispatch(editorElement, 'ex-mode:open')
|
||||||
|
submitNormalModeInputText(':set nogdefault')
|
||||||
|
expect(atom.config.get('ex-mode.gdefault')).toBe(false)
|
||||||
|
|
||||||
describe "aliases", ->
|
describe "aliases", ->
|
||||||
it "calls the aliased function without arguments", ->
|
it "calls the aliased function without arguments", ->
|
||||||
ExClass.registerAlias('W', 'w')
|
ExClass.registerAlias('W', 'w')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue