From 123310bb406f0c9bb9ef3af7a70a7d105f399162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Sun, 2 Oct 2022 22:03:21 -0400 Subject: [PATCH 1/5] Fixed minibuffer history order and goto-pane keyboard nav --- CHANGELOG.md | 5 +++ leoInteg.leo | 61 ++++++++++++++++----------- package.json | 2 +- src/extension.ts | 2 - src/leoIntegration.ts | 46 +++++++++++--------- src/webviews/settingsPanel/index.html | 4 +- 6 files changed, 72 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c3965..f3be5a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.0.9 + +- Fixed minibuffer history order +- Fixed keyboard navigation in the goto pane: focus no more flashes. + ## 1.0.8 - Added an 'undo panel' that shows actions history and supports right-clicking to go to any undo point. diff --git a/leoInteg.leo b/leoInteg.leo index bd83ca6..a4699a6 100644 --- a/leoInteg.leo +++ b/leoInteg.leo @@ -29,6 +29,7 @@ Acknowledgments @clean CHANGELOG.md +1.0.9 1.0.8 1.0.7 1.0.6 @@ -1053,7 +1054,10 @@ private _onDidOpenTextDocument(p_document: vscode.TextDocument): void { if ( this.leoStates.leoBridgeReady && p_document.uri.scheme === Constants.URI_FILE_SCHEME && - p_document.uri.fsPath.toLowerCase().endsWith('.leo') + ( + p_document.uri.fsPath.toLowerCase().endsWith('.leo') || + p_document.uri.fsPath.toLowerCase().endsWith('.leojs') + ) ) { if (!this._hasShownContextOpenMessage) { vscode.window.showInformationMessage(Constants.USER_MESSAGES.RIGHT_CLICK_TO_OPEN); @@ -1100,7 +1104,6 @@ public configTreeRefresh(): void { private _refreshOutline(p_incrementTreeID: boolean, p_revealType?: RevealType): void { if (p_incrementTreeID) { - // this._treeId++; this._leoTreeProvider.incTreeId(); } if (p_revealType !== undefined && p_revealType.valueOf() >= this._revealType.valueOf()) { @@ -1335,11 +1338,17 @@ private async _tryApplyNodeToBody( * (see command stack 'rules' in commandStack.ts) */ public nodeCommand(p_userCommand: UserCommand, p_isNavigation?: boolean): Promise<LeoBridgePackage> | undefined { + // No forced vscode save-triggers for direct calls from extension.js this.triggerBodySave(); if (p_isNavigation) { + // If any navigation command is used from outline or command palette: show body. this.showBodyIfClosed = true; + + // If alt+arrow is used to navigate: SHOW and leave focus on outline. + this.showOutlineIfClosed = true; } + const q_result = this._commandStack.add(p_userCommand); if (q_result) { return q_result; @@ -2197,7 +2206,7 @@ print('done') "name": "leointeg", "displayName": "Leo Editor Integration with Visual Studio Code", "description": "Use Leo, the literate editor with outline, directly in vscode.", - "version": "1.0.8", + "version": "1.0.9", "author": { "name": "Félix" }, @@ -6131,8 +6140,6 @@ var LeoInteg: LeoIntegration | undefined = undefined; */ export function activate(p_context: vscode.ExtensionContext) { - const w_start = process.hrtime(); // For calculating total startup time duration - // * Reset Extension context flags (used in 'when' clauses in package.json) utils.setContext(Constants.CONTEXT_FLAGS.BRIDGE_READY, false); // Connected to a leobridge server? utils.setContext(Constants.CONTEXT_FLAGS.TREE_OPENED, false); // Having a Leo file opened on that server? @@ -10290,16 +10297,17 @@ public async showBody(p_aside: boolean, p_preventTakingFocus?: boolean): Promise this._refreshType.scroll = false; // Set scroll approximation w_bodyTextEditor.revealRange(w_scrollRange, vscode.TextEditorRevealType.InCenterIfOutsideViewport); + console.log('-------------------------------------------------------------skipped setting back focus to goto'); // ! Compensate for reveal that steals the focus. - if (this.finalFocus.valueOf() === Focus.Goto) { - let w_viewName: string; - if (this._lastTreeView === this._leoTreeExView) { - w_viewName = Constants.GOTO_EXPLORER_ID; - } else { - w_viewName = Constants.GOTO_ID; - } - vscode.commands.executeCommand(w_viewName + ".focus"); - } + // if (this.finalFocus.valueOf() === Focus.Goto) { + // let w_viewName: string; + // if (this._lastTreeView === this._leoTreeExView) { + // w_viewName = Constants.GOTO_EXPLORER_ID; + // } else { + // w_viewName = Constants.GOTO_ID; + // } + // vscode.commands.executeCommand(w_viewName + ".focus"); + // } } } else { @@ -10903,11 +10911,11 @@ public async newLeoFile(): Promise<LeoBridgePackage> { public openLeoFile(p_leoFileUri?: vscode.Uri): Promise<LeoBridgePackage | undefined> { return this._isBusyTriggerSave(true, true) .then((p_saveResult) => { - if (p_leoFileUri && p_leoFileUri.scheme.startsWith("leo")) { + if (p_leoFileUri && p_leoFileUri.scheme && p_leoFileUri.scheme.startsWith("leo")) { p_leoFileUri = undefined; // Was used in the editor/title menu! } let q_openedFile: Promise<LeoBridgePackage | undefined>; // Promise for opening a file - if (p_leoFileUri && p_leoFileUri.fsPath.trim()) { + if (p_leoFileUri && p_leoFileUri.fsPath && p_leoFileUri.fsPath.trim()) { const w_fixedFilePath: string = p_leoFileUri.fsPath.replace(/\\/g, '/'); q_openedFile = this.sendAction( Constants.LEOBRIDGE.OPEN_FILE, @@ -11431,7 +11439,7 @@ public async minibuffer(): Promise<LeoBridgePackage | undefined> { // Wait for _isBusyTriggerSave resolve because the full body save may change available commands await this._isBusyTriggerSave(false); - const w_commandList: Thenable<vscode.QuickPickItem[]> = this.sendAction( + const q_commandList: Thenable<vscode.QuickPickItem[]> = this.sendAction( Constants.LEOBRIDGE.GET_COMMANDS ).then((p_result: LeoBridgePackage) => { if (p_result.commands && p_result.commands.length) { @@ -11505,12 +11513,12 @@ public async minibuffer(): Promise<LeoBridgePackage | undefined> { return []; } }); - // Add Nav tab special commands + const w_options: vscode.QuickPickOptions = { placeHolder: Constants.USER_MESSAGES.MINIBUFFER_PROMPT, matchOnDetail: true, }; - const w_picked = await vscode.window.showQuickPick(w_commandList, w_options); + const w_picked = await vscode.window.showQuickPick(q_commandList, w_options); // First, check for undo-history list being requested if (w_picked && w_picked.label === Constants.USER_MESSAGES.MINIBUFFER_HISTORY_LABEL) { return this.minibufferHistory(); @@ -15409,7 +15417,6 @@ public async gotoNavEntry(p_node: LeoGotoNode): Promise<unknown> { // documents: false, // buttons: false, states: true, - // goto: w_revealTarget === Focus.Body // ! HAVE TO FORCE BACK }, p_navEntryResult.node ); @@ -16526,7 +16533,7 @@ public gotSelectedNode(p_element: ArchivedPosition): void { ) { // ! MINIMAL TIMEOUT REQUIRED ! WHY ?? (works so leave) setTimeout(() => { - this.showBody(false, false); // SAME with scroll information specified + this.showBody(false, this.finalFocus.valueOf() !== Focus.Body); // SAME with scroll information specified }, 25); } else { @@ -17503,7 +17510,7 @@ private async _doMinibufferCommand(p_picked: vscode.QuickPickItem | undefined): if (p_picked && p_picked.label && Constants.MINIBUFFER_OVERRIDDEN_COMMANDS[p_picked.label]) { - this._minibufferHistory.push(p_picked.label); // Add to minibuffer history + this._minibufferHistory.unshift(p_picked.label); // Add to minibuffer history return vscode.commands.executeCommand( Constants.MINIBUFFER_OVERRIDDEN_COMMANDS[p_picked.label] ); @@ -17939,6 +17946,12 @@ public async navTextClear(): Promise<LeoBridgePackage> { return w_package; } + +## 1.0.9 + +- Fixed minibuffer history order +- Fixed keyboard navigation in the goto pane: focus no more flashes. + import * as vscode from "vscode"; import * as path from 'path'; @@ -18600,7 +18613,7 @@ body > div > div > label:active { <section id="welcome" class="section--full mb-0"> <h2 class="section__title section__title--primary"> - Welcome to <span class="highlight">LeoInteg 1.0.8</span> + Welcome to <span class="highlight">LeoInteg 1.0.9</span> </h2> <div class="center mt-1"> <a class="button button--flat is-sidebar-hidden " @@ -18611,7 +18624,7 @@ body > div > div > label:active { <a class="button button--flat" title="LeoInteg's Features" href="https://github.com/boltex/leointeg#features"> - See What's New in LeoInteg 1.0.8 + See What's New in LeoInteg 1.0.9 </a> </div> <p class="blurb center ml-0 mr-0"> diff --git a/package.json b/package.json index 603a81b..c6f261f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "leointeg", "displayName": "Leo Editor Integration with Visual Studio Code", "description": "Use Leo, the literate editor with outline, directly in vscode.", - "version": "1.0.8", + "version": "1.0.9", "author": { "name": "Félix" }, diff --git a/src/extension.ts b/src/extension.ts index f5d8e40..83ee6f3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -18,8 +18,6 @@ var LeoInteg: LeoIntegration | undefined = undefined; */ export function activate(p_context: vscode.ExtensionContext) { - const w_start = process.hrtime(); // For calculating total startup time duration - // * Reset Extension context flags (used in 'when' clauses in package.json) utils.setContext(Constants.CONTEXT_FLAGS.BRIDGE_READY, false); // Connected to a leobridge server? utils.setContext(Constants.CONTEXT_FLAGS.TREE_OPENED, false); // Having a Leo file opened on that server? diff --git a/src/leoIntegration.ts b/src/leoIntegration.ts index 7128d46..636b7e8 100644 --- a/src/leoIntegration.ts +++ b/src/leoIntegration.ts @@ -1220,7 +1220,10 @@ export class LeoIntegration { if ( this.leoStates.leoBridgeReady && p_document.uri.scheme === Constants.URI_FILE_SCHEME && - p_document.uri.fsPath.toLowerCase().endsWith('.leo') + ( + p_document.uri.fsPath.toLowerCase().endsWith('.leo') || + p_document.uri.fsPath.toLowerCase().endsWith('.leojs') + ) ) { if (!this._hasShownContextOpenMessage) { vscode.window.showInformationMessage(Constants.USER_MESSAGES.RIGHT_CLICK_TO_OPEN); @@ -2027,7 +2030,6 @@ export class LeoIntegration { private _refreshOutline(p_incrementTreeID: boolean, p_revealType?: RevealType): void { if (p_incrementTreeID) { - // this._treeId++; this._leoTreeProvider.incTreeId(); } if (p_revealType !== undefined && p_revealType.valueOf() >= this._revealType.valueOf()) { @@ -2138,7 +2140,7 @@ export class LeoIntegration { ) { // ! MINIMAL TIMEOUT REQUIRED ! WHY ?? (works so leave) setTimeout(() => { - this.showBody(false, false); // SAME with scroll information specified + this.showBody(false, this.finalFocus.valueOf() !== Focus.Body); // SAME with scroll information specified }, 25); } else { @@ -2872,16 +2874,17 @@ export class LeoIntegration { this._refreshType.scroll = false; // Set scroll approximation w_bodyTextEditor.revealRange(w_scrollRange, vscode.TextEditorRevealType.InCenterIfOutsideViewport); + console.log('-------------------------------------------------------------skipped setting back focus to goto'); // ! Compensate for reveal that steals the focus. - if (this.finalFocus.valueOf() === Focus.Goto) { - let w_viewName: string; - if (this._lastTreeView === this._leoTreeExView) { - w_viewName = Constants.GOTO_EXPLORER_ID; - } else { - w_viewName = Constants.GOTO_ID; - } - vscode.commands.executeCommand(w_viewName + ".focus"); - } + // if (this.finalFocus.valueOf() === Focus.Goto) { + // let w_viewName: string; + // if (this._lastTreeView === this._leoTreeExView) { + // w_viewName = Constants.GOTO_EXPLORER_ID; + // } else { + // w_viewName = Constants.GOTO_ID; + // } + // vscode.commands.executeCommand(w_viewName + ".focus"); + // } } } else { @@ -2992,7 +2995,7 @@ export class LeoIntegration { // Wait for _isBusyTriggerSave resolve because the full body save may change available commands await this._isBusyTriggerSave(false); - const w_commandList: Thenable = this.sendAction( + const q_commandList: Thenable = this.sendAction( Constants.LEOBRIDGE.GET_COMMANDS ).then((p_result: LeoBridgePackage) => { if (p_result.commands && p_result.commands.length) { @@ -3066,12 +3069,12 @@ export class LeoIntegration { return []; } }); - // Add Nav tab special commands + const w_options: vscode.QuickPickOptions = { placeHolder: Constants.USER_MESSAGES.MINIBUFFER_PROMPT, matchOnDetail: true, }; - const w_picked = await vscode.window.showQuickPick(w_commandList, w_options); + const w_picked = await vscode.window.showQuickPick(q_commandList, w_options); // First, check for undo-history list being requested if (w_picked && w_picked.label === Constants.USER_MESSAGES.MINIBUFFER_HISTORY_LABEL) { return this.minibufferHistory(); @@ -3110,7 +3113,7 @@ export class LeoIntegration { if (p_picked && p_picked.label && Constants.MINIBUFFER_OVERRIDDEN_COMMANDS[p_picked.label]) { - this._minibufferHistory.push(p_picked.label); // Add to minibuffer history + this._minibufferHistory.unshift(p_picked.label); // Add to minibuffer history return vscode.commands.executeCommand( Constants.MINIBUFFER_OVERRIDDEN_COMMANDS[p_picked.label] ); @@ -3221,11 +3224,17 @@ export class LeoIntegration { * (see command stack 'rules' in commandStack.ts) */ public nodeCommand(p_userCommand: UserCommand, p_isNavigation?: boolean): Promise | undefined { + // No forced vscode save-triggers for direct calls from extension.js this.triggerBodySave(); if (p_isNavigation) { + // If any navigation command is used from outline or command palette: show body. this.showBodyIfClosed = true; + + // If alt+arrow is used to navigate: SHOW and leave focus on outline. + this.showOutlineIfClosed = true; } + const q_result = this._commandStack.add(p_userCommand); if (q_result) { return q_result; @@ -3881,7 +3890,6 @@ export class LeoIntegration { // documents: false, // buttons: false, states: true, - // goto: w_revealTarget === Focus.Body // ! HAVE TO FORCE BACK }, p_navEntryResult.node ); @@ -5070,11 +5078,11 @@ export class LeoIntegration { public openLeoFile(p_leoFileUri?: vscode.Uri): Promise { return this._isBusyTriggerSave(true, true) .then((p_saveResult) => { - if (p_leoFileUri && p_leoFileUri.scheme.startsWith("leo")) { + if (p_leoFileUri && p_leoFileUri.scheme && p_leoFileUri.scheme.startsWith("leo")) { p_leoFileUri = undefined; // Was used in the editor/title menu! } let q_openedFile: Promise; // Promise for opening a file - if (p_leoFileUri && p_leoFileUri.fsPath.trim()) { + if (p_leoFileUri && p_leoFileUri.fsPath && p_leoFileUri.fsPath.trim()) { const w_fixedFilePath: string = p_leoFileUri.fsPath.replace(/\\/g, '/'); q_openedFile = this.sendAction( Constants.LEOBRIDGE.OPEN_FILE, diff --git a/src/webviews/settingsPanel/index.html b/src/webviews/settingsPanel/index.html index 22918b1..e597409 100644 --- a/src/webviews/settingsPanel/index.html +++ b/src/webviews/settingsPanel/index.html @@ -37,7 +37,7 @@

