mirror of
https://github.com/textmate/textmate.git
synced 2026-01-20 04:08:04 -05:00
Don’t create NSSpellChecker tags until needed
This commit is contained in:
@@ -14,14 +14,17 @@ namespace ns
|
||||
struct spelling_tag_t
|
||||
{
|
||||
spelling_tag_t () : _helper(new helper_t) { }
|
||||
operator long int () const { return _helper->_tag; }
|
||||
operator long int () const { return _helper->tag(); }
|
||||
|
||||
private:
|
||||
struct PUBLIC helper_t
|
||||
{
|
||||
helper_t ();
|
||||
~helper_t ();
|
||||
long int tag ();
|
||||
|
||||
private:
|
||||
long int _tag;
|
||||
bool _did_setup = false;
|
||||
};
|
||||
|
||||
std::shared_ptr<helper_t> _helper;
|
||||
|
||||
@@ -5,20 +5,28 @@
|
||||
|
||||
namespace ns
|
||||
{
|
||||
spelling_tag_t::helper_t::helper_t ()
|
||||
long int spelling_tag_t::helper_t::tag ()
|
||||
{
|
||||
_tag = [NSSpellChecker uniqueSpellDocumentTag];
|
||||
if(!_did_setup)
|
||||
{
|
||||
_tag = [NSSpellChecker uniqueSpellDocumentTag];
|
||||
_did_setup = true;
|
||||
}
|
||||
return _tag;
|
||||
}
|
||||
|
||||
spelling_tag_t::helper_t::~helper_t ()
|
||||
{
|
||||
@autoreleasepool {
|
||||
[[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:_tag];
|
||||
if(_did_setup)
|
||||
{
|
||||
@autoreleasepool {
|
||||
[[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:_tag];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename _OutputIter>
|
||||
_OutputIter spellcheck (char const* first, char const* last, std::string const& language, int tag, size_t offset, _OutputIter out)
|
||||
_OutputIter spellcheck (char const* first, char const* last, std::string const& language, long int tag, size_t offset, _OutputIter out)
|
||||
{
|
||||
NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
|
||||
NSString* lang = [NSString stringWithCxxString:language];
|
||||
|
||||
Reference in New Issue
Block a user