on master help sign in
minor: TODO comment cleanup
commit143cfe13e05b17840a9f2c69417ed98bc3b8cb0e authorBlaž Hrastnik <blaz@mxxn.io> dateTue 16 Mar 2021, 15:30 (6 years ago) parent4f77d80
9 files changed+15−61
TODO.md+2 helix-lsp/src/client.rs+6−16 helix-term/src/application.rs−12 helix-term/src/commands.rs−13 helix-term/src/compositor.rs−3 helix-term/src/keymap.rs−1 helix-term/src/ui/editor.rs+3−7 helix-view/src/document.rs+1−3 helix-view/src/view.rs+3−6
TODO.md+2
@@ -22,6 +22,8 @@
2222- [ ] buffers should sit on editor.buffers, view simply refs them
2323- [ ] yank on delete
2424
25+- [ ] load toml configs, themes, tabsize/identation
26+
2527- [ ] draw separator line between views
2628
2729- [ ] lsp: signature help
helix-lsp/src/client.rs+6−16
@@ -192,7 +192,7 @@ impl Client {
192192 text_document: Some(lsp::TextDocumentClientCapabilities {
193193 completion: Some(lsp::CompletionClientCapabilities {
194194 completion_item: Some(lsp::CompletionItemCapability {
195− snippet_support: Some(false), // TODO
195+ snippet_support: Some(false),
196196 ..Default::default()
197197 }),
198198 completion_item_kind: Some(lsp::CompletionItemKindCapability {
@@ -284,7 +284,6 @@ impl Client {
284284 mut character,
285285 } = pos;
286286
287− // TODO: there should be a better way here
288287 for ch in text.chars() {
289288 if ch == '\n' {
290289 line += 1;
@@ -299,8 +298,6 @@ impl Client {
299298 let old_text = old_text.slice(..);
300299 let new_text = new_text.slice(..);
301300
302− // TODO: verify this function, specifically line num counting
303−
304301 while let Some(change) = iter.next() {
305302 let len = match change {
306303 Delete(i) | Retain(i) => *i,
@@ -355,7 +352,6 @@ impl Client {
355352 changes
356353 }
357354
358− // TODO: trigger any time history.commit_revision happens
359355 pub async fn text_document_did_change(
360356 &self,
361357 text_document: lsp::VersionedTextDocumentIdentifier,
@@ -365,7 +361,7 @@ impl Client {
365361 ) -> Result<()> {
366362 // figure out what kind of sync the server supports
367363
368− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
364+ let capabilities = self.capabilities.as_ref().unwrap();
369365
370366 let sync_capabilities = match capabilities.text_document_sync {
371367 Some(lsp::TextDocumentSyncCapability::Kind(kind)) => kind,
@@ -384,7 +380,7 @@ impl Client {
384380 range: None, //Some(Range)
385381 range_length: None, // u64 apparently deprecated
386382 text: "".to_string(),
387− }] // TODO: probably need old_state here too?
383+ }]
388384 }
389385 lsp::TextDocumentSyncKind::Incremental => {
390386 Self::changeset_to_changes(old_text, new_text, changes)
@@ -416,7 +412,7 @@ impl Client {
416412 text_document: lsp::TextDocumentIdentifier,
417413 text: &Rope,
418414 ) -> Result<()> {
419− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
415+ let capabilities = self.capabilities.as_ref().unwrap();
420416
421417 let include_text = match &capabilities.text_document_sync {
422418 Some(lsp::TextDocumentSyncCapability::Options(lsp::TextDocumentSyncOptions {
@@ -446,8 +442,6 @@ impl Client {
446442 text_document: lsp::TextDocumentIdentifier,
447443 position: lsp::Position,
448444 ) -> Result<Vec<lsp::CompletionItem>> {
449− // TODO: figure out what should happen when you complete with multiple cursors
450−
451445 let params = lsp::CompletionParams {
452446 text_document_position: lsp::TextDocumentPositionParams {
453447 text_document,
@@ -489,7 +483,6 @@ impl Client {
489483 text_document,
490484 position,
491485 },
492− // TODO: support these tokens
493486 work_done_progress_params: lsp::WorkDoneProgressParams {
494487 work_done_token: None,
495488 },
@@ -514,7 +507,6 @@ impl Client {
514507 text_document,
515508 position,
516509 },
517− // TODO: support these tokens
518510 work_done_progress_params: lsp::WorkDoneProgressParams {
519511 work_done_token: None,
520512 },
@@ -533,7 +525,7 @@ impl Client {
533525 text_document: lsp::TextDocumentIdentifier,
534526 options: lsp::FormattingOptions,
535527 ) -> anyhow::Result<Vec<lsp::TextEdit>> {
536− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
528+ let capabilities = self.capabilities.as_ref().unwrap();
537529
538530 // check if we're able to format
539531 let _capabilities = match capabilities.document_formatting_provider {
@@ -547,7 +539,6 @@ impl Client {
547539 let params = lsp::DocumentFormattingParams {
548540 text_document,
549541 options,
550− // TODO: support these tokens
551542 work_done_progress_params: lsp::WorkDoneProgressParams {
552543 work_done_token: None,
553544 },
@@ -564,7 +555,7 @@ impl Client {
564555 range: lsp::Range,
565556 options: lsp::FormattingOptions,
566557 ) -> anyhow::Result<Vec<lsp::TextEdit>> {
567− let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
558+ let capabilities = self.capabilities.as_ref().unwrap();
568559
569560 // check if we're able to format
570561 let _capabilities = match capabilities.document_range_formatting_provider {
@@ -579,7 +570,6 @@ impl Client {
579570 text_document,
580571 range,
581572 options,
582− // TODO: support these tokens
583573 work_done_progress_params: lsp::WorkDoneProgressParams {
584574 work_done_token: None,
585575 },
helix-term/src/application.rs−12
@@ -221,15 +221,3 @@ impl Application {
221221 Ok(())
222222 }
223223}
224−
225−// TODO: language configs:
226−// tabSize, fileExtension etc, mapping to tree sitter parser
227−// themes:
228−// map tree sitter highlights to color values
229−//
230−// TODO: expand highlight thing so we're able to render only viewport range
231−// TODO: async: maybe pre-cache scopes as empty so we render all graphemes initially as regular
232−////text until calc finishes
233−// TODO: scope matching: biggest union match? [string] & [html, string], [string, html] & [ string, html]
234−// can do this by sorting our theme matches based on array len (longest first) then stopping at the
235−// first rule that matches (rule.all(|scope| scopes.contains(scope)))
helix-term/src/commands.rs−13
@@ -460,19 +460,6 @@ pub fn select_regex(cx: &mut Context) {
460460}
461461
462462pub fn split_selection(cx: &mut Context) {
463− // TODO: this needs to store initial selection state, revert on esc, confirm on enter
464− // needs to also call the callback function per input change, not just final time.
465− // could cheat and put it into completion_fn
466− //
467− // kakoune does it like this:
468− // # save state to register
469− // {
470− // # restore state from register
471− // # if event == abort, return early
472− // # add to history if enabled
473− // # update state
474− // }
475−
476463 let prompt = ui::regex_prompt(cx, "split:".to_string(), |doc, regex| {
477464 let text = doc.text().slice(..);
478465 let selection = selection::split_on_matches(text, doc.selection(), &regex);
helix-term/src/compositor.rs−3
@@ -54,9 +54,6 @@ pub trait Component {
5454 /// May be used by the parent component to compute the child area.
5555 /// viewport is the maximum allowed area, and the child should stay within those bounds.
5656 fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
57− // TODO: the compositor should trigger this on push_layer too so that we can use it as an
58− // initializer there too.
59− //
6057 // TODO: for scrolling, the scroll wrapper should place a size + offset on the Context
6158 // that way render can use it
6259 None
helix-term/src/keymap.rs−1
@@ -90,7 +90,6 @@ use std::collections::HashMap;
9090// #[cfg(feature = "term")]
9191pub use crossterm::event::{KeyCode, KeyEvent as Key, KeyModifiers as Modifiers};
9292
93−// TODO: could be trie based
9493pub type Keymap = HashMap<Key, Command>;
9594pub type Keymaps = HashMap<Mode, Keymap>;
9695
helix-term/src/ui/editor.rs+3−7
@@ -124,6 +124,9 @@ impl EditorView {
124124
125125 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
126126
127+ // TODO: scope matching: biggest union match? [string] & [html, string], [string, html] & [ string, html]
128+ // can do this by sorting our theme matches based on array len (longest first) then stopping at the
129+ // first rule that matches (rule.all(|scope| scopes.contains(scope)))
127130 let style = match spans.first() {
128131 Some(span) => theme.get(theme.scopes()[span.0].as_str()),
129132 None => Style::default().fg(Color::Rgb(164, 160, 232)), // lavender
@@ -138,8 +141,6 @@ impl EditorView {
138141
139142 // iterate over range char by char
140143 for grapheme in RopeGraphemes::new(text) {
141− // TODO: track current char_index
142−
143144 if grapheme == "\n" {
144145 visual_x = 0;
145146 line += 1;
@@ -433,9 +434,7 @@ impl Component for EditorView {
433434 Event::Key(event) => {
434435 let view = cx.editor.view_mut();
435436
436− // TODO: sequences (`gg`)
437437 let mode = view.doc.mode();
438− // TODO: handle count other than 1
439438 let mut cxt = commands::Context {
440439 executor: cx.executor,
441440 editor: &mut cx.editor,
@@ -479,8 +478,6 @@ impl Component for EditorView {
479478
480479 if let Some(command) = self.keymap[&mode].get(&event) {
481480 command(&mut cxt);
482−
483− // TODO: simplistic ensure cursor in view for now
484481 }
485482 }
486483 }
@@ -503,7 +500,6 @@ impl Component for EditorView {
503500
504501 fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) {
505502 for (view, is_focused) in cx.editor.tree.views() {
506− // TODO: use parent area
507503 self.render_view(view, view.area, surface, &cx.editor.theme, is_focused);
508504 }
509505 }
helix-view/src/document.rs+1−3
@@ -255,8 +255,6 @@ impl Document {
255255 return;
256256 }
257257
258− // TODO: change -> change -> undo -> change -> change fails, probably old_state needs reset
259−
260258 let new_changeset = ChangeSet::new(self.text());
261259 let changes = std::mem::replace(&mut self.changes, new_changeset);
262260 // Instead of doing this messy merge we could always commit, and based on transaction
@@ -319,7 +317,7 @@ impl Document {
319317 // self.state.doc.slice
320318 // }
321319
322− // TODO: transact(Fn) ?
320+ // transact(Fn) ?
323321
324322 // -- LSP methods
325323
helix-view/src/view.rs+3−6
@@ -13,15 +13,12 @@ use tui::layout::Rect;
1313
1414pub const PADDING: usize = 5;
1515
16−// TODO: view should be View { doc: Document(state, history,..) }
17−// since we can have multiple views into the same file
1816pub struct View {
1917 pub id: Key,
2018 pub doc: Document,
2119 pub first_line: usize,
2220 pub area: Rect,
2321}
24−// TODO: popups should be a thing on the view with a rect + text
2522
2623impl View {
2724 pub fn new(doc: Document) -> Result<Self, Error> {
@@ -54,9 +51,9 @@ impl View {
5451 /// Calculates the last visible line on screen
5552 #[inline]
5653 pub fn last_line(&self) -> usize {
57− let viewport = Rect::new(6, 0, self.area.width, self.area.height.saturating_sub(1)); // - 1 for statusline
54+ let height = self.area.height.saturating_sub(1); // - 1 for statusline
5855 std::cmp::min(
59− self.first_line + (viewport.height as usize),
56+ self.first_line + height as usize,
6057 self.doc.text().len_lines() - 1,
6158 )
6259 }
@@ -67,7 +64,7 @@ impl View {
6764 pub fn screen_coords_at_pos(&self, text: RopeSlice, pos: usize) -> Option<Position> {
6865 let line = text.char_to_line(pos);
6966
70− if line < self.first_line as usize || line > self.last_line() {
67+ if line < self.first_line || line > self.last_line() {
7168 // Line is not visible on screen
7269 return None;
7370 }