mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-02 11:19:22 +02:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 239a7e4f53 | |||
| 4d9d4ac26a | |||
| 7756e7465d | |||
| bbfcd01b07 | |||
| bb09ceb954 | |||
| 025e3e0baf | |||
| 9ec7fa82a2 | |||
| 3611fbfb56 | |||
| cbd3bd6cbe | |||
| a77a9b24dc | |||
| 869e35270e | |||
| 8507747600 | |||
| 265671c4a9 | |||
| 04d045a60f | |||
| d7e940584b | |||
| e9a431e6c3 | |||
| 3b3d235308 | |||
| a1a9cc7ef6 | |||
| 2ae331a486 | |||
| 156919f99a | |||
| ca291aec99 | |||
| 0a9046fbcb | |||
| 97792de276 | |||
| 472e85970e | |||
| 9e507ca8a3 | |||
| a6c27ee6db |
@@ -4287,7 +4287,9 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
||||
locale locale names (as output of locale -a)
|
||||
mapping mapping name
|
||||
menu menus
|
||||
messages |:messages| suboptions
|
||||
option options
|
||||
packadd optional package |pack-add| names
|
||||
shellcmd Shell command
|
||||
sign |:sign| suboptions
|
||||
syntax syntax file names |'syntax'|
|
||||
|
||||
@@ -1280,6 +1280,7 @@ completion can be enabled:
|
||||
-complete=locale locale names (as output of locale -a)
|
||||
-complete=mapping mapping name
|
||||
-complete=menu menus
|
||||
-complete=messages |:messages| suboptions
|
||||
-complete=option options
|
||||
-complete=packadd optional package |pack-add| names
|
||||
-complete=shellcmd Shell command
|
||||
|
||||
+32
-5
@@ -389,19 +389,46 @@ endfun
|
||||
|
||||
" get NL separated string with file names
|
||||
let s:n = globpath(&runtimepath, "colors/*.vim")
|
||||
let s:n .= globpath(&packpath, "pack/*/{opt,start}/*/colors/*.vim")
|
||||
|
||||
" split at NL, Ignore case for VMS and windows, sort on name
|
||||
let s:names = sort(map(split(s:n, "\n"), 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)
|
||||
|
||||
" define all the submenu entries
|
||||
let s:idx = 100
|
||||
let s:cs_idx = 100
|
||||
for s:name in s:names
|
||||
exe "an 20.450." . s:idx . ' &Edit.C&olor\ Scheme.' . s:name . " :colors " . s:name . "<CR>"
|
||||
let s:idx = s:idx + 10
|
||||
exe "an 20.450." . s:cs_idx . ' &Edit.C&olor\ Scheme.' . s:name . " :colors " . s:name . "<CR>"
|
||||
let s:cs_idx = s:cs_idx + 10
|
||||
endfor
|
||||
unlet s:name s:names s:n s:idx
|
||||
exe "an 20.450." . s:cs_idx . ' &Edit.C&olor\ Scheme.-SEP- <Nop>'
|
||||
let s:cs_idx = s:cs_idx + 10
|
||||
exe "an <silent> 20.450." . s:cs_idx '&Edit.C&olor\ Scheme.Find\ More\ Color\ Schemes' ":call <SID>Colorschemes()<CR>"
|
||||
let s:cs_idx = s:cs_idx + 10
|
||||
unlet s:name s:names s:n
|
||||
|
||||
let s:undo_colorschemes = ['aun &Edit.C&olor\ Scheme.Find\ More\ Color\ Schemes']
|
||||
func! s:Colorschemes()
|
||||
for cmd in s:undo_colorschemes
|
||||
exe "silent! " . cmd
|
||||
endfor
|
||||
let s:undo_colorschemes = []
|
||||
|
||||
let s = globpath(&packpath, "pack/*/{opt,start}/*/colors/*.vim")
|
||||
let names = sort(map(split(s, "\n"), 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 1)
|
||||
let n = s:cs_idx
|
||||
for name in names
|
||||
let menuname = '&Edit.C&olor\ Scheme.' . name
|
||||
exe 'an 20.450.' . n . ' ' . menuname . " :colors " . name . "<CR>"
|
||||
let s:undo_colorschemes += ['aun ' . menuname]
|
||||
let n += 10
|
||||
endfor
|
||||
if empty(names)
|
||||
echomsg "Could not find other color schemes"
|
||||
elseif len(names) == 1
|
||||
echomsg "Found color scheme " . names[0]
|
||||
else
|
||||
echomsg "Found " . len(names) . " more color schemes"
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Setup the Edit.Keymap submenu
|
||||
if has("keymap")
|
||||
|
||||
@@ -1255,7 +1255,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>112</string>
|
||||
<string>113</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#import "QLSFileAttributes.h"
|
||||
|
||||
#define DEFAULT_MAX_FILE_SIZE 1024 * 100
|
||||
|
||||
// Generate a preview for the document with the given url
|
||||
OSStatus GeneratePreviewForURL(void *thisInterface,
|
||||
@@ -40,6 +41,38 @@ OSStatus GeneratePreviewForURL(void *thisInterface,
|
||||
(NSString *)kQLPreviewPropertyHeightKey : @800
|
||||
};
|
||||
|
||||
// Get size of current File
|
||||
NSFileManager *man = [NSFileManager defaultManager];
|
||||
NSURL *file_url = (__bridge NSURL *)(url);
|
||||
NSDictionary *attrs = [man attributesOfItemAtPath: [file_url path] error: NULL];
|
||||
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
// the plugin is running as com.apple.quicklook.satellite therefore we need to load our own settings
|
||||
NSDictionary *defaults = [userDefaults persistentDomainForName:@"com.whomwah.quicklookstephen"];
|
||||
|
||||
long long maxFileSizeSetting = [[defaults valueForKey:@"maxFileSize"] longLongValue];
|
||||
unsigned long long maxFileSize = DEFAULT_MAX_FILE_SIZE;
|
||||
if(maxFileSizeSetting > 0) {
|
||||
maxFileSize = maxFileSizeSetting;
|
||||
}
|
||||
|
||||
// Display less data, if file is too big
|
||||
if(attrs.fileSize > maxFileSize) {
|
||||
NSFileHandle *myFile= [NSFileHandle fileHandleForReadingAtPath:[file_url path]];
|
||||
if(!myFile) {
|
||||
return noErr;
|
||||
}
|
||||
NSData *displayData = [myFile readDataOfLength:maxFileSize];
|
||||
[myFile closeFile];
|
||||
|
||||
QLPreviewRequestSetDataRepresentation(
|
||||
request,
|
||||
(__bridge CFDataRef)displayData,
|
||||
kUTTypePlainText,
|
||||
(__bridge CFDictionaryRef)previewProperties);
|
||||
return noErr;
|
||||
}
|
||||
QLPreviewRequestSetURLRepresentation(
|
||||
request,
|
||||
url,
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
#include <QuickLook/QuickLook.h>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "RegexKitLite.h"
|
||||
|
||||
#import "QLSFileAttributes.h"
|
||||
|
||||
|
||||
/**
|
||||
* This dictionary is used for a file with no extension. It maps the MIME type
|
||||
* (as returned by file(1)) onto an appropriate thumbnail badge.
|
||||
@@ -72,10 +70,11 @@ static NSString *ThumbnailBadgeForItemWithAttributes(
|
||||
// Does the filename match a known pattern? If so, use the appropriate badge.
|
||||
if (!badge && [fileExtension isEqualToString:@""]) {
|
||||
NSDictionary *map = filenameRegexToBadgeMap();
|
||||
|
||||
[map enumerateKeysAndObjectsUsingBlock:
|
||||
^(NSString *regex, NSString *candidateBadge, BOOL *stop) {
|
||||
if ([fileName rkl_isMatchedByRegex:regex]) {
|
||||
^(NSString *pattern, NSString *candidateBadge, BOOL *stop) {
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
|
||||
NSRange range = [regex rangeOfFirstMatchInString:fileName options:0 range:NSMakeRange(0, fileName.length)];
|
||||
if (range.location != NSNotFound) {
|
||||
badge = candidateBadge;
|
||||
*stop = true;
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
<key>CFBundleName</key>
|
||||
<string>QLStephen</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.4</string>
|
||||
<string>1.44</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.4.2</string>
|
||||
<string>1.4.4</string>
|
||||
<key>CFPlugInDynamicRegisterFunction</key>
|
||||
<string></string>
|
||||
<key>CFPlugInDynamicRegistration</key>
|
||||
@@ -54,7 +54,7 @@
|
||||
<key>CFPlugInUnloadFunction</key>
|
||||
<string></string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2013 Duncan Robertson. All rights reserved.</string>
|
||||
<string>Copyright © 2016 Duncan Robertson. All rights reserved.</string>
|
||||
<key>QLNeedsToBeRunInMainThread</key>
|
||||
<true/>
|
||||
<key>QLPreviewHeight</key>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
//
|
||||
|
||||
#import "QLSFileAttributes.h"
|
||||
#import "RegexKitLite.h"
|
||||
|
||||
@interface QLSFileAttributes ()
|
||||
|
||||
@@ -19,18 +18,22 @@
|
||||
|
||||
@implementation QLSFileAttributes
|
||||
|
||||
+ (instancetype)attributesForItemAtURL:(NSURL *)aURL
|
||||
{
|
||||
NSString *magicString = [self magicStringForItemAtURL:aURL];
|
||||
+ (instancetype)attributesForItemAtURL:(NSURL *)aURL {
|
||||
if ([aURL.lastPathComponent isEqualToString:@".DS_Store"]) {
|
||||
NSLog(@"Ignore the .DS_Store file.");
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *magicString = [self magicStringForItemAtURL:aURL usingLcALL:@"en_US.UTF-8"];
|
||||
if (!magicString) magicString = [self magicStringForItemAtURL:aURL usingLcALL:@"C"];
|
||||
if (!magicString) return nil;
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\S+/\\S+); charset=(\\S+)" options:0 error:nil];
|
||||
NSTextCheckingResult *match = [regex firstMatchInString:magicString options:0 range:NSMakeRange(0, magicString.length)];
|
||||
|
||||
NSArray *matches = [magicString rkl_captureComponentsMatchedByRegex:
|
||||
@"(\\S+/\\S+); charset=(\\S+)"];
|
||||
if (!match) return nil;
|
||||
|
||||
if (![matches count]) return nil;
|
||||
|
||||
NSString *mimeType = matches[1];
|
||||
NSString *charset = matches[2];
|
||||
NSString *mimeType = [magicString substringWithRange:[match rangeAtIndex:1]];
|
||||
NSString *charset = [magicString substringWithRange:[match rangeAtIndex:2]];
|
||||
|
||||
BOOL mimeTypeIsTextual = [self mimeTypeIsTextual:mimeType];
|
||||
|
||||
@@ -50,14 +53,13 @@
|
||||
// Private Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+ (NSString *)magicStringForItemAtURL:(NSURL *)aURL
|
||||
{
|
||||
+ (NSString *)magicStringForItemAtURL:(NSURL *)aURL usingLcALL:(NSString *)lcALL {
|
||||
NSString *path = [aURL path];
|
||||
NSParameterAssert(path);
|
||||
|
||||
NSMutableDictionary *environment =
|
||||
[NSProcessInfo.processInfo.environment mutableCopy];
|
||||
environment[@"LC_ALL"] = @"en_US.UTF-8";
|
||||
environment[@"LC_ALL"] = lcALL;
|
||||
|
||||
NSTask *task = [NSTask new];
|
||||
task.launchPath = @"/usr/bin/file";
|
||||
@@ -94,8 +96,7 @@
|
||||
* @return YES if mimeType contains "text", or if the mime type conforms to the
|
||||
* public.text UTI.
|
||||
*/
|
||||
+ (BOOL)mimeTypeIsTextual:(NSString *)mimeType
|
||||
{
|
||||
+ (BOOL)mimeTypeIsTextual:(NSString *)mimeType {
|
||||
NSArray *components = [mimeType componentsSeparatedByString:@"/"];
|
||||
if (components.count != 2)
|
||||
return NO;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0107ABFF15C76F2900C65F1A /* QLSFileAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 0107ABFD15C76F2900C65F1A /* QLSFileAttributes.m */; };
|
||||
0149EB3B15F2E8E4003AB298 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 0149EB3915F2E8E4003AB298 /* RegexKitLite.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
0149EB3E15F2E9A3003AB298 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 0149EB3D15F2E9A3003AB298 /* libicucore.dylib */; };
|
||||
2C05A19C06CAA52B00D84F6F /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C05A19B06CAA52B00D84F6F /* GeneratePreviewForURL.m */; };
|
||||
61E3BCFB0870B4F2002186A0 /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 61E3BCFA0870B4F2002186A0 /* GenerateThumbnailForURL.m */; };
|
||||
@@ -23,9 +22,7 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0107ABFC15C76F2900C65F1A /* QLSFileAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QLSFileAttributes.h; sourceTree = "<group>"; };
|
||||
0107ABFD15C76F2900C65F1A /* QLSFileAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QLSFileAttributes.m; sourceTree = "<group>"; };
|
||||
0149EB3815F2E8E4003AB298 /* RegexKitLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegexKitLite.h; sourceTree = "<group>"; };
|
||||
0149EB3915F2E8E4003AB298 /* RegexKitLite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegexKitLite.m; sourceTree = "<group>"; };
|
||||
0107ABFD15C76F2900C65F1A /* QLSFileAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = QLSFileAttributes.m; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
|
||||
0149EB3D15F2E9A3003AB298 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; };
|
||||
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
08FB77B6FE84183AC02AAC07 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
||||
@@ -57,19 +54,9 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0149EB3F15F2EC37003AB298 /* Third-Party */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0149EB3815F2E8E4003AB298 /* RegexKitLite.h */,
|
||||
0149EB3915F2E8E4003AB298 /* RegexKitLite.m */,
|
||||
);
|
||||
name = "Third-Party";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
089C166AFE841209C02AAC07 /* QuickLookStephen */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0149EB3F15F2EC37003AB298 /* Third-Party */,
|
||||
08FB77AFFE84173DC02AAC07 /* Source */,
|
||||
089C167CFE841241C02AAC07 /* Resources */,
|
||||
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */,
|
||||
@@ -130,6 +117,7 @@
|
||||
8D57630F048677EA00EA77CD /* Resources */,
|
||||
8D576311048677EA00EA77CD /* Sources */,
|
||||
8D576313048677EA00EA77CD /* Frameworks */,
|
||||
698210201CC62DD000504BBF /* ShellScript */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -146,7 +134,7 @@
|
||||
089C1669FE841209C02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0720;
|
||||
LastUpgradeCheck = 0730;
|
||||
};
|
||||
buildConfigurationList = 2CA326220896AD4900168862 /* Build configuration list for PBXProject "QuickLookStephen" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
@@ -175,6 +163,22 @@
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
698210201CC62DD000504BBF /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "qlmanage -r";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8D576311048677EA00EA77CD /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
@@ -184,7 +188,6 @@
|
||||
2C05A19C06CAA52B00D84F6F /* GeneratePreviewForURL.m in Sources */,
|
||||
61E3BCFB0870B4F2002186A0 /* GenerateThumbnailForURL.m in Sources */,
|
||||
0107ABFF15C76F2900C65F1A /* QLSFileAttributes.m in Sources */,
|
||||
0149EB3B15F2E8E4003AB298 /* RegexKitLite.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -1,295 +0,0 @@
|
||||
//
|
||||
// RegexKitLite.h
|
||||
// http://regexkit.sourceforge.net/
|
||||
// Licensed under the terms of the BSD License, as specified below.
|
||||
//
|
||||
|
||||
/*
|
||||
Copyright (c) 2008-2010, John Engelhart
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the Zang Industries nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObjCRuntime.h>
|
||||
#import <Foundation/NSRange.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#endif // __OBJC__
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <TargetConditionals.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef REGEXKITLITE_VERSION_DEFINED
|
||||
#define REGEXKITLITE_VERSION_DEFINED
|
||||
|
||||
#define _RKL__STRINGIFY(b) #b
|
||||
#define _RKL_STRINGIFY(a) _RKL__STRINGIFY(a)
|
||||
#define _RKL_JOIN_VERSION(a,b) _RKL_STRINGIFY(a##.##b)
|
||||
#define _RKL_VERSION_STRING(a,b) _RKL_JOIN_VERSION(a,b)
|
||||
|
||||
#define REGEXKITLITE_VERSION_MAJOR 4
|
||||
#define REGEXKITLITE_VERSION_MINOR 0
|
||||
|
||||
#define REGEXKITLITE_VERSION_CSTRING _RKL_VERSION_STRING(REGEXKITLITE_VERSION_MAJOR, REGEXKITLITE_VERSION_MINOR)
|
||||
#define REGEXKITLITE_VERSION_NSSTRING @REGEXKITLITE_VERSION_CSTRING
|
||||
|
||||
#endif // REGEXKITLITE_VERSION_DEFINED
|
||||
|
||||
#if !defined(RKL_BLOCKS) && defined(NS_BLOCKS_AVAILABLE) && (NS_BLOCKS_AVAILABLE == 1)
|
||||
#define RKL_BLOCKS 1
|
||||
#endif
|
||||
|
||||
#if defined(RKL_BLOCKS) && (RKL_BLOCKS == 1)
|
||||
#define _RKL_BLOCKS_ENABLED 1
|
||||
#endif // defined(RKL_BLOCKS) && (RKL_BLOCKS == 1)
|
||||
|
||||
#if defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__)
|
||||
#warning RegexKitLite support for Blocks is enabled, but __BLOCKS__ is not defined. This compiler may not support Blocks, in which case the behavior is undefined. This will probably cause numerous compiler errors.
|
||||
#endif // defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__)
|
||||
|
||||
// For Mac OS X < 10.5.
|
||||
#ifndef NSINTEGER_DEFINED
|
||||
#define NSINTEGER_DEFINED
|
||||
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
typedef long NSInteger;
|
||||
typedef unsigned long NSUInteger;
|
||||
#define NSIntegerMin LONG_MIN
|
||||
#define NSIntegerMax LONG_MAX
|
||||
#define NSUIntegerMax ULONG_MAX
|
||||
#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
typedef int NSInteger;
|
||||
typedef unsigned int NSUInteger;
|
||||
#define NSIntegerMin INT_MIN
|
||||
#define NSIntegerMax INT_MAX
|
||||
#define NSUIntegerMax UINT_MAX
|
||||
#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
|
||||
#endif // NSINTEGER_DEFINED
|
||||
|
||||
#ifndef RKLREGEXOPTIONS_DEFINED
|
||||
#define RKLREGEXOPTIONS_DEFINED
|
||||
|
||||
// These must be identical to their ICU regex counterparts. See http://www.icu-project.org/userguide/regexp.html
|
||||
enum {
|
||||
RKLNoOptions = 0,
|
||||
RKLCaseless = 2,
|
||||
RKLComments = 4,
|
||||
RKLDotAll = 32,
|
||||
RKLMultiline = 8,
|
||||
RKLUnicodeWordBoundaries = 256
|
||||
};
|
||||
typedef uint32_t RKLRegexOptions; // This must be identical to the ICU 'flags' argument type.
|
||||
|
||||
#endif // RKLREGEXOPTIONS_DEFINED
|
||||
|
||||
#ifndef RKLREGEXENUMERATIONOPTIONS_DEFINED
|
||||
#define RKLREGEXENUMERATIONOPTIONS_DEFINED
|
||||
|
||||
enum {
|
||||
RKLRegexEnumerationNoOptions = 0UL,
|
||||
RKLRegexEnumerationCapturedStringsNotRequired = 1UL << 9,
|
||||
RKLRegexEnumerationReleaseStringReturnedByReplacementBlock = 1UL << 10,
|
||||
RKLRegexEnumerationFastCapturedStringsXXX = 1UL << 11,
|
||||
};
|
||||
typedef NSUInteger RKLRegexEnumerationOptions;
|
||||
|
||||
#endif // RKLREGEXENUMERATIONOPTIONS_DEFINED
|
||||
|
||||
#ifndef _REGEXKITLITE_H_
|
||||
#define _REGEXKITLITE_H_
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
|
||||
#define RKL_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
|
||||
#else
|
||||
#define RKL_DEPRECATED_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
#if defined(NS_REQUIRES_NIL_TERMINATION)
|
||||
#define RKL_REQUIRES_NIL_TERMINATION NS_REQUIRES_NIL_TERMINATION
|
||||
#else // defined(NS_REQUIRES_NIL_TERMINATION)
|
||||
#define RKL_REQUIRES_NIL_TERMINATION
|
||||
#endif // defined(NS_REQUIRES_NIL_TERMINATION)
|
||||
|
||||
// This requires a few levels of rewriting to get the desired results.
|
||||
#define _RKL_CONCAT_2(c,d) c ## d
|
||||
#define _RKL_CONCAT(a,b) _RKL_CONCAT_2(a,b)
|
||||
|
||||
#ifdef RKL_PREPEND_TO_METHODS
|
||||
#define RKL_METHOD_PREPEND(x) _RKL_CONCAT(RKL_PREPEND_TO_METHODS, x)
|
||||
#else // RKL_PREPEND_TO_METHODS
|
||||
#define RKL_METHOD_PREPEND(x) x
|
||||
#endif // RKL_PREPEND_TO_METHODS
|
||||
|
||||
// If it looks like low memory notifications might be available, add code to register and respond to them.
|
||||
// This is (should be) harmless if it turns out that this isn't the case, since the notification that we register for,
|
||||
// UIApplicationDidReceiveMemoryWarningNotification, is dynamically looked up via dlsym().
|
||||
#if ((defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0))) && (!defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) || (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS != 0))
|
||||
#define RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS 1
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
|
||||
// NSException exception name.
|
||||
extern NSString * const RKLICURegexException;
|
||||
|
||||
// NSError error domains and user info keys.
|
||||
extern NSString * const RKLICURegexErrorDomain;
|
||||
|
||||
extern NSString * const RKLICURegexEnumerationOptionsErrorKey;
|
||||
extern NSString * const RKLICURegexErrorCodeErrorKey;
|
||||
extern NSString * const RKLICURegexErrorNameErrorKey;
|
||||
extern NSString * const RKLICURegexLineErrorKey;
|
||||
extern NSString * const RKLICURegexOffsetErrorKey;
|
||||
extern NSString * const RKLICURegexPreContextErrorKey;
|
||||
extern NSString * const RKLICURegexPostContextErrorKey;
|
||||
extern NSString * const RKLICURegexRegexErrorKey;
|
||||
extern NSString * const RKLICURegexRegexOptionsErrorKey;
|
||||
extern NSString * const RKLICURegexReplacedCountErrorKey;
|
||||
extern NSString * const RKLICURegexReplacedStringErrorKey;
|
||||
extern NSString * const RKLICURegexReplacementStringErrorKey;
|
||||
extern NSString * const RKLICURegexSubjectRangeErrorKey;
|
||||
extern NSString * const RKLICURegexSubjectStringErrorKey;
|
||||
|
||||
@interface NSString (RegexKitLiteAdditions)
|
||||
|
||||
+ (void)RKL_METHOD_PREPEND(clearStringCache);
|
||||
|
||||
// Although these are marked as deprecated, a bug in GCC prevents a warning from being issues for + class methods. Filed bug with Apple, #6736857.
|
||||
+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex RKL_DEPRECATED_ATTRIBUTE;
|
||||
+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error RKL_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
|
||||
|
||||
- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex;
|
||||
- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range;
|
||||
- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error;
|
||||
|
||||
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex;
|
||||
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture;
|
||||
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range;
|
||||
- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
|
||||
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex;
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture;
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range;
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
|
||||
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement;
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange;
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error;
|
||||
|
||||
//// >= 3.0
|
||||
|
||||
- (NSInteger)RKL_METHOD_PREPEND(captureCount);
|
||||
- (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error;
|
||||
|
||||
- (BOOL)RKL_METHOD_PREPEND(isRegexValid);
|
||||
- (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error;
|
||||
|
||||
- (void)RKL_METHOD_PREPEND(flushCachedRegexData);
|
||||
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
|
||||
|
||||
|
||||
- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
|
||||
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
|
||||
|
||||
//// >= 4.0
|
||||
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList;
|
||||
|
||||
- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count;
|
||||
|
||||
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
|
||||
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
|
||||
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
|
||||
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList;
|
||||
|
||||
- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count;
|
||||
|
||||
#ifdef _RKL_BLOCKS_ENABLED
|
||||
|
||||
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
|
||||
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
- (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
|
||||
#endif // _RKL_BLOCKS_ENABLED
|
||||
|
||||
@end
|
||||
|
||||
@interface NSMutableString (RegexKitLiteAdditions)
|
||||
|
||||
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement;
|
||||
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange;
|
||||
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error;
|
||||
|
||||
//// >= 4.0
|
||||
|
||||
#ifdef _RKL_BLOCKS_ENABLED
|
||||
|
||||
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
|
||||
|
||||
#endif // _RKL_BLOCKS_ENABLED
|
||||
|
||||
@end
|
||||
|
||||
#endif // __OBJC__
|
||||
|
||||
#endif // _REGEXKITLITE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -2064,7 +2064,7 @@ test1 \
|
||||
test40 test41 test42 test43 test44 test45 test48 test49 \
|
||||
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
|
||||
test60 test64 test65 test66 test67 test68 test69 \
|
||||
test70 test72 test73 test74 test75 test76 test77 test78 test79 \
|
||||
test70 test72 test73 test74 test75 test77 test78 test79 \
|
||||
test80 test82 test83 test84 test85 test86 test87 test88 test89 \
|
||||
test90 test91 test92 test93 test94 test95 test97 test98 test99 \
|
||||
test100 test101 test103 test104 test107 test108:
|
||||
|
||||
Vendored
+1
-1
@@ -12122,7 +12122,7 @@ for ac_func in bcmp fchdir fchown fsync getcwd getpseudotty \
|
||||
getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
|
||||
memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
|
||||
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
|
||||
sigvec strcasecmp strerror strftime stricmp strncasecmp \
|
||||
sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
|
||||
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
|
||||
usleep utime utimes
|
||||
do :
|
||||
|
||||
+59
-49
@@ -4453,6 +4453,39 @@ job_free(job_T *job)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
job_cleanup(job_T *job)
|
||||
{
|
||||
if (job->jv_status != JOB_ENDED)
|
||||
return;
|
||||
|
||||
if (job->jv_exit_cb != NULL)
|
||||
{
|
||||
typval_T argv[3];
|
||||
typval_T rettv;
|
||||
int dummy;
|
||||
|
||||
/* invoke the exit callback; make sure the refcount is > 0 */
|
||||
++job->jv_refcount;
|
||||
argv[0].v_type = VAR_JOB;
|
||||
argv[0].vval.v_job = job;
|
||||
argv[1].v_type = VAR_NUMBER;
|
||||
argv[1].vval.v_number = job->jv_exitval;
|
||||
call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb),
|
||||
&rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||
job->jv_exit_partial, NULL);
|
||||
clear_tv(&rettv);
|
||||
--job->jv_refcount;
|
||||
channel_need_redraw = TRUE;
|
||||
}
|
||||
if (job->jv_refcount == 0)
|
||||
{
|
||||
/* The job was already unreferenced, now that it ended it can be
|
||||
* freed. Careful: caller must not use "job" after this! */
|
||||
job_free(job);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(EXITFREE) || defined(PROTO)
|
||||
void
|
||||
job_free_all(void)
|
||||
@@ -4470,10 +4503,15 @@ job_free_all(void)
|
||||
static int
|
||||
job_still_useful(job_T *job)
|
||||
{
|
||||
return job->jv_status == JOB_STARTED
|
||||
&& (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL
|
||||
|| (job->jv_channel != NULL
|
||||
&& channel_still_useful(job->jv_channel)));
|
||||
return (job->jv_stoponexit != NULL || job->jv_exit_cb != NULL
|
||||
|| (job->jv_channel != NULL
|
||||
&& channel_still_useful(job->jv_channel)));
|
||||
}
|
||||
|
||||
static int
|
||||
job_still_alive(job_T *job)
|
||||
{
|
||||
return (job->jv_status == JOB_STARTED) && job_still_useful(job);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4487,7 +4525,7 @@ set_ref_in_job(int copyID)
|
||||
typval_T tv;
|
||||
|
||||
for (job = first_job; job != NULL; job = job->jv_next)
|
||||
if (job_still_useful(job))
|
||||
if (job_still_alive(job))
|
||||
{
|
||||
tv.v_type = VAR_JOB;
|
||||
tv.vval.v_job = job;
|
||||
@@ -4503,7 +4541,7 @@ job_unref(job_T *job)
|
||||
{
|
||||
/* Do not free the job when it has not ended yet and there is a
|
||||
* "stoponexit" flag or an exit callback. */
|
||||
if (!job_still_useful(job))
|
||||
if (!job_still_alive(job))
|
||||
{
|
||||
job_free(job);
|
||||
}
|
||||
@@ -4528,7 +4566,7 @@ free_unused_jobs_contents(int copyID, int mask)
|
||||
|
||||
for (job = first_job; job != NULL; job = job->jv_next)
|
||||
if ((job->jv_copyID & mask) != (copyID & mask)
|
||||
&& !job_still_useful(job))
|
||||
&& !job_still_alive(job))
|
||||
{
|
||||
/* Free the channel and ordinary items it contains, but don't
|
||||
* recurse into Lists, Dictionaries etc. */
|
||||
@@ -4548,7 +4586,7 @@ free_unused_jobs(int copyID, int mask)
|
||||
{
|
||||
job_next = job->jv_next;
|
||||
if ((job->jv_copyID & mask) != (copyID & mask)
|
||||
&& !job_still_useful(job))
|
||||
&& !job_still_alive(job))
|
||||
{
|
||||
/* Free the job struct itself. */
|
||||
job_free_job(job);
|
||||
@@ -4639,34 +4677,31 @@ has_pending_job(void)
|
||||
job_T *job;
|
||||
|
||||
for (job = first_job; job != NULL; job = job->jv_next)
|
||||
if (job->jv_status == JOB_STARTED && job_still_useful(job))
|
||||
if (job_still_alive(job))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define MAX_CHECK_ENDED 8
|
||||
|
||||
/*
|
||||
* Called once in a while: check if any jobs that seem useful have ended.
|
||||
*/
|
||||
void
|
||||
job_check_ended(void)
|
||||
{
|
||||
static time_t last_check = 0;
|
||||
time_t now;
|
||||
job_T *job;
|
||||
job_T *next;
|
||||
int i;
|
||||
|
||||
/* Only do this once in 10 seconds. */
|
||||
now = time(NULL);
|
||||
if (last_check + 10 < now)
|
||||
for (i = 0; i < MAX_CHECK_ENDED; ++i)
|
||||
{
|
||||
last_check = now;
|
||||
for (job = first_job; job != NULL; job = next)
|
||||
{
|
||||
next = job->jv_next;
|
||||
if (job->jv_status == JOB_STARTED && job_still_useful(job))
|
||||
job_status(job); /* may free "job" */
|
||||
}
|
||||
job_T *job = mch_detect_ended_job(first_job);
|
||||
|
||||
if (job == NULL)
|
||||
break;
|
||||
if (job_still_useful(job))
|
||||
job_cleanup(job); /* may free "job" */
|
||||
}
|
||||
|
||||
if (channel_need_redraw)
|
||||
{
|
||||
channel_need_redraw = FALSE;
|
||||
@@ -4887,32 +4922,7 @@ job_status(job_T *job)
|
||||
{
|
||||
result = mch_job_status(job);
|
||||
if (job->jv_status == JOB_ENDED)
|
||||
ch_log(job->jv_channel, "Job ended");
|
||||
if (job->jv_status == JOB_ENDED && job->jv_exit_cb != NULL)
|
||||
{
|
||||
typval_T argv[3];
|
||||
typval_T rettv;
|
||||
int dummy;
|
||||
|
||||
/* invoke the exit callback; make sure the refcount is > 0 */
|
||||
++job->jv_refcount;
|
||||
argv[0].v_type = VAR_JOB;
|
||||
argv[0].vval.v_job = job;
|
||||
argv[1].v_type = VAR_NUMBER;
|
||||
argv[1].vval.v_number = job->jv_exitval;
|
||||
call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb),
|
||||
&rettv, 2, argv, NULL, 0L, 0L, &dummy, TRUE,
|
||||
job->jv_exit_partial, NULL);
|
||||
clear_tv(&rettv);
|
||||
--job->jv_refcount;
|
||||
channel_need_redraw = TRUE;
|
||||
}
|
||||
if (job->jv_status == JOB_ENDED && job->jv_refcount == 0)
|
||||
{
|
||||
/* The job was already unreferenced, now that it ended it can be
|
||||
* freed. Careful: caller must not use "job" after this! */
|
||||
job_free(job);
|
||||
}
|
||||
job_cleanup(job);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@
|
||||
#undef HAVE_SIGSET
|
||||
#undef HAVE_SIGSETJMP
|
||||
#undef HAVE_SIGSTACK
|
||||
#undef HAVE_SIGPROCMASK
|
||||
#undef HAVE_SIGVEC
|
||||
#undef HAVE_SMACK
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
+1
-1
@@ -3677,7 +3677,7 @@ AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
|
||||
getpwent getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
|
||||
memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
|
||||
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
|
||||
sigvec strcasecmp strerror strftime stricmp strncasecmp \
|
||||
sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
|
||||
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
|
||||
usleep utime utimes)
|
||||
AC_FUNC_FSEEKO
|
||||
|
||||
+32
-30
@@ -1100,10 +1100,7 @@ ex_diffsplit(exarg_T *eap)
|
||||
if (bufref_valid(&old_curbuf))
|
||||
/* Move the cursor position to that of the old window. */
|
||||
curwin->w_cursor.lnum = diff_get_corresponding_line(
|
||||
old_curbuf.br_buf,
|
||||
old_curwin->w_cursor.lnum,
|
||||
curbuf,
|
||||
curwin->w_cursor.lnum);
|
||||
old_curbuf.br_buf, old_curwin->w_cursor.lnum);
|
||||
}
|
||||
/* Now that lines are folded scroll to show the cursor at the same
|
||||
* relative position. */
|
||||
@@ -2524,21 +2521,22 @@ diff_move_to(int dir, long count)
|
||||
return OK;
|
||||
}
|
||||
|
||||
linenr_T
|
||||
diff_get_corresponding_line(
|
||||
/*
|
||||
* Return the line number in the current window that is closest to "lnum1" in
|
||||
* "buf1" in diff mode.
|
||||
*/
|
||||
static linenr_T
|
||||
diff_get_corresponding_line_int(
|
||||
buf_T *buf1,
|
||||
linenr_T lnum1,
|
||||
buf_T *buf2,
|
||||
linenr_T lnum3)
|
||||
linenr_T lnum1)
|
||||
{
|
||||
int idx1;
|
||||
int idx2;
|
||||
diff_T *dp;
|
||||
int baseline = 0;
|
||||
linenr_T lnum2;
|
||||
|
||||
idx1 = diff_buf_idx(buf1);
|
||||
idx2 = diff_buf_idx(buf2);
|
||||
idx2 = diff_buf_idx(curbuf);
|
||||
if (idx1 == DB_COUNT || idx2 == DB_COUNT || curtab->tp_first_diff == NULL)
|
||||
return lnum1;
|
||||
|
||||
@@ -2551,15 +2549,8 @@ diff_get_corresponding_line(
|
||||
for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
|
||||
{
|
||||
if (dp->df_lnum[idx1] > lnum1)
|
||||
{
|
||||
lnum2 = lnum1 - baseline;
|
||||
/* don't end up past the end of the file */
|
||||
if (lnum2 > buf2->b_ml.ml_line_count)
|
||||
lnum2 = buf2->b_ml.ml_line_count;
|
||||
|
||||
return lnum2;
|
||||
}
|
||||
else if ((dp->df_lnum[idx1] + dp->df_count[idx1]) > lnum1)
|
||||
return lnum1 - baseline;
|
||||
if ((dp->df_lnum[idx1] + dp->df_count[idx1]) > lnum1)
|
||||
{
|
||||
/* Inside the diffblock */
|
||||
baseline = lnum1 - dp->df_lnum[idx1];
|
||||
@@ -2568,10 +2559,11 @@ diff_get_corresponding_line(
|
||||
|
||||
return dp->df_lnum[idx2] + baseline;
|
||||
}
|
||||
else if ( (dp->df_lnum[idx1] == lnum1)
|
||||
&& (dp->df_count[idx1] == 0)
|
||||
&& (dp->df_lnum[idx2] <= lnum3)
|
||||
&& ((dp->df_lnum[idx2] + dp->df_count[idx2]) > lnum3))
|
||||
if ( (dp->df_lnum[idx1] == lnum1)
|
||||
&& (dp->df_count[idx1] == 0)
|
||||
&& (dp->df_lnum[idx2] <= curwin->w_cursor.lnum)
|
||||
&& ((dp->df_lnum[idx2] + dp->df_count[idx2])
|
||||
> curwin->w_cursor.lnum))
|
||||
/*
|
||||
* Special case: if the cursor is just after a zero-count
|
||||
* block (i.e. all filler) and the target cursor is already
|
||||
@@ -2579,18 +2571,28 @@ diff_get_corresponding_line(
|
||||
* unmoved. This makes repeated CTRL-W W operations work
|
||||
* as expected.
|
||||
*/
|
||||
return lnum3;
|
||||
return curwin->w_cursor.lnum;
|
||||
baseline = (dp->df_lnum[idx1] + dp->df_count[idx1])
|
||||
- (dp->df_lnum[idx2] + dp->df_count[idx2]);
|
||||
}
|
||||
|
||||
/* If we get here then the cursor is after the last diff */
|
||||
lnum2 = lnum1 - baseline;
|
||||
/* don't end up past the end of the file */
|
||||
if (lnum2 > buf2->b_ml.ml_line_count)
|
||||
lnum2 = buf2->b_ml.ml_line_count;
|
||||
return lnum1 - baseline;
|
||||
}
|
||||
|
||||
return lnum2;
|
||||
/*
|
||||
* Return the line number in the current window that is closest to "lnum1" in
|
||||
* "buf1" in diff mode. Checks the line number to be valid.
|
||||
*/
|
||||
linenr_T
|
||||
diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1)
|
||||
{
|
||||
linenr_T lnum = diff_get_corresponding_line_int(buf1, lnum1);
|
||||
|
||||
/* don't end up past the end of the file */
|
||||
if (lnum > curbuf->b_ml.ml_line_count)
|
||||
return curbuf->b_ml.ml_line_count;
|
||||
return lnum;
|
||||
}
|
||||
|
||||
#if defined(FEAT_FOLDING) || defined(PROTO)
|
||||
|
||||
+39
-25
@@ -179,8 +179,8 @@ static void ins_compl_add_dict(dict_T *dict);
|
||||
#endif
|
||||
static int ins_compl_get_exp(pos_T *ini);
|
||||
static void ins_compl_delete(void);
|
||||
static void ins_compl_insert(void);
|
||||
static int ins_compl_next(int allow_get_expansion, int count, int insert_match);
|
||||
static void ins_compl_insert(int in_compl_func);
|
||||
static int ins_compl_next(int allow_get_expansion, int count, int insert_match, int in_compl_func);
|
||||
static int ins_compl_key2dir(int c);
|
||||
static int ins_compl_pum_key(int c);
|
||||
static int ins_compl_key2count(int c);
|
||||
@@ -857,11 +857,12 @@ edit(
|
||||
|
||||
/* Pressing CTRL-Y selects the current match. When
|
||||
* compl_enter_selects is set the Enter key does the same. */
|
||||
if (c == Ctrl_Y || (compl_enter_selects
|
||||
&& (c == CAR || c == K_KENTER || c == NL)))
|
||||
if ((c == Ctrl_Y || (compl_enter_selects
|
||||
&& (c == CAR || c == K_KENTER || c == NL)))
|
||||
&& stop_arrow() == OK)
|
||||
{
|
||||
ins_compl_delete();
|
||||
ins_compl_insert();
|
||||
ins_compl_insert(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2808,9 +2809,6 @@ set_completion(colnr_T startcol, list_T *list)
|
||||
ins_compl_prep(' ');
|
||||
ins_compl_clear();
|
||||
|
||||
if (stop_arrow() == FAIL)
|
||||
return;
|
||||
|
||||
compl_direction = FORWARD;
|
||||
if (startcol > curwin->w_cursor.col)
|
||||
startcol = curwin->w_cursor.col;
|
||||
@@ -3306,7 +3304,7 @@ ins_compl_files(
|
||||
break;
|
||||
}
|
||||
line_breakcheck();
|
||||
ins_compl_check_keys(50);
|
||||
ins_compl_check_keys(50, FALSE);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -3890,7 +3888,8 @@ ins_compl_prep(int c)
|
||||
/* put the cursor on the last char, for 'tw' formatting */
|
||||
if (prev_col > 0)
|
||||
dec_cursor();
|
||||
if (stop_arrow() == OK)
|
||||
/* only format when something was inserted */
|
||||
if (!arrow_used && !ins_need_undo)
|
||||
insertchar(NUL, 0, -1);
|
||||
if (prev_col > 0
|
||||
&& ml_get_curline()[curwin->w_cursor.col] != NUL)
|
||||
@@ -4050,8 +4049,6 @@ ins_compl_next_buf(buf_T *buf, int flag)
|
||||
}
|
||||
|
||||
#ifdef FEAT_COMPL_FUNC
|
||||
static void expand_by_function(int type, char_u *base);
|
||||
|
||||
/*
|
||||
* Execute user defined complete function 'completefunc' or 'omnifunc', and
|
||||
* get matches in "matches".
|
||||
@@ -4610,7 +4607,7 @@ ins_compl_get_exp(pos_T *ini)
|
||||
break;
|
||||
/* Fill the popup menu as soon as possible. */
|
||||
if (type != -1)
|
||||
ins_compl_check_keys(0);
|
||||
ins_compl_check_keys(0, FALSE);
|
||||
|
||||
if ((ctrl_x_mode != 0 && !CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode))
|
||||
|| compl_interrupted)
|
||||
@@ -4651,14 +4648,19 @@ ins_compl_get_exp(pos_T *ini)
|
||||
static void
|
||||
ins_compl_delete(void)
|
||||
{
|
||||
int i;
|
||||
int col;
|
||||
|
||||
/*
|
||||
* In insert mode: Delete the typed part.
|
||||
* In replace mode: Put the old characters back, if any.
|
||||
*/
|
||||
i = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0);
|
||||
backspace_until_column(i);
|
||||
col = compl_col + (compl_cont_status & CONT_ADDING ? compl_length : 0);
|
||||
if ((int)curwin->w_cursor.col > col)
|
||||
{
|
||||
if (stop_arrow() == FAIL)
|
||||
return;
|
||||
backspace_until_column(col);
|
||||
}
|
||||
|
||||
/* TODO: is this sufficient for redrawing? Redrawing everything causes
|
||||
* flicker, thus we can't do that. */
|
||||
@@ -4667,9 +4669,12 @@ ins_compl_delete(void)
|
||||
set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
|
||||
}
|
||||
|
||||
/* Insert the new text being completed. */
|
||||
/*
|
||||
* Insert the new text being completed.
|
||||
* "in_compl_func" is TRUE when called from complete_check().
|
||||
*/
|
||||
static void
|
||||
ins_compl_insert(void)
|
||||
ins_compl_insert(int in_compl_func)
|
||||
{
|
||||
dict_T *dict;
|
||||
|
||||
@@ -4696,7 +4701,8 @@ ins_compl_insert(void)
|
||||
EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO]));
|
||||
}
|
||||
set_vim_var_dict(VV_COMPLETED_ITEM, dict);
|
||||
compl_curr_match = compl_shown_match;
|
||||
if (!in_compl_func)
|
||||
compl_curr_match = compl_shown_match;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4720,7 +4726,8 @@ ins_compl_next(
|
||||
int allow_get_expansion,
|
||||
int count, /* repeat completion this many times; should
|
||||
be at least 1 */
|
||||
int insert_match) /* Insert the newly selected match */
|
||||
int insert_match, /* Insert the newly selected match */
|
||||
int in_compl_func) /* called from complete_check() */
|
||||
{
|
||||
int num_matches = -1;
|
||||
int i;
|
||||
@@ -4870,7 +4877,7 @@ ins_compl_next(
|
||||
else if (insert_match)
|
||||
{
|
||||
if (!compl_get_longest || compl_used_match)
|
||||
ins_compl_insert();
|
||||
ins_compl_insert(in_compl_func);
|
||||
else
|
||||
ins_bytes(compl_leader + ins_compl_len());
|
||||
}
|
||||
@@ -4935,9 +4942,11 @@ ins_compl_next(
|
||||
* mode. Also, when compl_pending is not zero, show a completion as soon as
|
||||
* possible. -- webb
|
||||
* "frequency" specifies out of how many calls we actually check.
|
||||
* "in_compl_func" is TRUE when called from complete_check(), don't set
|
||||
* compl_curr_match.
|
||||
*/
|
||||
void
|
||||
ins_compl_check_keys(int frequency)
|
||||
ins_compl_check_keys(int frequency, int in_compl_func)
|
||||
{
|
||||
static int count = 0;
|
||||
|
||||
@@ -4963,7 +4972,7 @@ ins_compl_check_keys(int frequency)
|
||||
c = safe_vgetc(); /* Eat the character */
|
||||
compl_shows_dir = ins_compl_key2dir(c);
|
||||
(void)ins_compl_next(FALSE, ins_compl_key2count(c),
|
||||
c != K_UP && c != K_DOWN);
|
||||
c != K_UP && c != K_DOWN, in_compl_func);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4986,7 +4995,7 @@ ins_compl_check_keys(int frequency)
|
||||
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
|
||||
|
||||
compl_pending = 0;
|
||||
(void)ins_compl_next(FALSE, todo, TRUE);
|
||||
(void)ins_compl_next(FALSE, todo, TRUE, in_compl_func);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5069,8 +5078,11 @@ ins_complete(int c, int enable_pum)
|
||||
colnr_T curs_col; /* cursor column */
|
||||
int n;
|
||||
int save_w_wrow;
|
||||
int insert_match;
|
||||
|
||||
compl_direction = ins_compl_key2dir(c);
|
||||
insert_match = ins_compl_use_match(c);
|
||||
|
||||
if (!compl_started)
|
||||
{
|
||||
/* First time we hit ^N or ^P (in a row, I mean) */
|
||||
@@ -5496,6 +5508,8 @@ ins_complete(int c, int enable_pum)
|
||||
edit_submode_extra = NULL;
|
||||
out_flush();
|
||||
}
|
||||
else if (insert_match && stop_arrow() == FAIL)
|
||||
return FAIL;
|
||||
|
||||
compl_shown_match = compl_curr_match;
|
||||
compl_shows_dir = compl_direction;
|
||||
@@ -5504,7 +5518,7 @@ ins_complete(int c, int enable_pum)
|
||||
* Find next match (and following matches).
|
||||
*/
|
||||
save_w_wrow = curwin->w_wrow;
|
||||
n = ins_compl_next(TRUE, ins_compl_key2count(c), ins_compl_use_match(c));
|
||||
n = ins_compl_next(TRUE, ins_compl_key2count(c), insert_match, FALSE);
|
||||
|
||||
/* may undisplay the popup menu */
|
||||
ins_compl_upd_pum();
|
||||
|
||||
+1
-1
@@ -2175,7 +2175,7 @@ f_complete_check(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
int saved = RedrawingDisabled;
|
||||
|
||||
RedrawingDisabled = 0;
|
||||
ins_compl_check_keys(0);
|
||||
ins_compl_check_keys(0, TRUE);
|
||||
rettv->vval.v_number = compl_interrupted;
|
||||
RedrawingDisabled = saved;
|
||||
}
|
||||
|
||||
+2
-2
@@ -6908,7 +6908,7 @@ fix_help_buffer(void)
|
||||
continue;
|
||||
e1 = vim_strrchr(t1, '.');
|
||||
e2 = vim_strrchr(gettail(f2), '.');
|
||||
if (e1 == NUL || e2 == NUL)
|
||||
if (e1 == NULL || e2 == NULL)
|
||||
continue;
|
||||
if (fnamecmp(e1, ".txt") != 0
|
||||
&& fnamecmp(e1, fname + 4) != 0)
|
||||
@@ -8205,7 +8205,7 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg)
|
||||
/* :sign define {name} {args}... {last}=
|
||||
* | |
|
||||
* last p */
|
||||
if (p == NUL)
|
||||
if (p == NULL)
|
||||
{
|
||||
/* Expand last argument name (before equal sign). */
|
||||
xp->xp_pattern = last;
|
||||
|
||||
@@ -4291,6 +4291,11 @@ set_one_cmd_context(
|
||||
xp->xp_pattern = arg;
|
||||
break;
|
||||
|
||||
case CMD_messages:
|
||||
xp->xp_context = EXPAND_MESSAGES;
|
||||
xp->xp_pattern = arg;
|
||||
break;
|
||||
|
||||
#if defined(FEAT_CMDHIST)
|
||||
case CMD_history:
|
||||
xp->xp_context = EXPAND_HISTORY;
|
||||
@@ -5910,6 +5915,7 @@ static struct
|
||||
#endif
|
||||
{EXPAND_MAPPINGS, "mapping"},
|
||||
{EXPAND_MENUS, "menu"},
|
||||
{EXPAND_MESSAGES, "messages"},
|
||||
{EXPAND_OWNSYNTAX, "syntax"},
|
||||
#if defined(FEAT_PROFILE)
|
||||
{EXPAND_SYNTIME, "syntime"},
|
||||
@@ -11936,6 +11942,18 @@ get_behave_arg(expand_T *xp UNUSED, int idx)
|
||||
return (char_u *)"xterm";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function given to ExpandGeneric() to obtain the possible arguments of the
|
||||
* ":messages {clear}" command.
|
||||
*/
|
||||
char_u *
|
||||
get_messages_arg(expand_T *xp UNUSED, int idx)
|
||||
{
|
||||
if (idx == 0)
|
||||
return (char_u *)"clear";
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_AUTOCMD
|
||||
|
||||
@@ -4843,6 +4843,7 @@ ExpandFromContext(
|
||||
{
|
||||
{EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
|
||||
{EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
|
||||
{EXPAND_MESSAGES, get_messages_arg, TRUE, TRUE},
|
||||
#ifdef FEAT_CMDHIST
|
||||
{EXPAND_HISTORY, get_history_arg, TRUE, TRUE},
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -861,7 +861,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
|
||||
break;
|
||||
}
|
||||
|
||||
if (res != NUL)
|
||||
if (res != NULL)
|
||||
{
|
||||
res->v_type = VAR_SPECIAL;
|
||||
res->vval.v_number = VVAL_NONE;
|
||||
|
||||
+2
-1
@@ -1597,7 +1597,8 @@ handle_viminfo_mark(garray_T *values, int force)
|
||||
|
||||
if (fm != NULL)
|
||||
{
|
||||
if (vi_namedfm != NULL || fm->time_set < timestamp || force)
|
||||
if (vi_namedfm != NULL || fm->fmark.mark.lnum == 0
|
||||
|| fm->time_set < timestamp || force)
|
||||
{
|
||||
fm->fmark.mark.lnum = lnum;
|
||||
fm->fmark.mark.col = col;
|
||||
|
||||
+2
-5
@@ -2853,11 +2853,8 @@ do_check_cursorbind(void)
|
||||
{
|
||||
# ifdef FEAT_DIFF
|
||||
if (curwin->w_p_diff)
|
||||
curwin->w_cursor.lnum
|
||||
= diff_get_corresponding_line(old_curbuf,
|
||||
line,
|
||||
curbuf,
|
||||
curwin->w_cursor.lnum);
|
||||
curwin->w_cursor.lnum =
|
||||
diff_get_corresponding_line(old_curbuf, line);
|
||||
else
|
||||
# endif
|
||||
curwin->w_cursor.lnum = line;
|
||||
|
||||
+102
-9
@@ -211,6 +211,15 @@ static RETSIGTYPE deathtrap SIGPROTOARG;
|
||||
static void catch_int_signal(void);
|
||||
static void set_signals(void);
|
||||
static void catch_signals(RETSIGTYPE (*func_deadly)(), RETSIGTYPE (*func_other)());
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
# define SIGSET_DECL(set) sigset_t set;
|
||||
# define BLOCK_SIGNALS(set) block_signals(set)
|
||||
# define UNBLOCK_SIGNALS(set) unblock_signals(set)
|
||||
#else
|
||||
# define SIGSET_DECL(set)
|
||||
# define BLOCK_SIGNALS(set) do { /**/ } while (0)
|
||||
# define UNBLOCK_SIGNALS(set) do { /**/ } while (0)
|
||||
#endif
|
||||
static int have_wildcard(int, char_u **);
|
||||
static int have_dollars(int, char_u **);
|
||||
|
||||
@@ -1468,6 +1477,33 @@ catch_signals(
|
||||
signal(signal_info[i].sig, func_other);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
static void
|
||||
block_signals(sigset_t *set)
|
||||
{
|
||||
sigset_t newset;
|
||||
int i;
|
||||
|
||||
sigemptyset(&newset);
|
||||
|
||||
for (i = 0; signal_info[i].sig != -1; i++)
|
||||
sigaddset(&newset, signal_info[i].sig);
|
||||
|
||||
# if defined(_REENTRANT) && defined(SIGCONT)
|
||||
/* SIGCONT isn't in the list, because its default action is ignore */
|
||||
sigaddset(&newset, SIGCONT);
|
||||
# endif
|
||||
|
||||
sigprocmask(SIG_BLOCK, &newset, set);
|
||||
}
|
||||
|
||||
static void
|
||||
unblock_signals(sigset_t *set)
|
||||
{
|
||||
sigprocmask(SIG_SETMASK, set, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handling of SIGHUP, SIGQUIT and SIGTERM:
|
||||
* "when" == a signal: when busy, postpone and return FALSE, otherwise
|
||||
@@ -4301,12 +4337,18 @@ mch_call_shell(
|
||||
|
||||
if (!pipe_error) /* pty or pipe opened or not used */
|
||||
{
|
||||
SIGSET_DECL(curset)
|
||||
|
||||
# ifdef __BEOS__
|
||||
beos_cleanup_read_thread();
|
||||
# endif
|
||||
|
||||
if ((pid = fork()) == -1) /* maybe we should use vfork() */
|
||||
BLOCK_SIGNALS(&curset);
|
||||
pid = fork(); /* maybe we should use vfork() */
|
||||
if (pid == -1)
|
||||
{
|
||||
UNBLOCK_SIGNALS(&curset);
|
||||
|
||||
MSG_PUTS(_("\nCannot fork\n"));
|
||||
if ((options & (SHELL_READ|SHELL_WRITE))
|
||||
# ifdef FEAT_GUI
|
||||
@@ -4333,6 +4375,7 @@ mch_call_shell(
|
||||
else if (pid == 0) /* child */
|
||||
{
|
||||
reset_signals(); /* handle signals normally */
|
||||
UNBLOCK_SIGNALS(&curset);
|
||||
|
||||
if (!show_shell_mess || (options & SHELL_EXPAND))
|
||||
{
|
||||
@@ -4476,6 +4519,7 @@ mch_call_shell(
|
||||
*/
|
||||
catch_signals(SIG_IGN, SIG_ERR);
|
||||
catch_int_signal();
|
||||
UNBLOCK_SIGNALS(&curset);
|
||||
|
||||
/*
|
||||
* For the GUI we redirect stdin, stdout and stderr to our window.
|
||||
@@ -5091,6 +5135,7 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED)
|
||||
int use_file_for_out = options->jo_io[PART_OUT] == JIO_FILE;
|
||||
int use_file_for_err = options->jo_io[PART_ERR] == JIO_FILE;
|
||||
int use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT;
|
||||
SIGSET_DECL(curset)
|
||||
|
||||
if (use_out_for_err && use_null_for_out)
|
||||
use_null_for_err = TRUE;
|
||||
@@ -5162,13 +5207,14 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
BLOCK_SIGNALS(&curset);
|
||||
pid = fork(); /* maybe we should use vfork() */
|
||||
if (pid == -1)
|
||||
if (pid == -1)
|
||||
{
|
||||
/* failed to fork */
|
||||
UNBLOCK_SIGNALS(&curset);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
int null_fd = -1;
|
||||
@@ -5176,6 +5222,7 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED)
|
||||
|
||||
/* child */
|
||||
reset_signals(); /* handle signals normally */
|
||||
UNBLOCK_SIGNALS(&curset);
|
||||
|
||||
# ifdef HAVE_SETSID
|
||||
/* Create our own process group, so that the child and all its
|
||||
@@ -5256,6 +5303,8 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED)
|
||||
}
|
||||
|
||||
/* parent */
|
||||
UNBLOCK_SIGNALS(&curset);
|
||||
|
||||
job->jv_pid = pid;
|
||||
job->jv_status = JOB_STARTED;
|
||||
job->jv_channel = channel; /* ch_refcount was set above */
|
||||
@@ -5316,8 +5365,7 @@ mch_job_status(job_T *job)
|
||||
if (wait_pid == -1)
|
||||
{
|
||||
/* process must have exited */
|
||||
job->jv_status = JOB_ENDED;
|
||||
return "dead";
|
||||
goto return_dead;
|
||||
}
|
||||
if (wait_pid == 0)
|
||||
return "run";
|
||||
@@ -5325,16 +5373,61 @@ mch_job_status(job_T *job)
|
||||
{
|
||||
/* LINTED avoid "bitwise operation on signed value" */
|
||||
job->jv_exitval = WEXITSTATUS(status);
|
||||
job->jv_status = JOB_ENDED;
|
||||
return "dead";
|
||||
goto return_dead;
|
||||
}
|
||||
if (WIFSIGNALED(status))
|
||||
{
|
||||
job->jv_exitval = -1;
|
||||
job->jv_status = JOB_ENDED;
|
||||
return "dead";
|
||||
goto return_dead;
|
||||
}
|
||||
return "run";
|
||||
|
||||
return_dead:
|
||||
if (job->jv_status != JOB_ENDED)
|
||||
{
|
||||
ch_log(job->jv_channel, "Job ended");
|
||||
job->jv_status = JOB_ENDED;
|
||||
}
|
||||
return "dead";
|
||||
}
|
||||
|
||||
job_T *
|
||||
mch_detect_ended_job(job_T *job_list)
|
||||
{
|
||||
# ifdef HAVE_UNION_WAIT
|
||||
union wait status;
|
||||
# else
|
||||
int status = -1;
|
||||
# endif
|
||||
pid_t wait_pid = 0;
|
||||
job_T *job;
|
||||
|
||||
# ifdef __NeXT__
|
||||
wait_pid = wait4(-1, &status, WNOHANG, (struct rusage *)0);
|
||||
# else
|
||||
wait_pid = waitpid(-1, &status, WNOHANG);
|
||||
# endif
|
||||
if (wait_pid <= 0)
|
||||
/* no process ended */
|
||||
return NULL;
|
||||
for (job = job_list; job != NULL; job = job->jv_next)
|
||||
{
|
||||
if (job->jv_pid == wait_pid)
|
||||
{
|
||||
if (WIFEXITED(status))
|
||||
/* LINTED avoid "bitwise operation on signed value" */
|
||||
job->jv_exitval = WEXITSTATUS(status);
|
||||
else if (WIFSIGNALED(status))
|
||||
job->jv_exitval = -1;
|
||||
if (job->jv_status != JOB_ENDED)
|
||||
{
|
||||
ch_log(job->jv_channel, "Job ended");
|
||||
job->jv_status = JOB_ENDED;
|
||||
}
|
||||
return job;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
+41
-1
@@ -4973,13 +4973,53 @@ mch_job_status(job_T *job)
|
||||
if (!GetExitCodeProcess(job->jv_proc_info.hProcess, &dwExitCode)
|
||||
|| dwExitCode != STILL_ACTIVE)
|
||||
{
|
||||
job->jv_status = JOB_ENDED;
|
||||
job->jv_exitval = (int)dwExitCode;
|
||||
if (job->jv_status != JOB_ENDED)
|
||||
{
|
||||
ch_log(job->jv_channel, "Job ended");
|
||||
job->jv_status = JOB_ENDED;
|
||||
}
|
||||
return "dead";
|
||||
}
|
||||
return "run";
|
||||
}
|
||||
|
||||
job_T *
|
||||
mch_detect_ended_job(job_T *job_list)
|
||||
{
|
||||
HANDLE jobHandles[MAXIMUM_WAIT_OBJECTS];
|
||||
job_T *jobArray[MAXIMUM_WAIT_OBJECTS];
|
||||
job_T *job = job_list;
|
||||
|
||||
while (job != NULL)
|
||||
{
|
||||
DWORD n;
|
||||
DWORD result;
|
||||
|
||||
for (n = 0; n < MAXIMUM_WAIT_OBJECTS
|
||||
&& job != NULL; job = job->jv_next)
|
||||
{
|
||||
if (job->jv_status == JOB_STARTED)
|
||||
{
|
||||
jobHandles[n] = job->jv_proc_info.hProcess;
|
||||
jobArray[n] = job;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
if (n == 0)
|
||||
continue;
|
||||
result = WaitForMultipleObjects(n, jobHandles, FALSE, 0);
|
||||
if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + n)
|
||||
{
|
||||
job_T *wait_job = jobArray[result - WAIT_OBJECT_0];
|
||||
|
||||
if (STRCMP(mch_job_status(wait_job), "dead") == 0)
|
||||
return wait_job;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
mch_stop_job(job_T *job, char_u *how)
|
||||
{
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ void nv_diffgetput(int put, long count);
|
||||
void ex_diffgetput(exarg_T *eap);
|
||||
int diff_mode_buf(buf_T *buf);
|
||||
int diff_move_to(int dir, long count);
|
||||
linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1, buf_T *buf2, linenr_T lnum3);
|
||||
linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1);
|
||||
linenr_T diff_lnum_win(linenr_T lnum, win_T *wp);
|
||||
/* vim: set ft=c : */
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ char_u *find_word_start(char_u *ptr);
|
||||
char_u *find_word_end(char_u *ptr);
|
||||
int ins_compl_active(void);
|
||||
int ins_compl_add_tv(typval_T *tv, int dir);
|
||||
void ins_compl_check_keys(int frequency);
|
||||
void ins_compl_check_keys(int frequency, int in_compl_func);
|
||||
int get_literal(void);
|
||||
void insertchar(int c, int flags, int second_indent);
|
||||
void auto_format(int trailblank, int prev_line);
|
||||
|
||||
@@ -61,4 +61,5 @@ int put_eol(FILE *fd);
|
||||
int put_line(FILE *fd, char *s);
|
||||
void dialog_msg(char_u *buff, char *format, char_u *fname);
|
||||
char_u *get_behave_arg(expand_T *xp, int idx);
|
||||
char_u *get_messages_arg(expand_T *xp, int idx);
|
||||
/* vim: set ft=c : */
|
||||
|
||||
@@ -59,6 +59,7 @@ int mch_parse_cmd(char_u *cmd, int use_shcf, char ***argv, int *argc);
|
||||
int mch_call_shell(char_u *cmd, int options);
|
||||
void mch_start_job(char **argv, job_T *job, jobopt_T *options);
|
||||
char *mch_job_status(job_T *job);
|
||||
job_T *mch_detect_ended_job(job_T *job_list);
|
||||
int mch_stop_job(job_T *job, char_u *how);
|
||||
void mch_clear_job(job_T *job);
|
||||
void mch_breakcheck(int force);
|
||||
|
||||
@@ -41,6 +41,7 @@ void mch_set_winsize_now(void);
|
||||
int mch_call_shell(char_u *cmd, int options);
|
||||
void mch_start_job(char *cmd, job_T *job, jobopt_T *options);
|
||||
char *mch_job_status(job_T *job);
|
||||
job_T *mch_detect_ended_job(job_T *job_list);
|
||||
int mch_stop_job(job_T *job, char_u *how);
|
||||
void mch_clear_job(job_T *job);
|
||||
void mch_set_normal_colors(void);
|
||||
|
||||
+1
-1
@@ -2266,7 +2266,7 @@ win_found:
|
||||
|
||||
ok = buflist_getfile(qf_ptr->qf_fnum,
|
||||
(linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
|
||||
if (qi != &ql_info && !win_valid(oldwin))
|
||||
if (qi != &ql_info && !win_valid_any_tab(oldwin))
|
||||
{
|
||||
EMSG(_("E924: Current window was closed"));
|
||||
is_abort = TRUE;
|
||||
|
||||
+32
-29
@@ -7786,6 +7786,10 @@ next_search_hl(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is a match fill "shl" and return one.
|
||||
* Return zero otherwise.
|
||||
*/
|
||||
static int
|
||||
next_search_hl_pos(
|
||||
match_T *shl, /* points to a match */
|
||||
@@ -7794,53 +7798,52 @@ next_search_hl_pos(
|
||||
colnr_T mincol) /* minimal column for a match */
|
||||
{
|
||||
int i;
|
||||
int bot = -1;
|
||||
int found = -1;
|
||||
|
||||
shl->lnum = 0;
|
||||
for (i = posmatch->cur; i < MAXPOSMATCH; i++)
|
||||
{
|
||||
if (posmatch->pos[i].lnum == 0)
|
||||
break;
|
||||
if (posmatch->pos[i].col < mincol)
|
||||
continue;
|
||||
if (posmatch->pos[i].lnum == lnum)
|
||||
{
|
||||
if (shl->lnum == lnum)
|
||||
{
|
||||
/* partially sort positions by column numbers
|
||||
* on the same line */
|
||||
if (posmatch->pos[i].col < posmatch->pos[bot].col)
|
||||
{
|
||||
llpos_T tmp = posmatch->pos[i];
|
||||
llpos_T *pos = &posmatch->pos[i];
|
||||
|
||||
posmatch->pos[i] = posmatch->pos[bot];
|
||||
posmatch->pos[bot] = tmp;
|
||||
if (pos->lnum == 0)
|
||||
break;
|
||||
if (pos->len == 0 && pos->col < mincol)
|
||||
continue;
|
||||
if (pos->lnum == lnum)
|
||||
{
|
||||
if (found >= 0)
|
||||
{
|
||||
/* if this match comes before the one at "found" then swap
|
||||
* them */
|
||||
if (pos->col < posmatch->pos[found].col)
|
||||
{
|
||||
llpos_T tmp = *pos;
|
||||
|
||||
*pos = posmatch->pos[found];
|
||||
posmatch->pos[found] = tmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bot = i;
|
||||
shl->lnum = lnum;
|
||||
}
|
||||
found = i;
|
||||
}
|
||||
}
|
||||
posmatch->cur = 0;
|
||||
if (shl->lnum == lnum && bot >= 0)
|
||||
if (found >= 0)
|
||||
{
|
||||
colnr_T start = posmatch->pos[bot].col == 0
|
||||
? 0 : posmatch->pos[bot].col - 1;
|
||||
colnr_T end = posmatch->pos[bot].col == 0
|
||||
? MAXCOL : start + posmatch->pos[bot].len;
|
||||
colnr_T start = posmatch->pos[found].col == 0
|
||||
? 0 : posmatch->pos[found].col - 1;
|
||||
colnr_T end = posmatch->pos[found].col == 0
|
||||
? MAXCOL : start + posmatch->pos[found].len;
|
||||
|
||||
shl->lnum = lnum;
|
||||
shl->rm.startpos[0].lnum = 0;
|
||||
shl->rm.startpos[0].col = start;
|
||||
shl->rm.endpos[0].lnum = 0;
|
||||
shl->rm.endpos[0].col = end;
|
||||
shl->is_addpos = TRUE;
|
||||
posmatch->cur = bot + 1;
|
||||
return TRUE;
|
||||
posmatch->cur = found + 1;
|
||||
return 1;
|
||||
}
|
||||
return FALSE;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -5444,7 +5444,7 @@ exit_matched:
|
||||
#endif
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
if (action == ACTION_EXPAND)
|
||||
ins_compl_check_keys(30);
|
||||
ins_compl_check_keys(30, FALSE);
|
||||
if (got_int || compl_interrupted)
|
||||
#else
|
||||
if (got_int)
|
||||
|
||||
+1
-1
@@ -8694,7 +8694,7 @@ spell_dump_compl(
|
||||
/* Done all bytes at this node, go up one level. */
|
||||
--depth;
|
||||
line_breakcheck();
|
||||
ins_compl_check_keys(50);
|
||||
ins_compl_check_keys(50, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1587,7 +1587,7 @@ find_tags(
|
||||
fast_breakcheck();
|
||||
#ifdef FEAT_INS_EXPAND
|
||||
if ((flags & TAG_INS_COMP)) /* Double brackets for gcc */
|
||||
ins_compl_check_keys(30);
|
||||
ins_compl_check_keys(30, FALSE);
|
||||
if (got_int || compl_interrupted)
|
||||
#else
|
||||
if (got_int)
|
||||
|
||||
@@ -55,7 +55,6 @@ SCRIPTS_ALL = \
|
||||
test70.out \
|
||||
test73.out \
|
||||
test75.out \
|
||||
test76.out \
|
||||
test77.out \
|
||||
test79.out \
|
||||
test80.out \
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
Tests for completefunc/omnifunc. vim: set ft=vim :
|
||||
|
||||
STARTTEST
|
||||
:"Test that nothing happens if the 'completefunc' opens
|
||||
:"a new window (no completion, no crash)
|
||||
:so small.vim
|
||||
:function! DummyCompleteOne(findstart, base)
|
||||
: if a:findstart
|
||||
: return 0
|
||||
: else
|
||||
: wincmd n
|
||||
: return ['onedef', 'oneDEF']
|
||||
: endif
|
||||
:endfunction
|
||||
:setlocal completefunc=DummyCompleteOne
|
||||
/^one
|
||||
A:q!
|
||||
:function! DummyCompleteTwo(findstart, base)
|
||||
: if a:findstart
|
||||
: wincmd n
|
||||
: return 0
|
||||
: else
|
||||
: return ['twodef', 'twoDEF']
|
||||
: endif
|
||||
:endfunction
|
||||
:setlocal completefunc=DummyCompleteTwo
|
||||
/^two
|
||||
A:q!
|
||||
:"Test that 'completefunc' works when it's OK.
|
||||
:function! DummyCompleteThree(findstart, base)
|
||||
: if a:findstart
|
||||
: return 0
|
||||
: else
|
||||
: return ['threedef', 'threeDEF']
|
||||
: endif
|
||||
:endfunction
|
||||
:setlocal completefunc=DummyCompleteThree
|
||||
/^three
|
||||
A:/^+++/,/^three/w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
+++
|
||||
one
|
||||
two
|
||||
three
|
||||
@@ -1,4 +0,0 @@
|
||||
+++
|
||||
|
||||
two
|
||||
threeDEF
|
||||
@@ -1362,6 +1362,24 @@ func Test_exit_callback()
|
||||
endif
|
||||
endfunc
|
||||
|
||||
let g:exit_cb_time = {'start': 0, 'end': 0}
|
||||
function MyExitTimeCb(job, status)
|
||||
let g:exit_cb_time.end = reltime(g:exit_cb_time.start)
|
||||
endfunction
|
||||
|
||||
func Test_exit_callback_interval()
|
||||
if !has('job')
|
||||
return
|
||||
endif
|
||||
|
||||
let g:exit_cb_time.start = reltime()
|
||||
let job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'})
|
||||
call WaitFor('g:exit_cb_time.end != 0')
|
||||
let elapsed = reltimefloat(g:exit_cb_time.end)
|
||||
call assert_true(elapsed > 0.3)
|
||||
call assert_true(elapsed < 1.0)
|
||||
endfunc
|
||||
|
||||
"""""""""
|
||||
|
||||
let g:Ch_close_ret = 'alive'
|
||||
@@ -1415,6 +1433,21 @@ func Test_job_start_invalid()
|
||||
call assert_fails('call job_start("")', 'E474:')
|
||||
endfunc
|
||||
|
||||
func Test_job_stop_immediately()
|
||||
if !has('job')
|
||||
return
|
||||
endif
|
||||
|
||||
let job = job_start([s:python, '-c', 'import time;time.sleep(10)'])
|
||||
try
|
||||
call job_stop(job)
|
||||
call WaitFor('"dead" == job_status(job)')
|
||||
call assert_equal('dead', job_status(job))
|
||||
finally
|
||||
call job_stop(job, 'kill')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" This was leaking memory.
|
||||
func Test_partial_in_channel_cycle()
|
||||
let d = {}
|
||||
|
||||
@@ -129,6 +129,11 @@ func Test_getcompletion()
|
||||
let l = getcompletion('dark', 'highlight')
|
||||
call assert_equal([], l)
|
||||
|
||||
let l = getcompletion('', 'messages')
|
||||
call assert_true(index(l, 'clear') >= 0)
|
||||
let l = getcompletion('not', 'messages')
|
||||
call assert_equal([], l)
|
||||
|
||||
if has('cscope')
|
||||
let l = getcompletion('', 'cscope')
|
||||
let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show']
|
||||
|
||||
@@ -218,3 +218,20 @@ func Test_diffoff()
|
||||
bwipe!
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_setting_cursor()
|
||||
new Xtest1
|
||||
put =range(1,90)
|
||||
wq
|
||||
new Xtest2
|
||||
put =range(1,100)
|
||||
wq
|
||||
|
||||
tabe Xtest2
|
||||
$
|
||||
diffsp Xtest1
|
||||
tabclose
|
||||
|
||||
call delete('Xtest1')
|
||||
call delete('Xtest2')
|
||||
endfunc
|
||||
|
||||
@@ -181,7 +181,25 @@ func Test_matchaddpos()
|
||||
redraw!
|
||||
call assert_equal(screenattr(2,2), screenattr(1,6))
|
||||
|
||||
" Check overlapping pos
|
||||
call clearmatches()
|
||||
call setline(1, ['1234567890', 'NH'])
|
||||
call matchaddpos('Error', [[1,1,5], [1,3,5], [2,2]])
|
||||
redraw!
|
||||
call assert_notequal(screenattr(2,2), 0)
|
||||
call assert_equal(screenattr(2,2), screenattr(1,5))
|
||||
call assert_equal(screenattr(2,2), screenattr(1,7))
|
||||
call assert_notequal(screenattr(2,2), screenattr(1,8))
|
||||
|
||||
call clearmatches()
|
||||
call matchaddpos('Error', [[1], [2,2]])
|
||||
redraw!
|
||||
call assert_equal(screenattr(2,2), screenattr(1,1))
|
||||
call assert_equal(screenattr(2,2), screenattr(1,10))
|
||||
call assert_notequal(screenattr(2,2), screenattr(1,11))
|
||||
|
||||
nohl
|
||||
call clearmatches()
|
||||
syntax off
|
||||
set hlsearch&
|
||||
endfunc
|
||||
|
||||
@@ -289,4 +289,153 @@ func Test_compl_vim_cmds_after_register_expr()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func DummyCompleteOne(findstart, base)
|
||||
if a:findstart
|
||||
return 0
|
||||
else
|
||||
wincmd n
|
||||
return ['onedef', 'oneDEF']
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Test that nothing happens if the 'completefunc' opens
|
||||
" a new window (no completion, no crash)
|
||||
func Test_completefunc_opens_new_window_one()
|
||||
new
|
||||
let winid = win_getid()
|
||||
setlocal completefunc=DummyCompleteOne
|
||||
call setline(1, 'one')
|
||||
/^one
|
||||
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E839:')
|
||||
call assert_notequal(winid, win_getid())
|
||||
q!
|
||||
call assert_equal(winid, win_getid())
|
||||
call assert_equal('', getline(1))
|
||||
q!
|
||||
endfunc
|
||||
|
||||
" Test that nothing happens if the 'completefunc' opens
|
||||
" a new window (no completion, no crash)
|
||||
func DummyCompleteTwo(findstart, base)
|
||||
if a:findstart
|
||||
wincmd n
|
||||
return 0
|
||||
else
|
||||
return ['twodef', 'twoDEF']
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Test that nothing happens if the 'completefunc' opens
|
||||
" a new window (no completion, no crash)
|
||||
func Test_completefunc_opens_new_window_two()
|
||||
new
|
||||
let winid = win_getid()
|
||||
setlocal completefunc=DummyCompleteTwo
|
||||
call setline(1, 'two')
|
||||
/^two
|
||||
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E764:')
|
||||
call assert_notequal(winid, win_getid())
|
||||
q!
|
||||
call assert_equal(winid, win_getid())
|
||||
call assert_equal('two', getline(1))
|
||||
q!
|
||||
endfunc
|
||||
|
||||
func DummyCompleteThree(findstart, base)
|
||||
if a:findstart
|
||||
return 0
|
||||
else
|
||||
return ['threedef', 'threeDEF']
|
||||
endif
|
||||
endfunc
|
||||
|
||||
:"Test that 'completefunc' works when it's OK.
|
||||
func Test_completefunc_works()
|
||||
new
|
||||
let winid = win_getid()
|
||||
setlocal completefunc=DummyCompleteThree
|
||||
call setline(1, 'three')
|
||||
/^three
|
||||
call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")
|
||||
call assert_equal(winid, win_getid())
|
||||
call assert_equal('threeDEF', getline(1))
|
||||
q!
|
||||
endfunc
|
||||
|
||||
func DummyCompleteFour(findstart, base)
|
||||
if a:findstart
|
||||
return 0
|
||||
else
|
||||
call complete_add('four1')
|
||||
call complete_add('four2')
|
||||
call complete_check()
|
||||
call complete_add('four3')
|
||||
call complete_add('four4')
|
||||
call complete_check()
|
||||
call complete_add('four5')
|
||||
call complete_add('four6')
|
||||
return []
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Test that 'completefunc' works when it's OK.
|
||||
func Test_omnifunc_with_check()
|
||||
new
|
||||
setlocal omnifunc=DummyCompleteFour
|
||||
call setline(1, 'four')
|
||||
/^four
|
||||
call feedkeys("A\<C-X>\<C-O>\<C-N>\<Esc>", "x")
|
||||
call assert_equal('four2', getline(1))
|
||||
|
||||
call setline(1, 'four')
|
||||
/^four
|
||||
call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<Esc>", "x")
|
||||
call assert_equal('four3', getline(1))
|
||||
|
||||
call setline(1, 'four')
|
||||
/^four
|
||||
call feedkeys("A\<C-X>\<C-O>\<C-N>\<C-N>\<C-N>\<C-N>\<Esc>", "x")
|
||||
call assert_equal('four5', getline(1))
|
||||
|
||||
q!
|
||||
endfunc
|
||||
|
||||
function UndoComplete()
|
||||
call complete(1, ['January', 'February', 'March',
|
||||
\ 'April', 'May', 'June', 'July', 'August', 'September',
|
||||
\ 'October', 'November', 'December'])
|
||||
return ''
|
||||
endfunc
|
||||
|
||||
" Test that no undo item is created when no completion is inserted
|
||||
func Test_complete_no_undo()
|
||||
set completeopt=menu,preview,noinsert,noselect
|
||||
inoremap <Right> <C-R>=UndoComplete()<CR>
|
||||
new
|
||||
call feedkeys("ixxx\<CR>\<CR>yyy\<Esc>k", 'xt')
|
||||
call feedkeys("iaaa\<Esc>0", 'xt')
|
||||
call assert_equal('aaa', getline(2))
|
||||
call feedkeys("i\<Right>\<Esc>", 'xt')
|
||||
call assert_equal('aaa', getline(2))
|
||||
call feedkeys("u", 'xt')
|
||||
call assert_equal('', getline(2))
|
||||
|
||||
call feedkeys("ibbb\<Esc>0", 'xt')
|
||||
call assert_equal('bbb', getline(2))
|
||||
call feedkeys("A\<Right>\<Down>\<CR>\<Esc>", 'xt')
|
||||
call assert_equal('January', getline(2))
|
||||
call feedkeys("u", 'xt')
|
||||
call assert_equal('bbb', getline(2))
|
||||
|
||||
call feedkeys("A\<Right>\<C-N>\<Esc>", 'xt')
|
||||
call assert_equal('January', getline(2))
|
||||
call feedkeys("u", 'xt')
|
||||
call assert_equal('bbb', getline(2))
|
||||
|
||||
iunmap <Right>
|
||||
set completeopt&
|
||||
q!
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -617,6 +617,22 @@ function Test_locationlist_curwin_was_closed()
|
||||
augroup! testgroup
|
||||
endfunction
|
||||
|
||||
function Test_locationlist_cross_tab_jump()
|
||||
call writefile(['loclistfoo'], 'loclistfoo')
|
||||
call writefile(['loclistbar'], 'loclistbar')
|
||||
set switchbuf=usetab
|
||||
|
||||
edit loclistfoo
|
||||
tabedit loclistbar
|
||||
silent lgrep loclistfoo loclist*
|
||||
call assert_equal(1, tabpagenr())
|
||||
|
||||
enew | only | tabonly
|
||||
set switchbuf&vim
|
||||
call delete('loclistfoo')
|
||||
call delete('loclistbar')
|
||||
endfunction
|
||||
|
||||
" More tests for 'errorformat'
|
||||
function! Test_efm1()
|
||||
if !has('unix')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
" Test for reading and writing .viminfo
|
||||
|
||||
function Test_read_and_write()
|
||||
function Test_viminfo_read_and_write()
|
||||
call histdel(':')
|
||||
let lines = [
|
||||
\ '# comment line',
|
||||
@@ -17,7 +17,7 @@ function Test_read_and_write()
|
||||
let lines = readfile('Xviminfo')
|
||||
let done = 0
|
||||
for line in lines
|
||||
if line[0] == '|' && line !~ '^|[234],'
|
||||
if line[0] == '|' && line !~ '^|[234],' && line !~ '^|<'
|
||||
if done == 0
|
||||
call assert_equal('|1,4', line)
|
||||
elseif done == 1
|
||||
@@ -469,7 +469,27 @@ func Test_viminfo_file_mark_tabclose()
|
||||
silent! bwipe Xtestfileintab
|
||||
endfunc
|
||||
|
||||
func Test_oldfiles()
|
||||
func Test_viminfo_file_mark_zero_time()
|
||||
let lines = [
|
||||
\ '# Viminfo version',
|
||||
\ '|1,4',
|
||||
\ '',
|
||||
\ '*encoding=utf-8',
|
||||
\ '',
|
||||
\ '# File marks:',
|
||||
\ "'B 1 0 /tmp/nothing",
|
||||
\ '|4,66,1,0,0,"/tmp/nothing"',
|
||||
\ "",
|
||||
\ ]
|
||||
call writefile(lines, 'Xviminfo')
|
||||
delmark B
|
||||
rviminfo Xviminfo
|
||||
call delete('Xviminfo')
|
||||
call assert_equal(1, line("'B"))
|
||||
delmark B
|
||||
endfunc
|
||||
|
||||
func Test_viminfo_oldfiles()
|
||||
let v:oldfiles = []
|
||||
let lines = [
|
||||
\ '# comment line',
|
||||
|
||||
@@ -779,6 +779,34 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
46,
|
||||
/**/
|
||||
45,
|
||||
/**/
|
||||
44,
|
||||
/**/
|
||||
43,
|
||||
/**/
|
||||
42,
|
||||
/**/
|
||||
41,
|
||||
/**/
|
||||
40,
|
||||
/**/
|
||||
39,
|
||||
/**/
|
||||
38,
|
||||
/**/
|
||||
37,
|
||||
/**/
|
||||
36,
|
||||
/**/
|
||||
35,
|
||||
/**/
|
||||
34,
|
||||
/**/
|
||||
33,
|
||||
/**/
|
||||
32,
|
||||
/**/
|
||||
|
||||
@@ -795,6 +795,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
|
||||
#define EXPAND_SYNTIME 43
|
||||
#define EXPAND_USER_ADDR_TYPE 44
|
||||
#define EXPAND_PACKADD 45
|
||||
#define EXPAND_MESSAGES 46
|
||||
#define EXPAND_MACACTION 46
|
||||
|
||||
/* Values for exmode_active (0 is no exmode) */
|
||||
@@ -2497,7 +2498,8 @@ typedef enum
|
||||
#define FNE_INCL_BR 1 /* include [] in name */
|
||||
#define FNE_CHECK_START 2 /* check name starts with valid character */
|
||||
|
||||
#if (defined(sun) || defined(__FreeBSD__)) && defined(S_ISCHR)
|
||||
#if (defined(sun) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) \
|
||||
&& defined(S_ISCHR)
|
||||
# define OPEN_CHR_FILES
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user