-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Headline as breadcrumb above the body text.
Fixes #104
- Loading branch information
Showing
5 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4487,4 +4487,4 @@ | |
"showdown": "^2.1.0", | ||
"stream": "^0.0.2" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as vscode from "vscode"; | ||
import { Constants } from "./constants"; | ||
import * as utils from "./utils"; | ||
import { LeoBodyProvider } from "./leoBody"; | ||
import { LeoBodyDetachedProvider } from "./leoBodyDetached"; | ||
import { VNode } from "./core/leoNodes"; | ||
|
||
export class LeoBodyDocumentSymbolProvider implements vscode.DocumentSymbolProvider { | ||
constructor( | ||
private _leoBody: LeoBodyProvider, | ||
private _leoDetached: LeoBodyDetachedProvider | ||
) { } | ||
|
||
public provideDocumentSymbols( | ||
document: vscode.TextDocument, token: vscode.CancellationToken): | ||
Thenable<vscode.SymbolInformation[]> { | ||
|
||
const w_gnx = utils.leoUriToStr(document.uri); | ||
let v: VNode | undefined; | ||
let fileProvider; | ||
if ( | ||
document.uri.scheme === Constants.URI_LEOJS_SCHEME | ||
) { | ||
fileProvider = this._leoBody; | ||
} else { | ||
fileProvider = this._leoDetached; | ||
} | ||
v = fileProvider.openedBodiesVNodes[w_gnx]; | ||
if (v) { | ||
|
||
const c = v.context; | ||
|
||
// const filename = c.shortFileName() || 'untitled'; | ||
const headline = v.headString(); | ||
|
||
// Get the last line number & last character index of the last line | ||
const lastLineIndex = document.lineCount - 1; | ||
const lastCharIndex = document.lineAt(lastLineIndex).text.length; | ||
const loc = new vscode.Location(document.uri, new vscode.Range(0, 0, lastLineIndex, lastCharIndex)); | ||
|
||
const breadcrumbInfo = new vscode.SymbolInformation( | ||
|
||
// * BOTH | ||
// filename + " > " + headline, vscode.SymbolKind.String, "", loc | ||
|
||
// * HEADLINE ONLY | ||
headline, vscode.SymbolKind.String, "", loc | ||
|
||
); | ||
return Promise.resolve([breadcrumbInfo]); | ||
} | ||
return Promise.resolve([]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters