WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit ec97825

Browse files
committed
Feat: exposing getter setter for widget manager created using line widgets
1 parent 74e95d1 commit ec97825

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

ace.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ export namespace Ace {
953953
splitLine(): void;
954954
setGhostText(text: string, position: Point): void;
955955
removeGhostText(): void;
956+
setWidgetManager(): void;
957+
getWidgetManager(): Ace.LineWidgets;
956958
transposeLetters(): void;
957959
toLowerCase(): void;
958960
toUpperCase(): void;

src/editor.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,29 @@ class Editor {
15021502
this.renderer.removeGhostText();
15031503
}
15041504

1505+
/**
1506+
* Set "widgetManager" in editor.session
1507+
* @returns void
1508+
*/
1509+
setWidgetManager() {
1510+
if (!this.session.widgetManager) {
1511+
this.session.widgetManager = new LineWidgets(this.session);
1512+
this.session.widgetManager.attach(this);
1513+
}
1514+
}
1515+
1516+
/**
1517+
* Get "widgetManager" from editor.session
1518+
*
1519+
* @returns {LineWidgets} object
1520+
*/
1521+
getWidgetManager() {
1522+
if (!this.session.widgetManager) {
1523+
this.setWidgetManager();
1524+
}
1525+
return this.session.widgetManager;
1526+
}
1527+
15051528
/**
15061529
* Transposes current line.
15071530
**/

src/ext/code_lens.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ function attachToEditor(editor) {
158158
if (!session) return;
159159

160160
if (!session.widgetManager) {
161-
session.widgetManager = new LineWidgets(session);
162-
session.widgetManager.attach(editor);
161+
editor.setWidgetManager();
163162
}
164163

165164
var providersToWaitNum = editor.codeLensProviders.length;

src/ext/error_marker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ function findAnnotations(session, row, dir) {
7171
exports.showErrorMarker = function(editor, dir) {
7272
var session = editor.session;
7373
if (!session.widgetManager) {
74-
session.widgetManager = new LineWidgets(session);
75-
session.widgetManager.attach(editor);
74+
editor.setWidgetManager();
7675
}
7776

7877
var pos = editor.getCursorPosition();

0 commit comments

Comments
 (0)