@@ -172,6 +172,7 @@ static auto createSubFollowSymbolSubmenu(const CommandArgs &data, QMenu *menu,
172172 auto const fieldType = tag[GlobalArguments::Type].toString ();
173173 auto const fieldValue = tag[GlobalArguments::Value].toString ();
174174 auto const rawAddress = tag[GlobalArguments::Raw].toString ();
175+ auto const lineNumber = tag[GlobalArguments::LineNumber].toInt ();
175176 auto address = rawAddress;
176177 if (address.startsWith (START_MARKER ) && address.endsWith (END_MARKER ) &&
177178 address.length () > MIN_LENGTH ) {
@@ -180,7 +181,16 @@ static auto createSubFollowSymbolSubmenu(const CommandArgs &data, QMenu *menu,
180181
181182 auto fi = QFileInfo (fileName);
182183 auto simpleFileName = fi.fileName ();
183- auto title = QString (" %1 - %2 %3" ).arg (simpleFileName, fieldType, fieldValue);
184+ auto title = QString ();
185+ if (lineNumber > 0 ) {
186+ title = QString (" %1:%2 - %3 %4" )
187+ .arg (simpleFileName)
188+ .arg (lineNumber)
189+ .arg (fieldType, fieldValue);
190+ } else {
191+ title = QString (" %1 - %2 %3" ).arg (simpleFileName, fieldType, fieldValue);
192+ }
193+
184194 auto a = new QAction (title, menu);
185195 QObject::connect (a, &QAction::triggered, a, [fileName, rawAddress, address, manager]() {
186196 auto nativeFileName = QDir::toNativeSeparators (fileName);
@@ -282,13 +292,13 @@ qmdiEditor::qmdiEditor(QWidget *p, Qutepart::ThemeManager *themes)
282292 auto layout = new QVBoxLayout (this );
283293
284294 // Set up completion callback
285- textEditor->setCompletionCallback ([ this ]( const QString &prefix, const QString &previousWord,
286- const QString &separator) {
287- if (prefix.length () < 2 && separator.isEmpty ()) {
288- return QFuture<QSet<QString >>();
289- }
290- return this ->getTagCompletions (prefix, previousWord, separator);
291- });
295+ textEditor->setCompletionCallback (
296+ [ this ]( const QString &prefix, const QString &previousWord, const QString &separator) {
297+ if (prefix.length () < 2 && separator.isEmpty ()) {
298+ return QFuture<QSet<Qutepart::CompletionItem >>();
299+ }
300+ return this ->getTagCompletions (prefix, previousWord, separator);
301+ });
292302
293303 operationsWidget->hide ();
294304 setupActions ();
@@ -479,7 +489,7 @@ qmdiEditor::~qmdiEditor() {
479489 mdiServer = nullptr ;
480490}
481491
482- bool qmdiEditor::saveClientConent () {
492+ bool qmdiEditor::saveClientContent () {
483493 deleteBackup ();
484494 return doSave ();
485495}
@@ -1090,7 +1100,7 @@ void qmdiEditor::handleTabDeselected() {
10901100 loadingTimer = nullptr ;
10911101}
10921102
1093- QFuture<QSet<QString >> qmdiEditor::getTagCompletions (const QString &prefix, const QString &previousWord,
1103+ QFuture<QSet<Qutepart::CompletionItem >> qmdiEditor::getTagCompletions (const QString &prefix, const QString &previousWord,
10941104 const QString &separator) {
10951105 if (!mdiServer || !mdiServer->mdiHost ) {
10961106 return {};
@@ -1114,19 +1124,35 @@ QFuture<QSet<QString>> qmdiEditor::getTagCompletions(const QString &prefix, cons
11141124
11151125 auto future = pluginManager->handleCommandAsync (GlobalCommands::VariableInfo, args);
11161126
1117- // Transform the result to QSet<QString> using QtConcurrent::run
1118- return future.then ([](const QFuture<CommandArgs> &f) -> QSet<QString> {
1119- QSet<QString> completions;
1120- if (f.isFinished () && f.isValid ()) {
1121- auto result = f.result ();
1122- if (result.contains (GlobalArguments::Tags)) {
1123- auto tags = result[GlobalArguments::Tags].toList ();
1124- for (const QVariant &item : std::as_const (tags)) {
1125- auto const tag = item.toHash ();
1126- auto const name = tag[GlobalArguments::Name].toString ();
1127- if (!name.isEmpty ()) {
1128- completions.insert (name);
1127+ return future.then ([](const QFuture<CommandArgs> &f) -> QSet<Qutepart::CompletionItem> {
1128+ auto completions = QSet<Qutepart::CompletionItem>();
1129+ if (!f.isFinished () || !f.isValid ()) {
1130+ return completions;
1131+ }
1132+
1133+ auto result = f.result ();
1134+ if (result.contains (GlobalArguments::Tags)) {
1135+ auto tags = result[GlobalArguments::Tags].toList ();
1136+ for (const QVariant &item : std::as_const (tags)) {
1137+ auto const tag = item.toHash ();
1138+ auto const name = tag[GlobalArguments::Name].toString ();
1139+ auto const type = tag[GlobalArguments::Type].toString ();
1140+ auto const fileName = tag[GlobalArguments::FileName].toString ();
1141+ auto const lineNumber = tag[GlobalArguments::LineNumber].toInt ();
1142+
1143+ if (!name.isEmpty ()) {
1144+ QString sourceName = " TreeSitter" ;
1145+ if (type == " tag" || type.isEmpty ()) sourceName = " CTags" ;
1146+
1147+ QString sourceInfo = sourceName;
1148+ if (!fileName.isEmpty ()) {
1149+ QFileInfo fi (fileName);
1150+ sourceInfo += " /" + fi.fileName ();
1151+ if (lineNumber > 0 ) {
1152+ sourceInfo += " :" + QString::number (lineNumber);
1153+ }
11291154 }
1155+ completions.insert (Qutepart::CompletionItem (name, sourceInfo));
11301156 }
11311157 }
11321158 }
0 commit comments