View Issue Details

IDProjectCategoryView StatusLast Update
0003426Far ManagerDialogpublic2017-10-25 20:04
ReporterCDK Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version3.0 
Summary0003426: Предлагаю добавить возможность отключать кавычки в автодополнении в диалоге
DescriptionНапример добавить в far:config параметр WithoutQuotesInDialog (по умолчанию false).

Если включено WithoutQuotesInDialog, AppendCompletion, Dialogs.AutoComplete и в строке нет кавычек, то не добавлять кавычки в список автодополнения.

Т.к. в этом случае перестает работать автодополнение путей с пробелами, то, если ничего не найдено (список автодополнения пуст), то смотреть строку с начала.
TagsAutoCompletion
Build

Activities

CDK

2017-04-23 13:01

reporter  

editcontrol_WithoutQuotesInDialog.diff (3,141 bytes)   
Index: editcontrol.cpp
===================================================================
--- editcontrol.cpp	(revision 14874)
+++ editcontrol.cpp	(working copy)
@@ -157,7 +157,7 @@
 
 using enumerator_type = void(VMenu2&, const string&, const std::function<void(const string&)>&);
 
-static bool EnumWithQuoutes(VMenu2& Menu, const string& Str, enumerator_type Enumerator)
+static bool EnumWithQuoutes(VMenu2& Menu, const string& Str, enumerator_type Enumerator, bool UseQuotes = true) // UseQuotes added - allows to skip quotes
 {
 	bool Result = false;
 	if(!Str.empty())
@@ -210,10 +210,11 @@
 		const auto strStart = Str.substr(0, Pos);
 		auto Token = Str.substr(Pos);
 		Unquote(Token);
+
+		std::set<string, string_i_less> ResultStrings; // moved here from "if" below
+
 		if (!Token.empty())
 		{
-			std::set<string, string_i_less> ResultStrings;
-
 			Enumerator(Menu, Token, [&](const string& strAdd)
 			{
 				ResultStrings.emplace(strAdd);
@@ -227,7 +228,8 @@
 				{
 					if (!StartQuote)
 					{
-						QuoteSpace(i);
+						if (UseQuotes) // UseQuotes added - allows to skip quotes
+							QuoteSpace(i);
 					}
 					auto strTmp = strStart + i;
 					if (StartQuote)
@@ -240,11 +242,41 @@
 				Result = true;
 			}
 		}
+
+		// now check the whole string if quotes not used
+		if (!UseQuotes && (Token.empty() || Token != Str.substr(0)))
+		{
+			Token = Str.substr(0);
+			Unquote(Token);
+
+			Enumerator(Menu, Token, [&](const string& strAdd)
+			{
+				ResultStrings.emplace(strAdd);
+			});
+
+			if (!ResultStrings.empty())
+			{
+				AddSeparatorOrSetTitle(Menu, lng::MCompletionFilesTitle);
+
+				for (auto i : ResultStrings)
+				{
+					auto strTmp = i;
+					if (StartQuote)
+					{
+						strTmp += L'"';
+					}
+					Menu.AddItem(strTmp);
+				}
+
+				Result = true;
+			}
+		}
 	}
 	return Result;
 }
 
-static bool EnumFiles(VMenu2& Menu, const string& Str)
+static bool EnumFiles(VMenu2& Menu, const string& Str, bool UseQuotes) // UseQuotes added - allows to skip quotes
 {
 	SCOPED_ACTION(elevation::suppress);
 
@@ -260,7 +292,7 @@
 				Inserter(Token.substr(0, FileName - Token.data()) + (NameMatch? i.strFileName : i.strAlternateFileName));
 			}
 		}
-	});
+	}, UseQuotes); // UseQuotes added
 }
 
 static bool EnumModules(VMenu2& Menu, const string& Module)
@@ -453,7 +485,16 @@
 		{
 			if(ECFlags.Check(EC_COMPLETE_FILESYSTEM) && CompletionEnabled(Global->Opt->AutoComplete.UseFilesystem))
 			{
-				EnumFiles(Menu,Str);
+				bool UseQuotes = true;
+				if (Global->Opt->AutoComplete.WithoutQuotesInDialog && Str.find(L"\"") == static_cast<size_t>(-1)) // if there are no quotes already
+				{
+					//use quotes always, except AppendCompletion in dialog
+					UseQuotes = !(Area == MACROAREA_DIALOGAUTOCOMPLETION && Global->Opt->AutoComplete.AppendCompletion && Global->Opt->Dialogs.AutoComplete);
+				}
+
+				EnumFiles(Menu, Str, UseQuotes); // UseQuotes added
 			}
 			if(ECFlags.Check(EC_COMPLETE_ENVIRONMENT) && CompletionEnabled(Global->Opt->AutoComplete.UseEnvironment))
 			{

Issue History

Date Modified Username Field Change
2017-04-23 13:01 CDK New Issue
2017-04-23 13:01 CDK File Added: editcontrol_WithoutQuotesInDialog.diff
2017-10-25 20:04 JohnDoe Tag Attached: AutoCompletion