|
12 | 12 | [com.intellij.ide DataManager] |
13 | 13 | [com.intellij.openapi.actionSystem ActionManager] |
14 | 14 | [com.intellij.openapi.components ServiceManager] |
15 | | - [com.intellij.openapi.wm WindowManager] |
16 | | - [com.intellij.testFramework EditorTestUtil])) |
| 15 | + [com.intellij.openapi.editor LogicalPosition] |
| 16 | + [com.intellij.openapi.wm WindowManager])) |
17 | 17 |
|
18 | 18 | (set! *warn-on-reflection* true) |
19 | 19 |
|
|
22 | 22 | (let [status-bar (.. (WindowManager/getInstance) (getStatusBar project))] |
23 | 23 | (.getWidget status-bar widget-id))) |
24 | 24 |
|
25 | | -(defn ensure-editor |
26 | | - "Ensure the editor was created in the UI thread" |
27 | | - [project] |
28 | | - (let [repl-content (repl-content project)] |
29 | | - @(app-manager/invoke-later! |
30 | | - {:invoke-fn (fn [] |
31 | | - (.addNotify repl-content) |
32 | | - (.getEditor repl-content true))}))) |
33 | | - |
34 | 25 | (defn run-editor-action [action-id project] |
35 | 26 | (let [action (.getAction (ActionManager/getInstance) action-id) |
36 | 27 | context (.getDataContext (DataManager/getInstance))] |
|
52 | 43 | deps-file (.createFile fixture "deps.edn" "{}") |
53 | 44 | _ (.setTestDataPath fixture "testdata") |
54 | 45 | clj-file (.copyFileToProject fixture "foo.clj") |
55 | | - project (.getProject fixture) |
56 | | - editor (.getEditor fixture)] |
| 46 | + project (.getProject fixture)] |
57 | 47 | (is (= project-name (.getName project))) |
58 | 48 | (is deps-file) |
59 | 49 |
|
|
81 | 71 | (println (lsp-client/server-status project)) |
82 | 72 | (println (db/get-in project [:status])) |
83 | 73 |
|
84 | | - (println "editor >> ") |
85 | | - (println editor) |
| 74 | + (let [editor (.getEditor fixture) |
| 75 | + document (.getDocument editor) |
| 76 | + offset (.getLineStartOffset document 2) |
| 77 | + caret (.getCaretModel editor) |
| 78 | + pos (.getLogicalPosition caret) |
| 79 | + new-position (LogicalPosition. 2 8)] |
| 80 | + (println "editor >> ") |
| 81 | + (println editor) |
| 82 | + (println caret) |
| 83 | + (println pos) |
| 84 | + (println (.getVisualPosition caret)) |
| 85 | + (println (.getText document)) |
| 86 | + @(app-manager/invoke-later! |
| 87 | + {:invoke-fn (fn [] |
| 88 | + #_(.moveToOffset caret (+ offset 9)) |
| 89 | + (.moveToLogicalPosition caret new-position))}) |
| 90 | + (println (.getLogicalPosition caret)) |
| 91 | + (println (.getVisualPosition caret))) |
86 | 92 | (run-editor-action "ClojureLSP.ForwardSlurp" project) |
87 | 93 |
|
| 94 | + (clj4intellij.test/dispatch-all) |
| 95 | + (println (-> fixture .getEditor .getDocument .getText)) |
| 96 | + |
88 | 97 | @(app-manager/invoke-later! |
89 | 98 | {:invoke-fn (fn [] |
90 | 99 | (let [widget (get-status-bar-widget project "ClojureLSPStatusBar")] |
|
0 commit comments