Add default pattern from last search regexp

pull/468/merge
Pleshevskiy Dima 2017-12-04 23:06:03 +03:00 zatwierdzone przez GitHub
rodzic 92e439fd9f
commit 94f5cd8c3d
1 zmienionych plików z 12 dodań i 3 usunięć

Wyświetl plik

@ -224,14 +224,23 @@ define(function(require, exports, module) {
* @see {@link http://vim.wikia.com/wiki/Search_and_replace|Vim wiki - sed}
*/
'sed': {
regex: /^(%|'<,'>|(?:\d+|\.),(?:\+?\d+|\$|\.))?s(\/|#)(.+?)\2(.*?)\2([giIc]*)$/,
regex: /^(%|'<,'>|(?:\d+|\.),(?:\+?\d+|\$|\.))?s(\/|#)(.*?)\2(.*?)\2([giIc]*)$/,
action: function (editor, cmd, data) {
// todo: if not data.match[3] get previous search result
var pattern = data.match[3]
var pattern = (
data.match[3]
|| (editor.state.cm
&& editor.state.cm.$searchHighlight
&& editor.state.cm.$searchHighlight.regExp.source)
|| '')
.replace(/(\\)?(\(|\)|\+|\?|\||\&|\{)/g, function (m, m1, m2) {
// Revert regular syntax
return m1 ? m2 : '\\' + m2;
});
if (!pattern) {
return editor.cmdLine.setTimedMessage(
'E35: No previous regular expression',
15000);
}
/**
* g - global by row