LeoInteg

- Welcome to LeoInteg 1.0.8 + Welcome to LeoInteg 1.0.9

From 815c79c01a1f03456f5617089021fbe1e2e1ab2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Thu, 6 Oct 2022 22:30:55 -0400 Subject: [PATCH 2/5] Fixed expanded state altering insert position and fixed outline reveal for navigation commands (alt+arrows, etc.) --- CHANGELOG.md | 4 ++- leoInteg.leo | 59 +++++++++++++++++++++++++++++++++++++------ src/leoIntegration.ts | 34 ++++++++++++++++++++----- 3 files changed, 81 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3be5a7..f67e532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ ## 1.0.9 -- Fixed minibuffer history order +- Fixed minibuffer history order. - Fixed keyboard navigation in the goto pane: focus no more flashes. +- Fixed navigation commands, including alt+arrow keys, to show outline if hidden. +- Fixed expand-collapse node selection prior to an 'insert' command. ## 1.0.8 diff --git a/leoInteg.leo b/leoInteg.leo index a4699a6..7dd2ce7 100644 --- a/leoInteg.leo +++ b/leoInteg.leo @@ -1120,8 +1120,6 @@ private _refreshOutline(p_incrementTreeID: boolean, p_revealType?: RevealType): } else { w_viewName = Constants.TREEVIEW_ID; } - // console.log('_refreshOutline HAS TO FORCE TREEVIEW SHOW - UP !'); - vscode.commands.executeCommand(w_viewName + ".focus").then( () => { this._revealNodeRetriedRefreshOutline = false; @@ -1157,6 +1155,8 @@ private _revealNode( p_leoNode: ArchivedPosition, p_options?: { select?: boolean; focus?: boolean; expand?: boolean | number } ): Thenable<void> { + console.log('_revealNode!'); + let w_treeview: vscode.TreeView<ArchivedPosition> | undefined; if (this._leoTreeView.visible) { w_treeview = this._leoTreeView; @@ -1164,6 +1164,20 @@ private _revealNode( if (this._leoTreeExView.visible && this.config.treeInExplorer) { w_treeview = this._leoTreeExView; } + if (!w_treeview && (this.showOutlineIfClosed || (p_options && p_options.focus))) { + this.showOutlineIfClosed = false; + w_treeview = this._lastTreeView; + if (p_options) { + p_options.focus = true; + } else { + p_options = { + focus: true, + select: true + }; + } + console.log('revealing hidden!'); + + } try { if (w_treeview) { return w_treeview.reveal(p_leoNode, p_options).then( @@ -1200,6 +1214,7 @@ private _revealNode( * * Launches refresh for UI components: treeviews, body, and context states */ private async _launchRefresh(): Promise<unknown> { + console.log("in launchRefresh"); // check states for having at least a document opened if (!this.serverHasOpenedFile && this.leoStates.leoBridgeReady && this.leoStates.fileOpenedReady) { @@ -1255,12 +1270,15 @@ private async _launchRefresh(): Promise<unknown> { this._refreshType.body = false; this._tryApplyNodeToBody(this._refreshNode || this.serverOpenedNode || this.lastSelectedNode!, false, w_showBodyNoFocus); } + console.log('launching refreshOutline!, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); this._refreshOutline(true, w_revealType); } else if (this._refreshType.node && this._refreshNode) { // * Force single node "refresh" by revealing it, instead of "refreshing" it this._refreshType.node = false; this.leoStates.setSelectedNodeFlags(this._refreshNode); let w_showOutline = this.isOutlineVisible(); + console.log('in else!'); + if (!this.isOutlineVisible() && this.showOutlineIfClosed) { this.showOutlineIfClosed = false; w_showOutline = true; @@ -1276,11 +1294,15 @@ private async _launchRefresh(): Promise<unknown> { // * if no outline visible, just update body pane as needed if (!this.isOutlineVisible()) { this._refreshType.body = false; + console.log('2nd _tryApplyNodeToBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); + this._tryApplyNodeToBody(this._refreshNode, false, w_showBodyNoFocus); } } } else if (this._refreshType.body) { this._refreshType.body = false; + console.log('3nd _tryApplyNodeToBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); + this._tryApplyNodeToBody(this._refreshNode || this.serverOpenedNode || this.lastSelectedNode!, false, w_showBodyNoFocus); } return this.getStates(); @@ -1301,6 +1323,8 @@ private async _tryApplyNodeToBody( p_preventTakingFocus: boolean, ): Promise<void | vscode.TextEditor> { + console.log('IN _tryApplyNodeToBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); + this.lastSelectedNode = p_node; // Set the 'lastSelectedNode' this will also set the 'marked' node context this._commandStack.newSelection(); // Signal that a new selected node was reached and to stop using the received selection as target for next command @@ -1326,7 +1350,6 @@ private async _tryApplyNodeToBody( if (this._isBodyVisible() === 0 && !this.showBodyIfClosed) { return Promise.resolve(); } - this.showBodyIfClosed = false; return this.showBody(p_aside, p_preventTakingFocus); } @@ -1347,6 +1370,7 @@ public nodeCommand(p_userCommand: UserCommand, p_isNavigation?: boolean): Promis // If alt+arrow is used to navigate: SHOW and leave focus on outline. this.showOutlineIfClosed = true; + // * If is navigation, and the outline is not visible : REFRESH TREE TOO } const q_result = this._commandStack.add(p_userCommand); @@ -9243,6 +9267,13 @@ private _onChangeCollapsedState( ): void { // * Expanding or collapsing via the treeview interface selects the node to mimic Leo this.triggerBodySave(true); + // * Set expanded flag even on leointeg's vscode side of things, mostly for 'insert node'. + if (p_expand) { + p_event.element.expanded = true; + } else { + p_event.element.expanded = false; + } + // * distinguish between: changing expand state on already-selected node -vs- selecting at the same time as clicking caret. if (p_treeView.selection[0] && utils.buildApId(p_treeView.selection[0]) === utils.buildApId(p_event.element)) { // * This happens if the tree selection is already the same as the expanded/collapsed node // Pass @@ -9272,6 +9303,8 @@ private _onTreeViewVisibilityChanged( p_event: vscode.TreeViewVisibilityChangeEvent, p_explorerView: boolean ): void { + console.log('_onTreeViewVisibilityChanged visible: ', p_event.visible); + if (p_event.visible) { this._lastTreeView = p_explorerView ? this._leoTreeExView : this._leoTreeView; this.setTreeViewTitle(); @@ -9835,7 +9868,6 @@ private _switchBody( if (w_visibleCount === 0 && !this.showBodyIfClosed) { return Promise.resolve(); } - this.showBodyIfClosed = false; if (w_visibleCount === 1) { this._bodyPreviewMode = this._isBodyPreview(); // recheck in case user double clicked on title @@ -10055,6 +10087,8 @@ public sendAction( */ public async showBody(p_aside: boolean, p_preventTakingFocus?: boolean): Promise<vscode.TextEditor | void> { + console.log('showBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); + const w_openedDocumentTS = performance.now(); const w_openedDocumentGnx = utils.leoUriToStr(this.bodyUri); let q_saved: Thenable<unknown> | undefined; @@ -10221,12 +10255,16 @@ public async showBody(p_aside: boolean, p_preventTakingFocus?: boolean): Promise return; } + console.log('SHOW TEXT EDITOR!, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); // * Actually Show the body pane document in a text editor const q_showTextDocument = vscode.window.showTextDocument( this._bodyTextDocument, w_showOptions ).then( - (p_result) => { return p_result; }, + (p_result) => { + this.showBodyIfClosed = false; + return p_result; + }, (p_reason) => { console.log('showTextDocument rejected: ', p_reason); } @@ -11114,6 +11152,7 @@ public connect(): void { this.serverOpenedNode = p_package.node!; // will provoke _setupOpenedLeoDocument this.loadSearchSettings(); + // Server already had opened files. this.setupRefresh( this.finalFocus, { @@ -11124,6 +11163,7 @@ public connect(): void { states: true, } ); + this.launchRefresh(); } if (!this.config.connectToServerAutomatically) { @@ -16561,6 +16601,8 @@ public gotSelectedNode(p_element: ArchivedPosition): void { } if (!w_last || this._needLastSelectedRefresh) { // lastSelectedNode will be set in _tryApplyNodeToBody ! + console.log('in got selected node, setting _needLastSelectedRefresh FALSE'); + this._needLastSelectedRefresh = false; } @@ -16572,7 +16614,7 @@ public gotSelectedNode(p_element: ArchivedPosition): void { // * Just make sure body selection is considered done. this.lastSelectedNode = p_element; // Set the 'lastSelectedNode' this will also set the 'marked' node context this._commandStack.newSelection(); // Signal that a new selected node was reached and to stop using the received selection as target for next command - + this._preventShowBody = false; // in case it was a config-changed-refresh } else { // * Actually run the normal 'APPLY NODE TO BODY' to show or switch this._tryApplyNodeToBody(p_element, false, w_showBodyNoFocus); @@ -17947,10 +17989,11 @@ public async navTextClear(): Promise<LeoBridgePackage> { } -## 1.0.9 +_needLastSelectedRefresh## 1.0.9 -- Fixed minibuffer history order +- Fixed minibuffer history order. - Fixed keyboard navigation in the goto pane: focus no more flashes. +- Fixed expand-collapse node selection prior to an 'insert' command. import * as vscode from "vscode"; diff --git a/src/leoIntegration.ts b/src/leoIntegration.ts index 636b7e8..44b03f1 100644 --- a/src/leoIntegration.ts +++ b/src/leoIntegration.ts @@ -695,6 +695,7 @@ export class LeoIntegration { this.serverOpenedNode = p_package.node!; // will provoke _setupOpenedLeoDocument this.loadSearchSettings(); + // Server already had opened files. this.setupRefresh( this.finalFocus, { @@ -705,6 +706,7 @@ export class LeoIntegration { states: true, } ); + this.launchRefresh(); } if (!this.config.connectToServerAutomatically) { @@ -1245,6 +1247,13 @@ export class LeoIntegration { ): void { // * Expanding or collapsing via the treeview interface selects the node to mimic Leo this.triggerBodySave(true); + // * Set expanded flag even on leointeg's vscode side of things, mostly for 'insert node'. + if (p_expand) { + p_event.element.expanded = true; + } else { + p_event.element.expanded = false; + } + // * distinguish between: changing expand state on already-selected node -vs- selecting at the same time as clicking caret. if (p_treeView.selection[0] && utils.buildApId(p_treeView.selection[0]) === utils.buildApId(p_event.element)) { // * This happens if the tree selection is already the same as the expanded/collapsed node // Pass @@ -2046,8 +2055,6 @@ export class LeoIntegration { } else { w_viewName = Constants.TREEVIEW_ID; } - // console.log('_refreshOutline HAS TO FORCE TREEVIEW SHOW - UP !'); - vscode.commands.executeCommand(w_viewName + ".focus").then( () => { this._revealNodeRetriedRefreshOutline = false; @@ -2089,6 +2096,18 @@ export class LeoIntegration { if (this._leoTreeExView.visible && this.config.treeInExplorer) { w_treeview = this._leoTreeExView; } + if (!w_treeview && (this.showOutlineIfClosed || (p_options && p_options.focus))) { + this.showOutlineIfClosed = false; + w_treeview = this._lastTreeView; + if (p_options) { + p_options.focus = true; + } else { + p_options = { + focus: true, + select: true + }; + } + } try { if (w_treeview) { return w_treeview.reveal(p_leoNode, p_options).then( @@ -2179,7 +2198,7 @@ export class LeoIntegration { // * Just make sure body selection is considered done. this.lastSelectedNode = p_element; // Set the 'lastSelectedNode' this will also set the 'marked' node context this._commandStack.newSelection(); // Signal that a new selected node was reached and to stop using the received selection as target for next command - + this._preventShowBody = false; // in case it was a config-changed-refresh } else { // * Actually run the normal 'APPLY NODE TO BODY' to show or switch this._tryApplyNodeToBody(p_element, false, w_showBodyNoFocus); @@ -2262,7 +2281,6 @@ export class LeoIntegration { if (this._isBodyVisible() === 0 && !this.showBodyIfClosed) { return Promise.resolve(); } - this.showBodyIfClosed = false; return this.showBody(p_aside, p_preventTakingFocus); } @@ -2286,7 +2304,6 @@ export class LeoIntegration { if (w_visibleCount === 0 && !this.showBodyIfClosed) { return Promise.resolve(); } - this.showBodyIfClosed = false; if (w_visibleCount === 1) { this._bodyPreviewMode = this._isBodyPreview(); // recheck in case user double clicked on title @@ -2798,12 +2815,16 @@ export class LeoIntegration { return; } + console.log('SHOW TEXT EDITOR!, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); // * Actually Show the body pane document in a text editor const q_showTextDocument = vscode.window.showTextDocument( this._bodyTextDocument, w_showOptions ).then( - (p_result) => { return p_result; }, + (p_result) => { + this.showBodyIfClosed = false; + return p_result; + }, (p_reason) => { console.log('showTextDocument rejected: ', p_reason); } @@ -3230,7 +3251,6 @@ export class LeoIntegration { if (p_isNavigation) { // If any navigation command is used from outline or command palette: show body. this.showBodyIfClosed = true; - // If alt+arrow is used to navigate: SHOW and leave focus on outline. this.showOutlineIfClosed = true; } From 882e184c6d29851094743007f12e2a6db0294363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Thu, 6 Oct 2022 23:30:42 -0400 Subject: [PATCH 3/5] Now uses 'leoChanged' state flag instead of old _currentDocumentChanged. --- CHANGELOG.md | 1 + leoInteg.leo | 37 ++++++++++--------------------------- src/leoIntegration.ts | 7 +++---- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f67e532..7e6530e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fixed minibuffer history order. - Fixed keyboard navigation in the goto pane: focus no more flashes. - Fixed navigation commands, including alt+arrow keys, to show outline if hidden. +- Fixed body edit undo bead creation frequency (when documents pane is not visible.) - Fixed expand-collapse node selection prior to an 'insert' command. ## 1.0.8 diff --git a/leoInteg.leo b/leoInteg.leo index 7dd2ce7..936036c 100644 --- a/leoInteg.leo +++ b/leoInteg.leo @@ -1155,8 +1155,6 @@ private _revealNode( p_leoNode: ArchivedPosition, p_options?: { select?: boolean; focus?: boolean; expand?: boolean | number } ): Thenable<void> { - console.log('_revealNode!'); - let w_treeview: vscode.TreeView<ArchivedPosition> | undefined; if (this._leoTreeView.visible) { w_treeview = this._leoTreeView; @@ -1175,8 +1173,6 @@ private _revealNode( select: true }; } - console.log('revealing hidden!'); - } try { if (w_treeview) { @@ -1214,7 +1210,6 @@ private _revealNode( * * Launches refresh for UI components: treeviews, body, and context states */ private async _launchRefresh(): Promise<unknown> { - console.log("in launchRefresh"); // check states for having at least a document opened if (!this.serverHasOpenedFile && this.leoStates.leoBridgeReady && this.leoStates.fileOpenedReady) { @@ -1270,15 +1265,12 @@ private async _launchRefresh(): Promise<unknown> { this._refreshType.body = false; this._tryApplyNodeToBody(this._refreshNode || this.serverOpenedNode || this.lastSelectedNode!, false, w_showBodyNoFocus); } - console.log('launching refreshOutline!, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); this._refreshOutline(true, w_revealType); } else if (this._refreshType.node && this._refreshNode) { // * Force single node "refresh" by revealing it, instead of "refreshing" it this._refreshType.node = false; this.leoStates.setSelectedNodeFlags(this._refreshNode); let w_showOutline = this.isOutlineVisible(); - console.log('in else!'); - if (!this.isOutlineVisible() && this.showOutlineIfClosed) { this.showOutlineIfClosed = false; w_showOutline = true; @@ -1294,15 +1286,11 @@ private async _launchRefresh(): Promise<unknown> { // * if no outline visible, just update body pane as needed if (!this.isOutlineVisible()) { this._refreshType.body = false; - console.log('2nd _tryApplyNodeToBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); - this._tryApplyNodeToBody(this._refreshNode, false, w_showBodyNoFocus); } } } else if (this._refreshType.body) { this._refreshType.body = false; - console.log('3nd _tryApplyNodeToBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); - this._tryApplyNodeToBody(this._refreshNode || this.serverOpenedNode || this.lastSelectedNode!, false, w_showBodyNoFocus); } return this.getStates(); @@ -1323,8 +1311,6 @@ private async _tryApplyNodeToBody( p_preventTakingFocus: boolean, ): Promise<void | vscode.TextEditor> { - console.log('IN _tryApplyNodeToBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); - this.lastSelectedNode = p_node; // Set the 'lastSelectedNode' this will also set the 'marked' node context this._commandStack.newSelection(); // Signal that a new selected node was reached and to stop using the received selection as target for next command @@ -1367,10 +1353,8 @@ public nodeCommand(p_userCommand: UserCommand, p_isNavigation?: boolean): Promis if (p_isNavigation) { // If any navigation command is used from outline or command palette: show body. this.showBodyIfClosed = true; - // If alt+arrow is used to navigate: SHOW and leave focus on outline. this.showOutlineIfClosed = true; - // * If is navigation, and the outline is not visible : REFRESH TREE TOO } const q_result = this._commandStack.add(p_userCommand); @@ -9033,7 +9017,6 @@ export class LeoIntegration { private _leoDocumentsProvider: LeoDocumentsProvider; private _leoDocuments: vscode.TreeView<LeoDocumentNode>; private _leoDocumentsExplorer: vscode.TreeView<LeoDocumentNode>; - private _currentDocumentChanged: boolean = false; // if clean and an edit is done: refresh opened documents view // * Goto nav panel private _leoGotoProvider: LeoGotoProvider; @@ -9303,8 +9286,6 @@ private _onTreeViewVisibilityChanged( p_event: vscode.TreeViewVisibilityChangeEvent, p_explorerView: boolean ): void { - console.log('_onTreeViewVisibilityChanged visible: ', p_event.visible); - if (p_event.visible) { this._lastTreeView = p_explorerView ? this._leoTreeExView : this._leoTreeView; this.setTreeViewTitle(); @@ -9681,7 +9662,11 @@ private _onDocumentChanged(p_textDocumentChange: vscode.TextDocumentChangeEvent) const w_hasBody = !!p_textDocumentChange.document.getText().length; const w_iconChanged = utils.isIconChangedByEdit(this.lastSelectedNode, w_hasBody); - if (!this._currentDocumentChanged || w_iconChanged) { + console.log('this.leoStates.leoChanged', this.leoStates.leoChanged); + console.log('w_iconChanged', w_iconChanged); + + + if (!this.leoStates.leoChanged || w_iconChanged) { if (this.preventIconChange) { this.preventIconChange = false; } else { @@ -9699,7 +9684,7 @@ private _onDocumentChanged(p_textDocumentChange: vscode.TextDocumentChangeEvent) }); } - if (!this._currentDocumentChanged) { + if (!this.leoStates.leoChanged) { // also refresh document panel (icon may be dirty now) this.refreshDocumentsPane(); } @@ -10087,8 +10072,6 @@ public sendAction( */ public async showBody(p_aside: boolean, p_preventTakingFocus?: boolean): Promise<vscode.TextEditor | void> { - console.log('showBody, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); - const w_openedDocumentTS = performance.now(); const w_openedDocumentGnx = utils.leoUriToStr(this.bodyUri); let q_saved: Thenable<unknown> | undefined; @@ -16601,8 +16584,6 @@ public gotSelectedNode(p_element: ArchivedPosition): void { } if (!w_last || this._needLastSelectedRefresh) { // lastSelectedNode will be set in _tryApplyNodeToBody ! - console.log('in got selected node, setting _needLastSelectedRefresh FALSE'); - this._needLastSelectedRefresh = false; } @@ -16632,7 +16613,7 @@ public gotSelectedNode(p_element: ArchivedPosition): void { * @param p_documentNode Document node instance in the Leo document view to be the 'selected' one. */ public setDocumentSelection(p_documentNode: LeoDocumentNode): void { - this._currentDocumentChanged = p_documentNode.documentEntry.changed; + this.leoStates.leoChanged = p_documentNode.documentEntry.changed; // also set here since slightly newer. this.leoStates.leoOpenedFileName = p_documentNode.documentEntry.name; setTimeout(() => { if (!this._leoDocuments.visible && !this._leoDocumentsExplorer.visible) { @@ -17989,10 +17970,12 @@ public async navTextClear(): Promise<LeoBridgePackage> { } -_needLastSelectedRefresh## 1.0.9 +## 1.0.9 - Fixed minibuffer history order. - Fixed keyboard navigation in the goto pane: focus no more flashes. +- Fixed navigation commands, including alt+arrow keys, to show outline if hidden. +- Fixed body edit undo bead creation frequency (when documents pane is not visible.) - Fixed expand-collapse node selection prior to an 'insert' command. diff --git a/src/leoIntegration.ts b/src/leoIntegration.ts index 44b03f1..40c8095 100644 --- a/src/leoIntegration.ts +++ b/src/leoIntegration.ts @@ -130,7 +130,6 @@ export class LeoIntegration { private _leoDocumentsProvider: LeoDocumentsProvider; private _leoDocuments: vscode.TreeView; private _leoDocumentsExplorer: vscode.TreeView; - private _currentDocumentChanged: boolean = false; // if clean and an edit is done: refresh opened documents view // * Goto nav panel private _leoGotoProvider: LeoGotoProvider; @@ -1515,7 +1514,7 @@ export class LeoIntegration { const w_hasBody = !!p_textDocumentChange.document.getText().length; const w_iconChanged = utils.isIconChangedByEdit(this.lastSelectedNode, w_hasBody); - if (!this._currentDocumentChanged || w_iconChanged) { + if (!this.leoStates.leoChanged || w_iconChanged) { if (this.preventIconChange) { this.preventIconChange = false; } else { @@ -1533,7 +1532,7 @@ export class LeoIntegration { }); } - if (!this._currentDocumentChanged) { + if (!this.leoStates.leoChanged) { // also refresh document panel (icon may be dirty now) this.refreshDocumentsPane(); } @@ -4646,7 +4645,7 @@ export class LeoIntegration { * @param p_documentNode Document node instance in the Leo document view to be the 'selected' one. */ public setDocumentSelection(p_documentNode: LeoDocumentNode): void { - this._currentDocumentChanged = p_documentNode.documentEntry.changed; + this.leoStates.leoChanged = p_documentNode.documentEntry.changed; // also set here since slightly newer. this.leoStates.leoOpenedFileName = p_documentNode.documentEntry.name; setTimeout(() => { if (!this._leoDocuments.visible && !this._leoDocumentsExplorer.visible) { From a422d76eed7f48a9d0e3f6616b085e30b182cbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Fri, 7 Oct 2022 21:14:42 -0400 Subject: [PATCH 4/5] Cleaned up logs --- leoInteg.leo | 17 ----------------- src/extension.ts | 1 - src/leoIntegration.ts | 12 ------------ 3 files changed, 30 deletions(-) diff --git a/leoInteg.leo b/leoInteg.leo index 936036c..a8755f2 100644 --- a/leoInteg.leo +++ b/leoInteg.leo @@ -6251,7 +6251,6 @@ export function deactivate(): Thenable<unknown> { async function showWelcomeIfNewer(p_version: string, p_previousVersion: string | undefined, p_leoInteg: LeoIntegration): Promise<unknown> { let w_showWelcomeScreen: boolean = false; if (p_previousVersion === undefined) { - console.log('leointeg first-time install'); // Force-Set/Clear leointeg's required configuration settings p_leoInteg.config.setEnablePreview(); p_leoInteg.config.clearCloseEmptyGroups(); @@ -9662,10 +9661,6 @@ private _onDocumentChanged(p_textDocumentChange: vscode.TextDocumentChangeEvent) const w_hasBody = !!p_textDocumentChange.document.getText().length; const w_iconChanged = utils.isIconChangedByEdit(this.lastSelectedNode, w_hasBody); - console.log('this.leoStates.leoChanged', this.leoStates.leoChanged); - console.log('w_iconChanged', w_iconChanged); - - if (!this.leoStates.leoChanged || w_iconChanged) { if (this.preventIconChange) { this.preventIconChange = false; @@ -10238,7 +10233,6 @@ public async showBody(p_aside: boolean, p_preventTakingFocus?: boolean): Promise return; } - console.log('SHOW TEXT EDITOR!, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); // * Actually Show the body pane document in a text editor const q_showTextDocument = vscode.window.showTextDocument( this._bodyTextDocument, @@ -10318,17 +10312,6 @@ public async showBody(p_aside: boolean, p_preventTakingFocus?: boolean): Promise this._refreshType.scroll = false; // Set scroll approximation w_bodyTextEditor.revealRange(w_scrollRange, vscode.TextEditorRevealType.InCenterIfOutsideViewport); - console.log('-------------------------------------------------------------skipped setting back focus to goto'); - // ! Compensate for reveal that steals the focus. - // if (this.finalFocus.valueOf() === Focus.Goto) { - // let w_viewName: string; - // if (this._lastTreeView === this._leoTreeExView) { - // w_viewName = Constants.GOTO_EXPLORER_ID; - // } else { - // w_viewName = Constants.GOTO_ID; - // } - // vscode.commands.executeCommand(w_viewName + ".focus"); - // } } } else { diff --git a/src/extension.ts b/src/extension.ts index 83ee6f3..06941c5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -822,7 +822,6 @@ function closeLeoTextEditors(): Thenable { async function showWelcomeIfNewer(p_version: string, p_previousVersion: string | undefined, p_leoInteg: LeoIntegration): Promise { let w_showWelcomeScreen: boolean = false; if (p_previousVersion === undefined) { - console.log('leointeg first-time install'); // Force-Set/Clear leointeg's required configuration settings p_leoInteg.config.setEnablePreview(); p_leoInteg.config.clearCloseEmptyGroups(); diff --git a/src/leoIntegration.ts b/src/leoIntegration.ts index 40c8095..a6d866b 100644 --- a/src/leoIntegration.ts +++ b/src/leoIntegration.ts @@ -2814,7 +2814,6 @@ export class LeoIntegration { return; } - console.log('SHOW TEXT EDITOR!, this._needLastSelectedRefresh', this._needLastSelectedRefresh, 'this.showBodyIfClosed :', this.showBodyIfClosed); // * Actually Show the body pane document in a text editor const q_showTextDocument = vscode.window.showTextDocument( this._bodyTextDocument, @@ -2894,17 +2893,6 @@ export class LeoIntegration { this._refreshType.scroll = false; // Set scroll approximation w_bodyTextEditor.revealRange(w_scrollRange, vscode.TextEditorRevealType.InCenterIfOutsideViewport); - console.log('-------------------------------------------------------------skipped setting back focus to goto'); - // ! Compensate for reveal that steals the focus. - // if (this.finalFocus.valueOf() === Focus.Goto) { - // let w_viewName: string; - // if (this._lastTreeView === this._leoTreeExView) { - // w_viewName = Constants.GOTO_EXPLORER_ID; - // } else { - // w_viewName = Constants.GOTO_ID; - // } - // vscode.commands.executeCommand(w_viewName + ".focus"); - // } } } else { From 16f60b49f44b7a8ef42d999f782dfbe2e696588b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Fri, 7 Oct 2022 21:44:04 -0400 Subject: [PATCH 5/5] Updated author field with full name --- leoInteg.leo | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/leoInteg.leo b/leoInteg.leo index a8755f2..a0bcce3 100644 --- a/leoInteg.leo +++ b/leoInteg.leo @@ -2216,7 +2216,7 @@ print('done') "description": "Use Leo, the literate editor with outline, directly in vscode.", "version": "1.0.9", "author": { - "name": "Félix" + "name": "Félix Malboeuf" }, "sponsor": { "url": "https://boltex.github.io/" diff --git a/package.json b/package.json index c6f261f..6b828d9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Use Leo, the literate editor with outline, directly in vscode.", "version": "1.0.9", "author": { - "name": "Félix" + "name": "Félix Malboeuf" }, "sponsor": { "url": "https://boltex.github.io/"